From ada6a61688a7bfacf0a9d8ef4ec58d3cb56c9acc Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 2 Aug 2024 12:32:30 +0200 Subject: [PATCH] fix(files): Do not allow rename action on single-file-shares Signed-off-by: Ferdinand Thiessen --- apps/files/src/actions/renameAction.ts | 16 +++++++++++----- 1 file 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) {