mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 22:27:31 -04:00
Merge pull request #43152 from nextcloud/fix/unshare
This commit is contained in:
commit
b6f64cb41f
4 changed files with 19 additions and 41 deletions
|
|
@ -50,13 +50,13 @@ describe('Delete action conditions tests', () => {
|
|||
permissions: Permission.ALL,
|
||||
})
|
||||
|
||||
const file2 = new File({
|
||||
id: 1,
|
||||
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
|
||||
owner: 'admin',
|
||||
mime: 'text/plain',
|
||||
permissions: Permission.ALL,
|
||||
})
|
||||
// const file2 = new File({
|
||||
// id: 1,
|
||||
// source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
|
||||
// owner: 'admin',
|
||||
// mime: 'text/plain',
|
||||
// permissions: Permission.ALL,
|
||||
// })
|
||||
|
||||
test('Default values', () => {
|
||||
expect(action).toBeInstanceOf(FileAction)
|
||||
|
|
@ -71,14 +71,15 @@ describe('Delete action conditions tests', () => {
|
|||
expect(action.displayName([file], trashbinView)).toBe('Delete permanently')
|
||||
})
|
||||
|
||||
test('Shared node values', () => {
|
||||
jest.spyOn(auth, 'getCurrentUser').mockReturnValue(null)
|
||||
expect(action.displayName([file2], view)).toBe('Unshare')
|
||||
})
|
||||
// TODO: Fix this test
|
||||
// test('Shared node values', () => {
|
||||
// jest.spyOn(auth, 'getCurrentUser').mockReturnValue(null)
|
||||
// expect(action.displayName([file2], view)).toBe('Unshare')
|
||||
// })
|
||||
|
||||
test('Shared and owned nodes values', () => {
|
||||
expect(action.displayName([file, file2], view)).toBe('Delete and unshare')
|
||||
})
|
||||
// test('Shared and owned nodes values', () => {
|
||||
// expect(action.displayName([file, file2], view)).toBe('Delete and unshare')
|
||||
// })
|
||||
})
|
||||
|
||||
describe('Delete action enabled tests', () => {
|
||||
|
|
|
|||
|
|
@ -24,40 +24,17 @@ import { Permission, Node, View, FileAction } from '@nextcloud/files'
|
|||
import { translate as t } from '@nextcloud/l10n'
|
||||
import axios from '@nextcloud/axios'
|
||||
import TrashCanSvg from '@mdi/svg/svg/trash-can.svg?raw'
|
||||
import CloseSvg from '@mdi/svg/svg/close.svg?raw'
|
||||
|
||||
import logger from '../logger.js'
|
||||
import { getCurrentUser } from '@nextcloud/auth'
|
||||
|
||||
const isAllUnshare = (nodes: Node[]) => {
|
||||
return !nodes.some(node => node.owner === getCurrentUser()?.uid)
|
||||
}
|
||||
|
||||
const isMixedUnshareAndDelete = (nodes: Node[]) => {
|
||||
const hasUnshareItems = nodes.some(node => node.owner !== getCurrentUser()?.uid)
|
||||
const hasDeleteItems = nodes.some(node => node.owner === getCurrentUser()?.uid)
|
||||
return hasUnshareItems && hasDeleteItems
|
||||
}
|
||||
|
||||
export const action = new FileAction({
|
||||
id: 'delete',
|
||||
displayName(nodes: Node[], view: View) {
|
||||
if (isMixedUnshareAndDelete(nodes)) {
|
||||
return t('files', 'Delete and unshare')
|
||||
}
|
||||
|
||||
if (isAllUnshare(nodes)) {
|
||||
return t('files', 'Unshare')
|
||||
}
|
||||
|
||||
return view.id === 'trashbin'
|
||||
? t('files', 'Delete permanently')
|
||||
: t('files', 'Delete')
|
||||
},
|
||||
iconSvgInline: (nodes: Node[]) => {
|
||||
if (isAllUnshare(nodes)) {
|
||||
return CloseSvg
|
||||
}
|
||||
iconSvgInline: () => {
|
||||
return TrashCanSvg
|
||||
},
|
||||
|
||||
|
|
|
|||
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