Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable28] fix(files): view-in-folder enabled conditions #49178

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apps/files/src/actions/viewInFolderAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ describe('View in folder action enabled tests', () => {
expect(action.enabled).toBeDefined()
expect(action.enabled!([folder], view)).toBe(false)
})

test('Disabled for files outside the user root folder', () => {
const file = new Folder({
id: 1,
source: 'https://cloud.domain.com/remote.php/dav/trashbin/admin/trash/image.jpg.d1731053878',
owner: 'admin',
permissions: Permission.READ,
})

expect(action.enabled).toBeDefined()
expect(action.enabled!([file], view)).toBe(false)
})
})

describe('View in folder action execute tests', () => {
Expand Down
5 changes: 5 additions & 0 deletions apps/files/src/actions/viewInFolderAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ export const action = new FileAction({
return false
}

// Can only view files that are in the user root folder
if (!node.root?.startsWith('/files')) {
return false
}

if (node.permissions === Permission.NONE) {
return false
}
Expand Down
4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

Loading