diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-27 13:10:32 +0200 |
---|---|---|
committer | Andy Scherzinger <info@andy-scherzinger.de> | 2024-08-28 17:22:20 +0200 |
commit | 030c209d22ea93b2f168bd02521d83c525ea26ab (patch) | |
tree | 5f5369c71abcd9746dccc49b186d5427f016b62a /apps/files/src | |
parent | 0d41c4991859533b4df89e41368c21437b7464f5 (diff) | |
download | nextcloud-server-030c209d22ea93b2f168bd02521d83c525ea26ab.tar.gz nextcloud-server-030c209d22ea93b2f168bd02521d83c525ea26ab.zip |
fix: Renaming does not need update but delete permissions
Renaming is basically copy + delete (a move), so no need to update permissions.
Especially if the node is in a invalid directory the node should be moveable but not editable.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files/src')
-rw-r--r-- | apps/files/src/actions/moveOrCopyActionUtils.ts | 2 | ||||
-rw-r--r-- | apps/files/src/actions/renameAction.spec.ts | 4 | ||||
-rw-r--r-- | apps/files/src/actions/renameAction.ts | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/apps/files/src/actions/moveOrCopyActionUtils.ts b/apps/files/src/actions/moveOrCopyActionUtils.ts index d2e276b2b93..0c7822390ac 100644 --- a/apps/files/src/actions/moveOrCopyActionUtils.ts +++ b/apps/files/src/actions/moveOrCopyActionUtils.ts @@ -38,7 +38,7 @@ export type MoveCopyResult = { export const canMove = (nodes: Node[]) => { const minPermission = nodes.reduce((min, node) => Math.min(min, node.permissions), Permission.ALL) - return (minPermission & Permission.UPDATE) !== 0 + return Boolean(minPermission & Permission.DELETE) } export const canDownload = (nodes: Node[]) => { diff --git a/apps/files/src/actions/renameAction.spec.ts b/apps/files/src/actions/renameAction.spec.ts index b309c11d9a6..954eca5820f 100644 --- a/apps/files/src/actions/renameAction.spec.ts +++ b/apps/files/src/actions/renameAction.spec.ts @@ -30,14 +30,14 @@ describe('Rename action enabled tests', () => { source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt', owner: 'admin', mime: 'text/plain', - permissions: Permission.UPDATE, + permissions: Permission.UPDATE | Permission.DELETE, }) expect(action.enabled).toBeDefined() expect(action.enabled!([file], view)).toBe(true) }) - test('Disabled for node without UPDATE permission', () => { + test('Disabled for node without DELETE permission', () => { const file = new File({ id: 1, source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt', diff --git a/apps/files/src/actions/renameAction.ts b/apps/files/src/actions/renameAction.ts index c00a99b4de1..e4dbb0ed129 100644 --- a/apps/files/src/actions/renameAction.ts +++ b/apps/files/src/actions/renameAction.ts @@ -17,7 +17,7 @@ export const action = new FileAction({ enabled: (nodes: Node[]) => { return nodes.length > 0 && nodes .map(node => node.permissions) - .every(permission => (permission & Permission.UPDATE) !== 0) + .every(permission => Boolean(permission & Permission.DELETE)) }, async exec(node: Node) { |