diff options
Diffstat (limited to 'apps/files/src/actions/deleteAction.ts')
-rw-r--r-- | apps/files/src/actions/deleteAction.ts | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/apps/files/src/actions/deleteAction.ts b/apps/files/src/actions/deleteAction.ts index 8b3f45196e9..fa4fdfe8cdc 100644 --- a/apps/files/src/actions/deleteAction.ts +++ b/apps/files/src/actions/deleteAction.ts @@ -2,20 +2,17 @@ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -import type { FilesTrashbinConfigState } from '../../../files_trashbin/src/fileListActions/emptyTrashAction.ts' - -import { loadState } from '@nextcloud/initial-state' 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 }) @@ -36,10 +33,12 @@ export const action = new FileAction({ return TrashCanSvg }, - enabled(nodes: Node[]) { - const config = loadState<FilesTrashbinConfigState>('files_trashbin', 'config') - if (!config.allow_delete) { - return false + 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 @@ -57,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 } @@ -80,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) @@ -89,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)) } @@ -113,5 +108,6 @@ export const action = new FileAction({ return Promise.all(promises) }, + destructive: true, order: 100, }) |