diff --git a/apps/files/src/mixins/fileActions.js b/apps/files/src/mixins/fileActions.js index be36240ca4d..5b058a928ef 100644 --- a/apps/files/src/mixins/fileActions.js +++ b/apps/files/src/mixins/fileActions.js @@ -68,7 +68,12 @@ export default { $_fileActions_openEditor(editor, filePath, fileId) { if (editor.handler) { - return editor.handler(this.configuration, filePath, fileId) + return editor.handler({ + config: this.configuration, + extensionConfig: editor.config, + filePath, + fileId + }) } // TODO: Refactor in the store diff --git a/changelog/unreleased/editor-handler b/changelog/unreleased/editor-handler new file mode 100644 index 00000000000..0396f772d6e --- /dev/null +++ b/changelog/unreleased/editor-handler @@ -0,0 +1,5 @@ +Change: Load extensions config + +We've started loading the config of extensions which can now be defined as an object in the `external_apps` in the config.json. + +https://github.com/owncloud/phoenix/pull/4380 diff --git a/src/phoenix.js b/src/phoenix.js index 0871f12ee6d..3b5592c6ed8 100644 --- a/src/phoenix.js +++ b/src/phoenix.js @@ -149,9 +149,6 @@ async function loadApps () { } store.dispatch('registerApp', app.appInfo) - if (config.external_apps) { - store.dispatch('loadExternalAppConfig', { app: app.appInfo, config }) - } } router.addRoutes(routes.flat()) sync(store, router) diff --git a/src/store/apps.js b/src/store/apps.js index 83b9118fde6..758b9e5bd8c 100644 --- a/src/store/apps.js +++ b/src/store/apps.js @@ -1,5 +1,3 @@ -const merge = require('deepmerge') - const state = { file: { path: '', @@ -42,34 +40,6 @@ const actions = { }, addFileAction({ commit }, action) { commit('ADD_FILE_ACTION', action) - }, - - /** - * Load config for external app - * @param {Object} app AppInfo containing information about app and local config - * @param {Object} config Config from config.json which can overwrite local config from AppInfo - */ - loadExternalAppConfig({ dispatch }, { app, config }) { - config.external_apps.forEach(extension => { - // Check if app is loaded from external server - // Extension id = id from external apps array - // App id = id specified in AppInfo - if (extension.id === app.id && (app.config || extension.config)) { - if (app.config && extension.config) { - dispatch(`${app.name}/loadConfig`, merge(app.config, extension.config), { root: true }) - return - } - - if (app.config) { - dispatch(`${app.name}/loadConfig`, app.config, { root: true }) - return - } - - if (extension.config) { - dispatch(`${app.name}/loadConfig`, extension.config, { root: true }) - } - } - }) } } @@ -125,6 +95,18 @@ const mutations = { }, FETCH_FILE(state, filePath) { state.file.path = filePath + }, + + LOAD_EXTENSION_CONFIG(state, { id, config }) { + const editors = state.fileEditors + + for (const editor of editors) { + if (editor.app === id) { + editor.config = config + } + } + + state.fileEditors = editors } } diff --git a/src/store/config.js b/src/store/config.js index 167c6870603..5ac8f48e1d9 100644 --- a/src/store/config.js +++ b/src/store/config.js @@ -41,8 +41,20 @@ const state = { } const actions = { - loadConfig(context, config) { - context.commit('LOAD_CONFIG', config) + loadConfig({ commit }, config) { + commit('LOAD_CONFIG', config) + + if (config.external_apps) { + config.external_apps.forEach(externalApp => { + if (externalApp.config !== undefined) { + commit( + 'LOAD_EXTENSION_CONFIG', + { id: externalApp.id, config: externalApp.config }, + { root: true } + ) + } + }) + } }, loadTheme(context, { theme, name }) { theme.name = name