diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2023-03-25 11:51:11 +0100 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2023-04-06 14:49:31 +0200 |
commit | f28944e23f96dd756cba3739e99c2fba57e81f1f (patch) | |
tree | e6fde2f68c458184d5f81d2c095f2903c0917e60 /apps/files_trashbin | |
parent | e85eb4c59395c4c59d0bb19fb8ad64063a8d7f3b (diff) | |
download | nextcloud-server-f28944e23f96dd756cba3739e99c2fba57e81f1f.tar.gz nextcloud-server-f28944e23f96dd756cba3739e99c2fba57e81f1f.zip |
feat(files): propagate restore and delete events
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r-- | apps/files_trashbin/src/actions/restoreAction.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/apps/files_trashbin/src/actions/restoreAction.ts b/apps/files_trashbin/src/actions/restoreAction.ts index d65ff3f0799..201fffe6a53 100644 --- a/apps/files_trashbin/src/actions/restoreAction.ts +++ b/apps/files_trashbin/src/actions/restoreAction.ts @@ -19,12 +19,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -import { registerFileAction, Permission, FileAction } from '@nextcloud/files' +import { registerFileAction, Permission, FileAction, Node } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import axios from '@nextcloud/axios' import History from '@mdi/svg/svg/history.svg?raw' import { generateRemoteUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' +import { emit } from '@nextcloud/event-bus' registerFileAction(new FileAction({ id: 'restore', @@ -32,7 +33,7 @@ registerFileAction(new FileAction({ return t('files_trashbin', 'Restore') }, iconSvgInline: () => History, - enabled(nodes, view) { + enabled(nodes: Node[], view) { // Only available in the trashbin view if (view.id !== 'trashbin') { return false @@ -43,15 +44,20 @@ registerFileAction(new FileAction({ .map(node => node.permissions) .every(permission => (permission & Permission.READ) !== 0) }, - async exec(node) { + async exec(node: Node) { // No try...catch here, let the files app handle the error + const destination = generateRemoteUrl(`dav/trashbin/${getCurrentUser()?.uid}/restore/${node.basename}`) await axios({ method: 'MOVE', url: node.source, headers: { - destination: generateRemoteUrl(`dav/trashbin/${getCurrentUser()?.uid}/restore/${node.basename}`), + destination, }, }) + + // Let's pretend the file is deleted since + // we don't know the restored location + emit('files:file:deleted', node) return true }, order: 1, |