aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2023-11-21 20:10:40 +0100
committernextcloud-command <nextcloud-command@users.noreply.github.com>2023-11-21 19:45:41 +0000
commitc7e2c340a80a69a3ebfde0998746ba3ac4ffa37a (patch)
tree6bfaf1361f704a9db0727eaed0c8110a28e068e2 /apps/files
parent7c6ee7e71a001a437f98521b217824ff551aa281 (diff)
downloadnextcloud-server-c7e2c340a80a69a3ebfde0998746ba3ac4ffa37a.tar.gz
nextcloud-server-c7e2c340a80a69a3ebfde0998746ba3ac4ffa37a.zip
Trigger default action when open file initial state is set
Signed-off-by: Louis Chemineau <louis@chmn.me> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/src/components/FilesListVirtual.vue25
1 files changed, 23 insertions, 2 deletions
diff --git a/apps/files/src/components/FilesListVirtual.vue b/apps/files/src/components/FilesListVirtual.vue
index a196836f3f9..4a6e27bc233 100644
--- a/apps/files/src/components/FilesListVirtual.vue
+++ b/apps/files/src/components/FilesListVirtual.vue
@@ -78,8 +78,9 @@ import type { PropType } from 'vue'
import type { UserConfig } from '../types.ts'
import { Fragment } from 'vue-frag'
-import { getFileListHeaders, Folder, View, Permission } from '@nextcloud/files'
+import { getFileListHeaders, Folder, View, Permission, getFileActions } from '@nextcloud/files'
import { showError } from '@nextcloud/dialogs'
+import { loadState } from '@nextcloud/initial-state'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
import Vue from 'vue'
@@ -217,6 +218,8 @@ export default Vue.extend({
this.scrollToFile(this.fileId)
this.openSidebarForFile(this.fileId)
+ this.handleOpenFile()
+
},
methods: {
@@ -234,7 +237,7 @@ export default Vue.extend({
}
},
- scrollToFile(fileId: number, warn = true) {
+ scrollToFile(fileId: number|null, warn = true) {
if (fileId) {
const index = this.nodes.findIndex(node => node.fileid === fileId)
if (warn && index === -1 && fileId !== this.currentFolder.fileid) {
@@ -244,6 +247,24 @@ export default Vue.extend({
}
},
+ handleOpenFile() {
+ const openFileInfo = loadState('files', 'openFileInfo', {}) as ({ id?: number })
+ if (openFileInfo === undefined) {
+ return
+ }
+
+ const node = this.nodes.find(n => n.fileid === openFileInfo.id) as NcNode
+ if (node === undefined) {
+ return
+ }
+
+ logger.debug('Opening file ' + node.path, { node })
+ getFileActions()
+ .filter(action => !action.enabled || action.enabled([node], this.currentView))
+ .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
},