-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(trashbin): Allow emptying trash #49171
Open
Pytal
wants to merge
2
commits into
master
Choose a base branch
from
feat/empty-trash
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+87
−1
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
apps/files_trashbin/src/fileListActions/emptyTrashAction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import PQueue from 'p-queue' | ||
import { FileListAction } from '@nextcloud/files' | ||
import { DialogSeverity, getDialogBuilder, showSuccess } from '@nextcloud/dialogs' | ||
|
||
import TrashCanSvg from '@mdi/svg/svg/trash-can.svg?raw' | ||
|
||
import { deleteNode } from '../../../files/src/actions/deleteUtils.ts' | ||
import { logger } from '../logger.ts' | ||
|
||
const queue = new PQueue({ concurrency: 5 }) | ||
|
||
export const emptyTrashAction = new FileListAction({ | ||
id: 'empty-trash', | ||
|
||
displayName: () => t('files_trashbin', 'Empty deleted files'), | ||
iconSvgInline: () => TrashCanSvg, | ||
order: 0, | ||
|
||
enabled: (view, nodes, { folder }) => { | ||
if (view.id !== 'trashbin') { | ||
return false | ||
} | ||
|
||
return nodes.length > 0 && folder.path === '/' | ||
}, | ||
|
||
exec: async (view, nodes) => { | ||
const dialog = getDialogBuilder(t('files_trashbin', 'Confirm permanent deletion')) | ||
.setSeverity(DialogSeverity.Warning) | ||
// TODO Add note for groupfolders | ||
.setText(t('files_trashbin', "Are you sure you want to permanently delete the items in deleted files? You can't undo this action.")) | ||
.setButtons([ | ||
{ | ||
label: t('files_trashbin', 'Cancel'), | ||
type: 'secondary', | ||
callback: () => {}, | ||
}, | ||
{ | ||
label: t('files_trashbin', 'Empty deleted files'), | ||
type: 'error', | ||
callback: async () => { | ||
for (const node of nodes) { | ||
queue.add(async () => { | ||
try { | ||
await deleteNode(node) | ||
} catch (error) { | ||
logger.error('Failed to delete node', { error, node }) | ||
} | ||
}) | ||
} | ||
queue.once('empty', () => { | ||
showSuccess(t('files_trashbin', 'Permanently deleted items in deleted files')) | ||
}) | ||
}, | ||
}, | ||
]) | ||
.build() | ||
|
||
try { | ||
await dialog.show() | ||
} catch (error) { | ||
// Allow throw on dialog close | ||
} | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import { getLoggerBuilder } from '@nextcloud/logger' | ||
|
||
export const logger = getLoggerBuilder() | ||
.setApp('files_trashbin') | ||
.detectUser() | ||
.build() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The phrasing looks odd to me :)
Maybe something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the UI we call it "Deleted files" so this would be inconsistent, maybe we should change it to "Trash" or "Trash bin" everywhere @marcoambrosini?