diff options
author | Christopher Ng <chrng8@gmail.com> | 2024-11-08 11:53:36 -0800 |
---|---|---|
committer | Christopher Ng <chrng8@gmail.com> | 2024-11-08 11:53:36 -0800 |
commit | d1fb691c899ae260dcbbb6f543dcee1e54df5dfa (patch) | |
tree | fe04d3afb74213e66fce3955464ba57511163e27 | |
parent | 3eadae3a69462dba2407a81a2325c9c61ee70adc (diff) | |
download | nextcloud-server-feat/file-list-actions.tar.gz nextcloud-server-feat/file-list-actions.zip |
feat(files): Add support for file list actionsfeat/file-list-actions
Signed-off-by: Christopher Ng <chrng8@gmail.com>
-rw-r--r-- | apps/files/src/views/FilesList.vue | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/apps/files/src/views/FilesList.vue b/apps/files/src/views/FilesList.vue index fdfbed6a4e3..47789e15347 100644 --- a/apps/files/src/views/FilesList.vue +++ b/apps/files/src/views/FilesList.vue @@ -45,6 +45,15 @@ multiple @failed="onUploadFail" @uploaded="onUpload" /> + + <NcButton v-for="action in enabledFileListActions" + :key="action.id" + @click="() => action.exec(currentView, dirContents, { folder: currentFolder })"> + <template #icon> + <NcIconSvgWrapper :svg="action.iconSvgInline(currentView)" /> + </template> + {{ action.displayName(currentView) }} + </NcButton> </template> </BreadCrumbs> @@ -138,7 +147,7 @@ import type { UserConfig } from '../types.ts' import { getCapabilities } from '@nextcloud/capabilities' import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus' -import { Folder, Node, Permission, sortNodes } from '@nextcloud/files' +import { Folder, Node, Permission, sortNodes, getFileListActions } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' import { join, dirname, normalize } from 'path' import { showError, showWarning } from '@nextcloud/dialogs' @@ -430,6 +439,19 @@ export default defineComponent({ showCustomEmptyView() { return !this.loading && this.isEmptyDir && this.currentView?.emptyView !== undefined }, + + enabledFileListActions() { + const actions = getFileListActions() + const enabledActions = actions + .filter(action => { + if (action.enabled === undefined) { + return true + } + return action.enabled(this.currentView, this.dirContents, { folder: this.currentFolder }) + }) + .toSorted((a, b) => a.order - b.order) + return enabledActions + }, }, watch: { |