aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2024-01-04 13:38:46 +0100
committerJohn Molakvoæ <skjnldsv@protonmail.com>2024-01-11 11:57:48 +0100
commit32071942de292cd63fa29e60c4de02669cf93166 (patch)
tree94f93fe00c599d0e05e48b341d54e3b9783b0f58 /apps
parent744720b443c23fadcbb929e86c699aaf35fbadb3 (diff)
downloadnextcloud-server-32071942de292cd63fa29e60c4de02669cf93166.tar.gz
nextcloud-server-32071942de292cd63fa29e60c4de02669cf93166.zip
fix(files): fix unshare action
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/src/actions/deleteAction.ts27
1 files changed, 26 insertions, 1 deletions
diff --git a/apps/files/src/actions/deleteAction.ts b/apps/files/src/actions/deleteAction.ts
index f79872f1685..29f1cf86c9b 100644
--- a/apps/files/src/actions/deleteAction.ts
+++ b/apps/files/src/actions/deleteAction.ts
@@ -24,17 +24,42 @@ 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: () => TrashCanSvg,
+ iconSvgInline: (nodes: Node[]) => {
+ if (isAllUnshare(nodes)) {
+ return CloseSvg
+ }
+ return TrashCanSvg
+ },
enabled(nodes: Node[]) {
return nodes.length > 0 && nodes