mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
Merge pull request #42967 from nextcloud/fix/files/42956
This commit is contained in:
commit
1a5d5a22e0
4 changed files with 30 additions and 6 deletions
|
|
@ -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
|
||||
|
|
@ -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',
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
4
dist/files-init.js
vendored
4
dist/files-init.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-init.js.map
vendored
2
dist/files-init.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue