From 1c4c93d497809967030f5100fa97ce33d41faa55 Mon Sep 17 00:00:00 2001 From: elizavetaRa Date: Thu, 19 Jan 2023 22:51:19 +0100 Subject: [PATCH] Possibility to open apps in the same tab Required to auto-opening an app on single file view. Since this functionality looks like is available upstream, this commit might not be needed any longer. --- packages/web-app-files/src/mixins/fileActions.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/web-app-files/src/mixins/fileActions.ts b/packages/web-app-files/src/mixins/fileActions.ts index 7de5dc57d9c..dcc95900fb6 100644 --- a/packages/web-app-files/src/mixins/fileActions.ts +++ b/packages/web-app-files/src/mixins/fileActions.ts @@ -43,6 +43,7 @@ export const EDITOR_MODE_CREATE = 'create' export type FileActionOptions = { space: SpaceResource resources: Resource[] + sameTab?: Boolean } export default { @@ -99,7 +100,8 @@ export default { options.resources[0].webDavPath, options.resources[0].fileId, EDITOR_MODE_EDIT, - options.space.shareId + options.space.shareId, + options.sameTab ), isEnabled: ({ resources }) => { if (resources.length !== 1) { @@ -147,7 +149,7 @@ export default { }, methods: { - $_fileActions_openEditor(editor, driveAliasAndItem: string, filePath, fileId, mode, shareId) { + $_fileActions_openEditor(editor, driveAliasAndItem: string, filePath, fileId, mode, shareId, sameTab) { if (editor.handler) { return editor.handler({ config: this.configuration, @@ -169,7 +171,7 @@ export default { shareId ) - if (this.configuration.options.openAppsInTab) { + if (this.configuration.options.openAppsInTab && !sameTab) { const path = this.$router.resolve(routeOpts).href const target = `${editor.routeName}-${filePath}` const win = window.open(path, target) @@ -292,14 +294,15 @@ export default { driveAliasAndItem, webDavPath, fileId, - options.space.shareId + options.space.shareId, + options.sameTab ), label: () => this.$gettextInterpolate(label, { appName: app.name }) } }) }, - $_fileActions_openExternalApp(app, driveAliasAndItem: string, filePath, fileId, shareId) { + $_fileActions_openExternalApp(app, driveAliasAndItem: string, filePath, fileId, shareId, sameTab=false) { const routeOpts = this.$_fileActions__routeOpts( { routeName: 'external-apps' @@ -318,7 +321,7 @@ export default { } // TODO: Let users configure whether to open in same/new tab (`_blank` vs `_self`) - window.open(this.$router.resolve(routeOpts).href, '_blank') + window.open(this.$router.resolve(routeOpts).href, sameTab ? '_self' : '_blank') } } }