From 54af3a4a5fbed9bc342b50363c28776627a1231c Mon Sep 17 00:00:00 2001 From: "@suet-kei.chan" Date: Tue, 21 Jul 2026 16:55:29 +0200 Subject: [PATCH] fix: enable rename action for items in the favorites view The core files app hides "Rename" for every item in the Favorites view because its enabled() check requires the real parent folder to have CREATE permission. Favorites is a flattened list aggregating items from many different folders, so no single real parent is resolvable, and the check always fails there. Patch the rename action's enabled() at runtime, scoped to the favorites view only, to fall back to the node's own DELETE + UPDATE permission bits instead of the parent folder's permissions. All other views keep the original, unmodified behavior. --- src/nmcfiles.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/nmcfiles.ts b/src/nmcfiles.ts index ecda776..04a9823 100644 --- a/src/nmcfiles.ts +++ b/src/nmcfiles.ts @@ -50,6 +50,25 @@ registerFileAction(fileAction) const FileActions = getFileActions() +const renameAction = FileActions.find(action => action.id === 'rename') + +if (renameAction?.enabled) { + const originalEnabled = renameAction.enabled + + // Relies on `_action` being a plain field on FileAction (@nextcloud/files + // internal detail) - re-verify on @nextcloud/files upgrades. + ;(renameAction as unknown as { _action: { enabled: typeof originalEnabled } })._action.enabled = (nodes: Node[], view: View) => { + if (view.id !== 'favorites') { + return originalEnabled(nodes, view) + } + + return nodes.every(node => + Boolean(node.permissions & Permission.DELETE) + && Boolean(node.permissions & Permission.UPDATE), + ) + } +} + const sharingStatusAction = FileActions.find(action => action.id === 'sharing-status') if (sharingStatusAction) {