Skip to content

Commit

Permalink
Use handler of the file editor
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasHirt committed Nov 16, 2020
1 parent 2976b58 commit 6e70c4c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 6 additions & 2 deletions apps/files/src/components/FilesAppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -524,16 +524,20 @@ 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
if (this.newFileAction) {
// not cool - needs refactoring
this.$nextTick(() => {
this.openFile({
filePath: filePath
})
this.openFileAction(this.newFileAction, filePath)
this.openFileAction(this.newFileAction, filePath, fileId)
})
}
Expand Down
10 changes: 7 additions & 3 deletions apps/files/src/fileactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
'flatFileList',
'currentFolder'
]),
...mapGetters(['capabilities', 'fileSideBars', 'isAuthenticated', 'getToken']),
...mapGetters(['capabilities', 'fileSideBars', 'isAuthenticated', 'getToken', 'configuration']),
...mapState(['apps']),

// Files lists
Expand All @@ -38,7 +38,7 @@ export default {
return `Open in ${this.apps.meta[editor.app].name}`
},
icon: this.apps.meta[editor.app].icon,
handler: item => this.openFileAction(editor, item.path),
handler: item => this.openFileAction(editor, item.path, item.id),
isEnabled: item => item.extension === editor.extension,
canBeDefault: true
}
Expand Down Expand Up @@ -342,7 +342,11 @@ export default {
.then(blob => this.openBlobInNewTab(blob, mimetype))
},

openFileAction(action, filePath) {
openFileAction(action, filePath, fileId) {
if (action.handler) {
return action.handler(this.configuration, filePath, fileId)
}

// TODO: Refactor in the store
this.openFile({
filePath: filePath
Expand Down
3 changes: 2 additions & 1 deletion src/store/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,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

0 comments on commit 6e70c4c

Please sign in to comment.