@@ -7,25 +7,34 @@ import type { PropType } from 'vue'
77import type { FileSource } from '../types.ts'
88
99import { openConflictPicker } from '@nextcloud/dialogs'
10- import { FileType , Folder , getFileActions , File as NcFile , Node , NodeStatus , Permission } from '@nextcloud/files'
10+ import { FileType , Folder , getFileActions , File as NcFile , Node , NodeStatus , Permission , type View } from '@nextcloud/files'
1111import { t } from '@nextcloud/l10n'
1212import { extname } from '@nextcloud/paths'
1313import { isPublicShare } from '@nextcloud/sharing/public'
1414import { generateUrl } from '@nextcloud/router'
1515import { getConflicts , getUploader } from '@nextcloud/upload'
1616import { vOnClickOutside } from '@vueuse/components'
1717import { relative } from 'path'
18+ import { storeToRefs } from 'pinia'
1819import Vue , { computed , defineComponent } from 'vue'
1920
2021import { action as sidebarAction } from '../actions/sidebarAction.ts'
2122import { onDropInternalFiles } from '../services/DropService.ts'
23+ import { useActiveStore } from '../store/active.ts'
2224import { getDragAndDropPreview } from '../utils/dragUtils.ts'
2325import { hashCode } from '../utils/hashUtils.ts'
2426import { isDownloadable } from '../utils/permissions.ts'
2527import logger from '../logger.ts'
2628
2729Vue . directive ( 'onClickOutside' , vOnClickOutside )
2830
31+ type FileActionContext = {
32+ nodes : Node [ ]
33+ view : View
34+ folder : Folder
35+ contents : Node [ ]
36+ }
37+
2938const actions = getFileActions ( )
3039
3140export default defineComponent ( {
@@ -59,6 +68,15 @@ export default defineComponent({
5968 }
6069 } ,
6170
71+ setup ( ) {
72+ const { activeFolder, activeView } = storeToRefs ( useActiveStore ( ) )
73+
74+ return {
75+ activeFolder,
76+ activeView,
77+ }
78+ } ,
79+
6280 data ( ) {
6381 return {
6482 dragover : false ,
@@ -229,6 +247,19 @@ export default defineComponent({
229247 }
230248 } ,
231249
250+ fileActionView ( ) : View {
251+ return this . activeView ?? this . currentView
252+ } ,
253+
254+ fileActionContext ( ) : FileActionContext {
255+ return {
256+ nodes : [ this . source ] ,
257+ view : this . fileActionView ,
258+ folder : this . activeFolder ! ,
259+ contents : this . nodes ,
260+ }
261+ } ,
262+
232263 /**
233264 * Sorted actions that are enabled for this node
234265 */
@@ -246,7 +277,7 @@ export default defineComponent({
246277 // In case something goes wrong, since we don't want to break
247278 // the entire list, we filter out actions that throw an error.
248279 try {
249- return action . enabled ( [ this . source ] , this . currentView )
280+ return ( action . enabled as ( context : FileActionContext ) => boolean ) ( this . fileActionContext )
250281 } catch ( error ) {
251282 logger . error ( 'Error while checking action' , { action, error } )
252283 return false
0 commit comments