From 0db210a0922cc32c924d196f7d38778912547fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Wed, 22 Mar 2023 12:26:35 +0100 Subject: [PATCH] chore(deps): cleanup unused deps and audit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- apps/files/src/actions/deleteAction.ts | 49 + .../src/components/CustomElementRender.vue | 39 + apps/files/src/components/FileEntry.vue | 25 +- .../files/src/components/FilesListVirtual.vue | 24 +- apps/files/src/main.js | 3 + apps/files/src/services/Navigation.ts | 4 +- package-lock.json | 47343 ---------------- package.json | 1 - 8 files changed, 106 insertions(+), 47382 deletions(-) create mode 100644 apps/files/src/actions/deleteAction.ts create mode 100644 apps/files/src/components/CustomElementRender.vue delete mode 100644 package-lock.json diff --git a/apps/files/src/actions/deleteAction.ts b/apps/files/src/actions/deleteAction.ts new file mode 100644 index 00000000000..b1bf2cb2105 --- /dev/null +++ b/apps/files/src/actions/deleteAction.ts @@ -0,0 +1,49 @@ +/** + * @copyright Copyright (c) 2023 John Molakvoæ + * + * @author John Molakvoæ + * + * @license AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +import { registerFileAction, Permission, FileAction } from '@nextcloud/files' +import { translate as t } from '@nextcloud/l10n' +import axios from '@nextcloud/axios' +import TrashCan from '@mdi/svg/svg/trash-can.svg?raw' + +registerFileAction(new FileAction({ + id: 'delete', + displayName(nodes, view) { + return view.id === 'trashbin' + ? t('files_trashbin', 'Delete permanently') + : t('files', 'Delete') + }, + iconSvgInline: () => TrashCan, + enabled(nodes) { + return nodes.length > 0 && nodes + .map(node => node.permissions) + .every(permission => (permission & Permission.DELETE) !== 0) + }, + async exec(node) { + try { + await axios.delete(node.source) + return true + } catch (error) { + console.error(error) + return false + } + }, +})) diff --git a/apps/files/src/components/CustomElementRender.vue b/apps/files/src/components/CustomElementRender.vue new file mode 100644 index 00000000000..b5dc510b645 --- /dev/null +++ b/apps/files/src/components/CustomElementRender.vue @@ -0,0 +1,39 @@ + + + + diff --git a/apps/files/src/components/FileEntry.vue b/apps/files/src/components/FileEntry.vue index 65fdf4b4c38..d507fe6945c 100644 --- a/apps/files/src/components/FileEntry.vue +++ b/apps/files/src/components/FileEntry.vue @@ -20,24 +20,25 @@ - -->