Skip to content

Commit

Permalink
Merge pull request #45586 from nextcloud/fix/files-default-action
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Jun 4, 2024
2 parents c1661b6 + 923e1b8 commit 7ac1e2f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
18 changes: 11 additions & 7 deletions apps/files/src/components/FilesListVirtual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,18 @@ export default defineComponent({
logger.debug('Opening file ' + node.path, { node })
this.openFileId = fileId
getFileActions()
.filter(action => !action.enabled || action.enabled([node], this.currentView))
const defaultAction = getFileActions()
// Get only default actions (visible and hidden)
.filter(action => !!action?.default)
// Find actions that are either always enabled or enabled for the current node
.filter((action) => !action.enabled || action.enabled([node], this.currentView))
// Sort enabled default actions by order
.sort((a, b) => (a.order || 0) - (b.order || 0))
.filter(action => !!action?.default)[0].exec(node, this.currentView, this.currentFolder.path)
},
getFileId(node) {
return node.fileid
// Get the first one
.at(0)
// Some file types do not have a default action (e.g. they can only be downloaded)
// So if there is an enabled default action, so execute it
defaultAction?.exec(node, this.currentView, this.currentFolder.path)
},
onDragOver(event: DragEvent) {
Expand Down
6 changes: 3 additions & 3 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

0 comments on commit 7ac1e2f

Please sign in to comment.