diff --git a/changelog/unreleased/enhancement-editor-mode b/changelog/unreleased/enhancement-editor-mode new file mode 100644 index 00000000000..365cd853ed4 --- /dev/null +++ b/changelog/unreleased/enhancement-editor-mode @@ -0,0 +1,8 @@ +Enhancement: File editor mode + +We've added a parameter called `mode` to the different ways of opening a file editor. +The mode can be `edit` or `create` and reflects whether the file editor was opened +in an editing mode or in a creation mode. + +https://github.com/owncloud/web/issues/5226 +https://github.com/owncloud/web/pull/5256 diff --git a/packages/web-app-files/src/components/AppBar.vue b/packages/web-app-files/src/components/AppBar.vue index 34e799e3aad..b3a8c0b5b18 100644 --- a/packages/web-app-files/src/components/AppBar.vue +++ b/packages/web-app-files/src/components/AppBar.vue @@ -108,7 +108,7 @@ import pathUtil from 'path' import isEmpty from 'lodash-es/isEmpty' import Mixins from '../mixins' -import MixinFileActions from '../mixins/fileActions' +import MixinFileActions, { EDITOR_MODE_CREATE } from '../mixins/fileActions' import MixinRoutes from '../mixins/routes' import MixinScrollToResource from '../mixins/filesListScrolling' import { buildResource } from '../helpers/resources' @@ -419,7 +419,7 @@ export default { if (this.newFileAction) { const fileId = resource.fileInfo['{http://owncloud.org/ns}fileid'] - this.$_fileActions_openEditor(this.newFileAction, path, fileId) + this.$_fileActions_openEditor(this.newFileAction, path, fileId, EDITOR_MODE_CREATE) this.hideModal() return diff --git a/packages/web-app-files/src/mixins/fileActions.js b/packages/web-app-files/src/mixins/fileActions.js index 8a5d7617b18..3927e51d0cf 100644 --- a/packages/web-app-files/src/mixins/fileActions.js +++ b/packages/web-app-files/src/mixins/fileActions.js @@ -24,6 +24,9 @@ const actionsMixins = [ 'delete' ] +export const EDITOR_MODE_EDIT = 'edit' +export const EDITOR_MODE_CREATE = 'create' + export default { mixins: [Copy, Delete, Download, Favorite, Fetch, Move, Navigate, Rename, Restore], computed: { @@ -53,7 +56,8 @@ export default { ) }, icon: this.apps.meta[editor.app].icon, - handler: item => this.$_fileActions_openEditor(editor, item.path, item.id), + handler: item => + this.$_fileActions_openEditor(editor, item.path, item.id, EDITOR_MODE_EDIT), isEnabled: ({ resource }) => { if (editor.routes?.length > 0 && !checkRoute(editor.routes, this.$route.name)) { return false @@ -74,25 +78,26 @@ export default { methods: { ...mapActions(['openFile']), - $_fileActions_openEditor(editor, filePath, fileId) { + $_fileActions_openEditor(editor, filePath, fileId, mode) { if (editor.handler) { return editor.handler({ config: this.configuration, extensionConfig: editor.config, filePath, - fileId + fileId, + mode }) } // TODO: Refactor in the store this.openFile({ - filePath: filePath + filePath }) if (editor.newTab) { const path = this.$router.resolve({ name: editor.routeName, - params: { filePath: filePath } + params: { filePath, fileId, mode } }).href const target = `${editor.routeName}-${filePath}` const win = window.open(path, target) @@ -103,15 +108,14 @@ export default { return } - const routeName = editor.routeName || editor.app - const params = { - filePath, - contextRouteName: this.$route.name - } - this.$router.push({ - name: routeName, - params + name: editor.routeName || editor.app, + params: { + filePath, + fileId, + mode, + contextRouteName: this.$route.name + } }) },