Skip to content

Commit dd87b3a

Browse files
committed
fix(files): disable Unshare until proper fix
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
1 parent 787b2a3 commit dd87b3a

File tree

4 files changed

+19
-41
lines changed

4 files changed

+19
-41
lines changed

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ describe('Delete action conditions tests', () => {
5050
permissions: Permission.ALL,
5151
})
5252

53-
const file2 = new File({
54-
id: 1,
55-
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
56-
owner: 'admin',
57-
mime: 'text/plain',
58-
permissions: Permission.ALL,
59-
})
53+
// const file2 = new File({
54+
// id: 1,
55+
// source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
56+
// owner: 'admin',
57+
// mime: 'text/plain',
58+
// permissions: Permission.ALL,
59+
// })
6060

6161
test('Default values', () => {
6262
expect(action).toBeInstanceOf(FileAction)
@@ -71,14 +71,15 @@ describe('Delete action conditions tests', () => {
7171
expect(action.displayName([file], trashbinView)).toBe('Delete permanently')
7272
})
7373

74-
test('Shared node values', () => {
75-
jest.spyOn(auth, 'getCurrentUser').mockReturnValue(null)
76-
expect(action.displayName([file2], view)).toBe('Unshare')
77-
})
74+
// TODO: Fix this test
75+
// test('Shared node values', () => {
76+
// jest.spyOn(auth, 'getCurrentUser').mockReturnValue(null)
77+
// expect(action.displayName([file2], view)).toBe('Unshare')
78+
// })
7879

79-
test('Shared and owned nodes values', () => {
80-
expect(action.displayName([file, file2], view)).toBe('Delete and unshare')
81-
})
80+
// test('Shared and owned nodes values', () => {
81+
// expect(action.displayName([file, file2], view)).toBe('Delete and unshare')
82+
// })
8283
})
8384

8485
describe('Delete action enabled tests', () => {

apps/files/src/actions/deleteAction.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,17 @@ import { Permission, Node, View, FileAction } from '@nextcloud/files'
2424
import { translate as t } from '@nextcloud/l10n'
2525
import axios from '@nextcloud/axios'
2626
import TrashCanSvg from '@mdi/svg/svg/trash-can.svg?raw'
27-
import CloseSvg from '@mdi/svg/svg/close.svg?raw'
2827

2928
import logger from '../logger.js'
30-
import { getCurrentUser } from '@nextcloud/auth'
31-
32-
const isAllUnshare = (nodes: Node[]) => {
33-
return !nodes.some(node => node.owner === getCurrentUser()?.uid)
34-
}
35-
36-
const isMixedUnshareAndDelete = (nodes: Node[]) => {
37-
const hasUnshareItems = nodes.some(node => node.owner !== getCurrentUser()?.uid)
38-
const hasDeleteItems = nodes.some(node => node.owner === getCurrentUser()?.uid)
39-
return hasUnshareItems && hasDeleteItems
40-
}
4129

4230
export const action = new FileAction({
4331
id: 'delete',
4432
displayName(nodes: Node[], view: View) {
45-
if (isMixedUnshareAndDelete(nodes)) {
46-
return t('files', 'Delete and unshare')
47-
}
48-
49-
if (isAllUnshare(nodes)) {
50-
return t('files', 'Unshare')
51-
}
52-
5333
return view.id === 'trashbin'
5434
? t('files', 'Delete permanently')
5535
: t('files', 'Delete')
5636
},
57-
iconSvgInline: (nodes: Node[]) => {
58-
if (isAllUnshare(nodes)) {
59-
return CloseSvg
60-
}
37+
iconSvgInline: () => {
6138
return TrashCanSvg
6239
},
6340

dist/files-init.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)