mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
fix(files): Only execute default action if there is an action to perform
Some files do not have a default action (can not be viewed and only downloaded). If the `openfile` query is set on them the `handleOpenFile` will throw an error. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
This commit is contained in:
parent
86635c3965
commit
b84820387c
3 changed files with 14 additions and 10 deletions
|
|
@ -274,14 +274,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) {
|
||||
|
|
|
|||
4
dist/files-main.js
vendored
4
dist/files-main.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-main.js.map
vendored
2
dist/files-main.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue