From 97888b083b5fec8730d2d5039bdfc061bf33a28f Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Fri, 8 Nov 2024 11:02:53 +0100 Subject: [PATCH] fix(files): open sidebar on sharing tab by default for files Signed-off-by: skjnldsv --- apps/files/src/actions/sidebarAction.spec.ts | 30 +++++++++++++++++++ apps/files/src/actions/sidebarAction.ts | 3 ++ .../files_sharing/files-inline-action.cy.ts | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/apps/files/src/actions/sidebarAction.spec.ts b/apps/files/src/actions/sidebarAction.spec.ts index 21b48eba1051a..3a96c198f32bd 100644 --- a/apps/files/src/actions/sidebarAction.spec.ts +++ b/apps/files/src/actions/sidebarAction.spec.ts @@ -124,6 +124,36 @@ describe('Open sidebar action exec tests', () => { // Silent action expect(exec).toBe(null) expect(openMock).toBeCalledWith('/foobar.txt') + expect(defaultTabMock).toBeCalledWith('sharing') + expect(goToRouteMock).toBeCalledWith( + null, + { view: view.id, fileid: '1' }, + { dir: '/' }, + true, + ) + }) + + test('Open sidebar for folder', async () => { + const openMock = vi.fn() + const defaultTabMock = vi.fn() + window.OCA = { Files: { Sidebar: { open: openMock, setActiveTab: defaultTabMock } } } + + const goToRouteMock = vi.fn() + // @ts-expect-error We only mock what needed, we do not need Files.Router.goTo or Files.Navigation + window.OCP = { Files: { Router: { goToRoute: goToRouteMock } } } + + const file = new Folder({ + id: 1, + source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar', + owner: 'admin', + mime: 'httpd/unix-directory', + }) + + const exec = await action.exec(file, view, '/') + // Silent action + expect(exec).toBe(null) + expect(openMock).toBeCalledWith('/foobar') + expect(defaultTabMock).toBeCalledWith('sharing') expect(goToRouteMock).toBeCalledWith( null, { view: view.id, fileid: '1' }, diff --git a/apps/files/src/actions/sidebarAction.ts b/apps/files/src/actions/sidebarAction.ts index f00088f8d0c8f..6dcb6df2bbcca 100644 --- a/apps/files/src/actions/sidebarAction.ts +++ b/apps/files/src/actions/sidebarAction.ts @@ -36,6 +36,9 @@ export const action = new FileAction({ async exec(node: Node, view: View, dir: string) { try { + // Open sidebar and set active tab to sharing by default + window.OCA.Files.Sidebar.setActiveTab('sharing') + // TODO: migrate Sidebar to use a Node instead await window.OCA.Files.Sidebar.open(node.path) diff --git a/cypress/e2e/files_sharing/files-inline-action.cy.ts b/cypress/e2e/files_sharing/files-inline-action.cy.ts index 0fd476ca6ed5f..4d7763bd7786f 100644 --- a/cypress/e2e/files_sharing/files-inline-action.cy.ts +++ b/cypress/e2e/files_sharing/files-inline-action.cy.ts @@ -29,7 +29,7 @@ describe('files_sharing: Files inline status action', { testIsolation: true }, ( .should('not.exist') }) - describe('', () => { + describe('Sharing inline status action handling', () => { let user: User let sharee: User