Skip to content

Commit dfb2745

Browse files
committed
feat(files): Add support for file list actions
Signed-off-by: Christopher Ng <[email protected]>
1 parent 690aeb0 commit dfb2745

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

apps/files/src/views/FilesList.vue

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@
4545
multiple
4646
@failed="onUploadFail"
4747
@uploaded="onUpload" />
48+
49+
<NcActions :inline="1" force-name>
50+
<NcActionButton v-for="action in enabledFileListActions"
51+
:key="action.id"
52+
close-after-click
53+
@click="() => action.exec(currentView, dirContents, { folder: currentFolder })">
54+
<template #icon>
55+
<NcIconSvgWrapper :svg="action.iconSvgInline(currentView)" />
56+
</template>
57+
{{ action.displayName(currentView) }}
58+
</NcActionButton>
59+
</NcActions>
4860
</template>
4961
</BreadCrumbs>
5062

@@ -138,7 +150,7 @@ import type { UserConfig } from '../types.ts'
138150
139151
import { getCapabilities } from '@nextcloud/capabilities'
140152
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
141-
import { Folder, Node, Permission, sortNodes } from '@nextcloud/files'
153+
import { Folder, Node, Permission, sortNodes, getFileListActions } from '@nextcloud/files'
142154
import { translate as t } from '@nextcloud/l10n'
143155
import { join, dirname, normalize } from 'path'
144156
import { showError, showWarning } from '@nextcloud/dialogs'
@@ -152,6 +164,8 @@ import IconReload from 'vue-material-design-icons/Reload.vue'
152164
import LinkIcon from 'vue-material-design-icons/Link.vue'
153165
import ListViewIcon from 'vue-material-design-icons/FormatListBulletedSquare.vue'
154166
import NcAppContent from '@nextcloud/vue/dist/Components/NcAppContent.js'
167+
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
168+
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
155169
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
156170
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
157171
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
@@ -190,6 +204,8 @@ export default defineComponent({
190204
LinkIcon,
191205
ListViewIcon,
192206
NcAppContent,
207+
NcActions,
208+
NcActionButton,
193209
NcButton,
194210
NcEmptyContent,
195211
NcIconSvgWrapper,
@@ -430,6 +446,19 @@ export default defineComponent({
430446
showCustomEmptyView() {
431447
return !this.loading && this.isEmptyDir && this.currentView?.emptyView !== undefined
432448
},
449+
450+
enabledFileListActions() {
451+
const actions = getFileListActions()
452+
const enabledActions = actions
453+
.filter(action => {
454+
if (action.enabled === undefined) {
455+
return true
456+
}
457+
return action.enabled(this.currentView, this.dirContents, { folder: this.currentFolder })
458+
})
459+
.toSorted((a, b) => a.order - b.order)
460+
return enabledActions
461+
},
433462
},
434463
435464
watch: {

0 commit comments

Comments
 (0)