diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2023-04-21 15:40:27 +0200 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2023-04-21 15:49:54 +0200 |
commit | 1de3666e16af8362789d7a000c93b9aea1229c12 (patch) | |
tree | ba0a961078cf69f8a10e140b5197f8271793e05f | |
parent | 6e29560475f328f3f2cfe908895287f9c095eadd (diff) | |
download | nextcloud-server-1de3666e16af8362789d7a000c93b9aea1229c12.tar.gz nextcloud-server-1de3666e16af8362789d7a000c93b9aea1229c12.zip |
feat(files): add dir file action parameter
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
-rw-r--r-- | apps/files/src/actions/deleteAction.ts | 7 | ||||
-rw-r--r-- | apps/files/src/components/FileEntry.vue | 4 | ||||
-rw-r--r-- | apps/files/src/components/FilesListHeaderActions.vue | 6 | ||||
-rw-r--r-- | apps/files/src/services/FileAction.ts | 5 |
4 files changed, 14 insertions, 8 deletions
diff --git a/apps/files/src/actions/deleteAction.ts b/apps/files/src/actions/deleteAction.ts index 087884b3362..a633e477b1f 100644 --- a/apps/files/src/actions/deleteAction.ts +++ b/apps/files/src/actions/deleteAction.ts @@ -27,10 +27,11 @@ import TrashCan from '@mdi/svg/svg/trash-can.svg?raw' import { registerFileAction, FileAction } from '../services/FileAction.ts' import logger from '../logger.js' +import type { Navigation } from '../services/Navigation.ts' registerFileAction(new FileAction({ id: 'delete', - displayName(nodes: Node[], view) { + displayName(nodes: Node[], view: Navigation) { return view.id === 'trashbin' ? t('files_trashbin', 'Delete permanently') : t('files', 'Delete') @@ -57,8 +58,8 @@ registerFileAction(new FileAction({ return false } }, - async execBatch(nodes: Node[], view) { - return Promise.all(nodes.map(node => this.exec(node, view))) + async execBatch(nodes: Node[], view: Navigation, dir: string) { + return Promise.all(nodes.map(node => this.exec(node, view, dir))) }, order: 100, diff --git a/apps/files/src/components/FileEntry.vue b/apps/files/src/components/FileEntry.vue index 215a8fdbbc7..d4258f29861 100644 --- a/apps/files/src/components/FileEntry.vue +++ b/apps/files/src/components/FileEntry.vue @@ -503,7 +503,7 @@ export default Vue.extend({ this.loading = action.id Vue.set(this.source, '_loading', true) - const success = await action.exec(this.source, this.currentView) + const success = await action.exec(this.source, this.currentView, this.dir) // If the action returns null, we stay silent if (success === null) { @@ -529,7 +529,7 @@ export default Vue.extend({ event.preventDefault() event.stopPropagation() // Execute the first default action if any - this.enabledDefaultActions[0].exec(this.source, this.currentView) + this.enabledDefaultActions[0].exec(this.source, this.currentView, this.dir) } }, diff --git a/apps/files/src/components/FilesListHeaderActions.vue b/apps/files/src/components/FilesListHeaderActions.vue index a53a1d041bf..f8c60a5cd1b 100644 --- a/apps/files/src/components/FilesListHeaderActions.vue +++ b/apps/files/src/components/FilesListHeaderActions.vue @@ -103,6 +103,10 @@ export default Vue.extend({ }, computed: { + dir() { + // Remove any trailing slash but leave root slash + return (this.$route?.query?.dir || '/').replace(/^(.+)\/$/, '$1') + }, enabledActions() { return actions .filter(action => action.execBatch) @@ -165,7 +169,7 @@ export default Vue.extend({ }) // Dispatch action execution - const results = await action.execBatch(this.nodes, this.currentView) + const results = await action.execBatch(this.nodes, this.currentView, this.dir) // Check if all actions returned null if (!results.some(result => result !== null)) { diff --git a/apps/files/src/services/FileAction.ts b/apps/files/src/services/FileAction.ts index 94fc7e8ce5f..70d6405c804 100644 --- a/apps/files/src/services/FileAction.ts +++ b/apps/files/src/services/FileAction.ts @@ -22,6 +22,7 @@ import type { Node } from '@nextcloud/files' import logger from '../logger' +import type { Navigation } from './Navigation' declare global { interface Window { @@ -48,14 +49,14 @@ interface FileActionData { * @returns true if the action was executed, false otherwise * @throws Error if the action failed */ - exec: (file: Node, view) => Promise<boolean|null>, + exec: (file: Node, view: Navigation, dir: string) => Promise<boolean|null>, /** * Function executed on multiple files action * @returns true if the action was executed successfully, * false otherwise and null if the action is silent/undefined. * @throws Error if the action failed */ - execBatch?: (files: Node[], view) => Promise<(boolean|null)[]> + execBatch?: (files: Node[], view: Navigation, dir: string) => Promise<(boolean|null)[]> /** This action order in the list */ order?: number, /** Make this action the default */ |