Skip to content

Commit 5ee989b

Browse files
committed
fix(files): do not show View in folder in the Files view
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
1 parent aeb5047 commit 5ee989b

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

apps/files/src/actions/viewInFolderAction.spec.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ import { expect } from '@jest/globals'
2424
import { File, Folder, Node, Permission, View, FileAction } from '@nextcloud/files'
2525

2626
const view = {
27+
id: 'trashbin',
28+
name: 'Trashbin',
29+
} as View
30+
31+
const viewFiles = {
2732
id: 'files',
2833
name: 'Files',
2934
} as View
@@ -36,11 +41,12 @@ describe('View in folder action conditions tests', () => {
3641
expect(action.iconSvgInline([], view)).toBe('<svg>SvgMock</svg>')
3742
expect(action.default).toBeUndefined()
3843
expect(action.order).toBe(80)
44+
expect(action.enabled).toBeDefined()
3945
})
4046
})
4147

4248
describe('View in folder action enabled tests', () => {
43-
test('Enabled for files', () => {
49+
test('Enabled for trashbin', () => {
4450
const file = new File({
4551
id: 1,
4652
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
@@ -53,6 +59,19 @@ describe('View in folder action enabled tests', () => {
5359
expect(action.enabled!([file], view)).toBe(true)
5460
})
5561

62+
test('Disabled for files', () => {
63+
const file = new File({
64+
id: 1,
65+
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
66+
owner: 'admin',
67+
mime: 'text/plain',
68+
permissions: Permission.ALL,
69+
})
70+
71+
expect(action.enabled).toBeDefined()
72+
expect(action.enabled!([file], viewFiles)).toBe(false)
73+
})
74+
5675
test('Disabled without permissions', () => {
5776
const file = new File({
5877
id: 1,

apps/files/src/actions/viewInFolderAction.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ export const action = new FileAction({
3030
},
3131
iconSvgInline: () => FolderMoveSvg,
3232

33-
enabled(nodes: Node[]) {
33+
enabled(nodes: Node[], view: View) {
34+
// Only works outside of the main files view
35+
if (view.id === 'files') {
36+
return false
37+
}
38+
3439
// Only works on single node
3540
if (nodes.length !== 1) {
3641
return false
@@ -49,7 +54,7 @@ export const action = new FileAction({
4954
return node.type === FileType.File
5055
},
5156

52-
async exec(node: Node, view: View, dir: string) {
57+
async exec(node: Node) {
5358
if (!node || node.type !== FileType.File) {
5459
return false
5560
}

0 commit comments

Comments
 (0)