Skip to content

Commit

Permalink
feat(files): Add support for file list actions
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal committed Nov 8, 2024
1 parent 3eadae3 commit d1fb691
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion apps/files/src/views/FilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit d1fb691

Please sign in to comment.