Skip to content

Commit

Permalink
fix(files): open sidebar on sharing tab by default for files
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <[email protected]>
  • Loading branch information
skjnldsv authored and backportbot[bot] committed Nov 8, 2024
1 parent cc1197d commit 97888b0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
30 changes: 30 additions & 0 deletions apps/files/src/actions/sidebarAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down
3 changes: 3 additions & 0 deletions apps/files/src/actions/sidebarAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/files_sharing/files-inline-action.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 97888b0

Please sign in to comment.