aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src/actions/deleteAction.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/src/actions/deleteAction.ts')
-rw-r--r--apps/files/src/actions/deleteAction.ts26
1 files changed, 15 insertions, 11 deletions
diff --git a/apps/files/src/actions/deleteAction.ts b/apps/files/src/actions/deleteAction.ts
index 8d8aa4f9deb..fa4fdfe8cdc 100644
--- a/apps/files/src/actions/deleteAction.ts
+++ b/apps/files/src/actions/deleteAction.ts
@@ -3,16 +3,16 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { Permission, Node, View, FileAction } from '@nextcloud/files'
-import { showInfo } from '@nextcloud/dialogs'
-import { translate as t } from '@nextcloud/l10n'
+import { loadState } from '@nextcloud/initial-state'
import PQueue from 'p-queue'
import CloseSvg from '@mdi/svg/svg/close.svg?raw'
import NetworkOffSvg from '@mdi/svg/svg/network-off.svg?raw'
-import TrashCanSvg from '@mdi/svg/svg/trash-can.svg?raw'
+import TrashCanSvg from '@mdi/svg/svg/trash-can-outline.svg?raw'
+import { TRASHBIN_VIEW_ID } from '../../../files_trashbin/src/files_views/trashbinView.ts'
+import { askConfirmation, canDisconnectOnly, canUnshareOnly, deleteNode, displayName, shouldAskForConfirmation } from './deleteUtils.ts'
import logger from '../logger.ts'
-import { askConfirmation, canDisconnectOnly, canUnshareOnly, deleteNode, displayName, isTrashbinEnabled } from './deleteUtils'
const queue = new PQueue({ concurrency: 5 })
@@ -33,7 +33,14 @@ export const action = new FileAction({
return TrashCanSvg
},
- enabled(nodes: Node[]) {
+ enabled(nodes: Node[], view: View): boolean {
+ if (view.id === TRASHBIN_VIEW_ID) {
+ const config = loadState('files_trashbin', 'config', { allow_delete: true })
+ if (config.allow_delete === false) {
+ return false
+ }
+ }
+
return nodes.length > 0 && nodes
.map(node => node.permissions)
.every(permission => (permission & Permission.DELETE) !== 0)
@@ -49,14 +56,12 @@ export const action = new FileAction({
const callStack = new Error().stack || ''
const isCalledFromEventListener = callStack.toLocaleLowerCase().includes('keydown')
- // If trashbin is disabled, we need to ask for confirmation
- if (!isTrashbinEnabled() || isCalledFromEventListener) {
+ if (shouldAskForConfirmation() || isCalledFromEventListener) {
confirm = await askConfirmation([node], view)
}
// If the user cancels the deletion, we don't want to do anything
if (confirm === false) {
- showInfo(t('files', 'Deletion cancelled'))
return null
}
@@ -72,8 +77,7 @@ export const action = new FileAction({
async execBatch(nodes: Node[], view: View): Promise<(boolean | null)[]> {
let confirm = true
- // If trashbin is disabled, we need to ask for confirmation
- if (!isTrashbinEnabled()) {
+ if (shouldAskForConfirmation()) {
confirm = await askConfirmation(nodes, view)
} else if (nodes.length >= 5 && !canUnshareOnly(nodes) && !canDisconnectOnly(nodes)) {
confirm = await askConfirmation(nodes, view)
@@ -81,7 +85,6 @@ export const action = new FileAction({
// If the user cancels the deletion, we don't want to do anything
if (confirm === false) {
- showInfo(t('files', 'Deletion cancelled'))
return Promise.all(nodes.map(() => null))
}
@@ -105,5 +108,6 @@ export const action = new FileAction({
return Promise.all(promises)
},
+ destructive: true,
order: 100,
})