diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-05-30 18:44:02 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-06-04 14:41:08 +0200 |
commit | d33cfdd14bd4920c6fa8769afcae7b02b27380e3 (patch) | |
tree | 0ae0db9b65a89b4c6ca48c8eb8110e4af910c729 /apps | |
parent | c1661b60238554fcac93160bffcb478e355b4c2c (diff) | |
download | nextcloud-server-d33cfdd14bd4920c6fa8769afcae7b02b27380e3.tar.gz nextcloud-server-d33cfdd14bd4920c6fa8769afcae7b02b27380e3.zip |
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>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/src/components/FilesListVirtual.vue | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/apps/files/src/components/FilesListVirtual.vue b/apps/files/src/components/FilesListVirtual.vue index 17831a97a3f..12f4642f227 100644 --- a/apps/files/src/components/FilesListVirtual.vue +++ b/apps/files/src/components/FilesListVirtual.vue @@ -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) { |