Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use handler of the file editor #4324

Merged
merged 1 commit into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions apps/files/src/components/FilesAppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,16 @@ export default {
if (this.publicPage()) {
p = this.$client.publicFiles.putFileContents(filePath, null, this.publicLinkPassword, '')
}
p.then(() => {
p.then(async () => {
const file = await this.$client.files.fileInfo(filePath, this.davProperties)
const fileId = file.fileInfo['{http://owncloud.org/ns}fileid']

this.$_ocFilesFolder_getFolder()
this.fileFolderCreationLoading = false
this.hideModal()

if (this.newFileAction) {
this.$_fileActions_openEditor(this.newFileAction, filePath)
this.$_fileActions_openEditor(this.newFileAction, filePath, fileId)
}
}).catch(error => {
this.fileFolderCreationLoading = false
Expand Down
9 changes: 7 additions & 2 deletions apps/files/src/mixins/fileActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
computed: {
...mapState(['apps']),
...mapGetters('Files', ['highlightedFile', 'currentFolder']),
...mapGetters(['configuration']),

$_fileActions_systemActions() {
const systemActions = []
Expand All @@ -46,7 +47,7 @@ export default {
return `Open in ${this.apps.meta[editor.app].name}`
},
icon: this.apps.meta[editor.app].icon,
handler: item => this.$_fileActions_openEditor(editor, item.path),
handler: item => this.$_fileActions_openEditor(editor, item.path, item.id),
isEnabled: ({ resource }) => {
if (editor.routes && checkRoute(editor.routes, this.$route.name)) {
return false
Expand All @@ -65,7 +66,11 @@ export default {
methods: {
...mapActions(['openFile']),

$_fileActions_openEditor(editor, filePath) {
$_fileActions_openEditor(editor, filePath, fileId) {
if (editor.handler) {
return editor.handler(this.configuration, filePath, fileId)
}

// TODO: Refactor in the store
this.openFile({
filePath: filePath
Expand Down
5 changes: 5 additions & 0 deletions changelog/unreleased/editor-handler
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Use handler of file editors

In case the extension is a file editor which defines a custom handler, we are triggering that handler instead of trying to open any assigned route.

https://github.com/owncloud/phoenix/pull/4324
3 changes: 2 additions & 1 deletion src/store/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ const mutations = {
icon: e.icon,
newTab: e.newTab || false,
routeName: e.routeName,
extension: e.extension
extension: e.extension,
handler: e.handler
}

state.fileEditors.push(editor)
Expand Down