mirror of
https://github.com/nextcloud/server.git
synced 2026-06-13 10:40:40 -04:00
fix(files): Do not allow rename action on single-file-shares
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
563f8e7c5d
commit
ada6a61688
1 changed files with 11 additions and 5 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue