aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-08-02 12:32:30 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-09-06 03:38:47 +0200
commitada6a61688a7bfacf0a9d8ef4ec58d3cb56c9acc (patch)
treef28d8b95d2203ed3b94bbe2f27894173d125def9 /apps/files
parent563f8e7c5d4c44d6f17abe615885b3564e23c193 (diff)
downloadnextcloud-server-ada6a61688a7bfacf0a9d8ef4ec58d3cb56c9acc.tar.gz
nextcloud-server-ada6a61688a7bfacf0a9d8ef4ec58d3cb56c9acc.zip
fix(files): Do not allow rename action on single-file-shares
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/src/actions/renameAction.ts16
1 files changed, 11 insertions, 5 deletions
diff --git a/apps/files/src/actions/renameAction.ts b/apps/files/src/actions/renameAction.ts
index e4dbb0ed129..13ba32aaae9 100644
--- a/apps/files/src/actions/renameAction.ts
+++ b/apps/files/src/actions/renameAction.ts
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { emit } from '@nextcloud/event-bus'
-import { Permission, type Node, FileAction } from '@nextcloud/files'
+import { Permission, type Node, FileAction, View } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import PencilSvg from '@mdi/svg/svg/pencil.svg?raw'
@@ -14,10 +14,16 @@ export const action = new FileAction({
displayName: () => t('files', 'Rename'),
iconSvgInline: () => PencilSvg,
- enabled: (nodes: Node[]) => {
- return nodes.length > 0 && nodes
- .map(node => node.permissions)
- .every(permission => Boolean(permission & Permission.DELETE))
+ enabled: (nodes: Node[], view: View) => {
+ if (nodes.length === 0) {
+ return false
+ }
+ // Disable for single file shares
+ if (view.id === 'public-file-share') {
+ return false
+ }
+ // Only enable if all nodes have the delete permission
+ return nodes.every((node) => Boolean(node.permissions & Permission.DELETE))
},
async exec(node: Node) {