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): do not show View in folder in the Files view #43030

Merged
merged 2 commits into from Jan 22, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 20 additions & 1 deletion apps/files/src/actions/viewInFolderAction.spec.ts
Expand Up @@ -24,6 +24,11 @@ import { expect } from '@jest/globals'
import { File, Folder, Node, Permission, View, FileAction } from '@nextcloud/files'

const view = {
id: 'trashbin',
name: 'Trashbin',
} as View

const viewFiles = {
id: 'files',
name: 'Files',
} as View
Expand All @@ -36,11 +41,12 @@ describe('View in folder action conditions tests', () => {
expect(action.iconSvgInline([], view)).toBe('<svg>SvgMock</svg>')
expect(action.default).toBeUndefined()
expect(action.order).toBe(80)
expect(action.enabled).toBeDefined()
})
})

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

test('Disabled for files', () => {
const file = new File({
id: 1,
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
owner: 'admin',
mime: 'text/plain',
permissions: Permission.ALL,
})

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

test('Disabled without permissions', () => {
const file = new File({
id: 1,
Expand Down
9 changes: 7 additions & 2 deletions apps/files/src/actions/viewInFolderAction.ts
Expand Up @@ -30,7 +30,12 @@ export const action = new FileAction({
},
iconSvgInline: () => FolderMoveSvg,

enabled(nodes: Node[]) {
enabled(nodes: Node[], view: View) {
// Only works outside of the main files view
if (view.id === 'files') {
return false
}

// Only works on single node
if (nodes.length !== 1) {
return false
Expand All @@ -49,7 +54,7 @@ export const action = new FileAction({
return node.type === FileType.File
},

async exec(node: Node, view: View, dir: string) {
async exec(node: Node) {
if (!node || node.type !== FileType.File) {
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.