mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(files): allow renaming if parent allow creating
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
This commit is contained in:
parent
e167dc1dd7
commit
ce15c53c69
1 changed files with 16 additions and 2 deletions
|
|
@ -6,6 +6,9 @@ import { emit } from '@nextcloud/event-bus'
|
|||
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'
|
||||
import { getPinia } from '../store'
|
||||
import { useFilesStore } from '../store/files'
|
||||
import { dirname } from 'path'
|
||||
|
||||
export const ACTION_RENAME = 'rename'
|
||||
|
||||
|
|
@ -18,12 +21,23 @@ export const action = new FileAction({
|
|||
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) && Boolean(node.permissions & Permission.UPDATE))
|
||||
|
||||
const node = nodes[0]
|
||||
const filesStore = useFilesStore(getPinia())
|
||||
const parentNode = node.dirname === '/'
|
||||
? filesStore.getRoot(view.id)
|
||||
: filesStore.getNode(dirname(node.source))
|
||||
const parentPermissions = parentNode?.permissions || Permission.NONE
|
||||
|
||||
// Only enable if the node have the delete permission
|
||||
// and if the parent folder allows creating files
|
||||
return Boolean(node.permissions & Permission.DELETE)
|
||||
&& Boolean(parentPermissions & Permission.CREATE)
|
||||
},
|
||||
|
||||
async exec(node: Node) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue