From 8e46ca887127cecd697cc4810a55c445d3f3cdd2 Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Wed, 22 Jul 2020 06:49:54 +0200 Subject: [PATCH 1/4] replace map with forEach since result is ignored anyway --- src/phoenix.js | 2 +- src/store/apps.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/phoenix.js b/src/phoenix.js index 85ecfd02deb..9d8db15fbe4 100644 --- a/src/phoenix.js +++ b/src/phoenix.js @@ -247,7 +247,7 @@ function requireError (err) { // Loads apps from external servers if (config.external_apps) { - config.external_apps.map(app => apps.push(app.path)) + config.external_apps.forEach(app => apps.push(app.path)) } // provide global config object diff --git a/src/store/apps.js b/src/store/apps.js index 275052792a9..b5697f2fe47 100644 --- a/src/store/apps.js +++ b/src/store/apps.js @@ -50,7 +50,7 @@ const actions = { * @param {Object} config Config from config.json which can overwrite local config from AppInfo */ loadExternalAppConfig({ dispatch }, { app, config }) { - config.external_apps.map(extension => { + 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 @@ -162,15 +162,16 @@ const getters = { if (!ext) { return [] } - ext.map(e => { + ext.forEach(e => { if (e.version === 3) { return e } // enhance App Chooser with App Name as label e.name = state.meta[e.app].name // if no icon for this filetype extension, choose the app icon - if (!e.icon) e.icon = state.meta[e.app].icon - return e + if (!e.icon) { + e.icon = state.meta[e.app].icon + } }) return ext } From 04cebcfe6a457ede75a2ae83acb5c3cd09147119 Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Wed, 22 Jul 2020 06:51:11 +0200 Subject: [PATCH 2/4] adapt to new data model in ocis-settings --- src/Phoenix.vue | 8 ++--- src/store/settings.js | 69 ++++++++++++++++++++----------------------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/src/Phoenix.vue b/src/Phoenix.vue index c1b6ef599a0..5867964922a 100644 --- a/src/Phoenix.vue +++ b/src/Phoenix.vue @@ -98,7 +98,7 @@ export default { 'activeMessages', 'capabilities', 'apps', - 'getSettingsValueByIdentifier', + 'getSettingsValue', 'getNavItems', 'getExtensionsWithNavItems' ]), @@ -190,10 +190,10 @@ export default { }, selectedLanguage() { - return this.getSettingsValueByIdentifier({ + return this.getSettingsValue({ extension: 'ocis-accounts', - bundleKey: 'profile', - settingKey: 'language' + bundle: 'profile', + setting: 'language' }) } }, diff --git a/src/store/settings.js b/src/store/settings.js index 53cee0ae8de..b57e8d0dad7 100644 --- a/src/store/settings.js +++ b/src/store/settings.js @@ -1,3 +1,9 @@ +import keyBy from 'lodash/keyBy' +import assign from 'lodash/assign' +import findKey from 'lodash/findKey' +import isNil from 'lodash/isNil' +import isEqual from 'lodash/isEqual' + const state = { settingsValues: null } @@ -25,15 +31,13 @@ const mutations = { if (settingsValues === null) { state.settingsValues = null } else { - const map = new Map() - Array.from(settingsValues).forEach(value => applySettingsValueToMap(value, map)) - state.settingsValues = map + state.settingsValues = keyBy(settingsValues, 'value.id') } }, SET_SETTINGS_VALUE(state, settingsValue) { - const map = new Map(state.settingsValues) - applySettingsValueToMap(settingsValue, map) - state.settingsValues = map + state.settingsValues = assign({}, state.settingsValues, { + [settingsValue.value.id]: settingsValue + }) } } @@ -41,25 +45,30 @@ const getters = { settingsValuesLoaded: state => { return state.settingsValues !== null }, - hasSettingsValue: (state, getters) => ({ extension, bundleKey, settingKey }) => { - return getters.getSettingsValueByIdentifier({ extension, bundleKey, settingKey }) !== null + // calling this getter requires either having the `settingId` or all three other params + hasSettingsValue: (state, getters) => ({ settingId, extension, bundle, setting }) => { + return getters.getSettingsValue({ settingId, extension, bundle, setting }) !== null }, - getSettingsValueByIdentifier: (state, getters) => ({ extension, bundleKey, settingKey }) => { - if ( - getters.settingsValuesLoaded && - state.settingsValues.has(extension) && - state.settingsValues.get(extension).has(bundleKey) && - state.settingsValues - .get(extension) - .get(bundleKey) - .has(settingKey) - ) { - return state.settingsValues - .get(extension) - .get(bundleKey) - .get(settingKey) + // calling this getter requires either having the `settingId` or all three other params + getSettingsValue: (state, getters) => ({ settingId, extension, bundle, setting }) => { + if (!getters.settingsValuesLoaded) { + return null + } + if (settingId) { + const key = findKey( + state.settingsValues, + settingsValue => settingsValue.value.settingId === settingId + ) + return isNil(key) ? null : state.settingsValues[key].value } - return null + const key = findKey(state.settingsValues, settingsValue => + isEqual(settingsValue.identifier, { + extension, + bundle, + setting + }) + ) + return isNil(key) ? null : state.settingsValues[key].value } } @@ -69,17 +78,3 @@ export default { mutations, getters } - -function applySettingsValueToMap(settingsValue, map) { - if (!map.has(settingsValue.identifier.extension)) { - map.set(settingsValue.identifier.extension, new Map()) - } - if (!map.get(settingsValue.identifier.extension).has(settingsValue.identifier.bundleKey)) { - map.get(settingsValue.identifier.extension).set(settingsValue.identifier.bundleKey, new Map()) - } - map - .get(settingsValue.identifier.extension) - .get(settingsValue.identifier.bundleKey) - .set(settingsValue.identifier.settingKey, settingsValue) - return map -} From 7f2f6fe2fb5e418f042d327752835eb6af0488e2 Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Wed, 19 Aug 2020 12:02:33 +0200 Subject: [PATCH 3/4] Add changelog --- changelog/unreleased/adapt-to-settings-data-model.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 changelog/unreleased/adapt-to-settings-data-model.md diff --git a/changelog/unreleased/adapt-to-settings-data-model.md b/changelog/unreleased/adapt-to-settings-data-model.md new file mode 100644 index 00000000000..d28591888ca --- /dev/null +++ b/changelog/unreleased/adapt-to-settings-data-model.md @@ -0,0 +1,7 @@ +Change: Adapt to new ocis-settings data model + +ocis-settings introduced UUIDs and less verbose endpoint and message type names. This PR adjusts phoenix accordingly. + +https://github.com/owncloud/phoenix/pull/3806 +https://github.com/owncloud/owncloud-sdk/pull/520 +https://github.com/owncloud/ocis-settings/pull/46 From bc449ba8eee2909f5279206d275cbc786d8b3192 Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Wed, 19 Aug 2020 12:08:27 +0200 Subject: [PATCH 4/4] Upgrade owncloud-sdk to 1.0.0-740 --- package.json | 2 +- yarn.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 0de805b907d..721ec8e55a2 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "npm-run-all": "^4.1.5", "oidc-client": "^1.9.1", "owncloud-design-system": "^1.9.0", - "owncloud-sdk": "^1.0.0-728", + "owncloud-sdk": "^1.0.0-740", "p-limit": "^2.2.1", "p-queue": "^6.1.1", "parse-json": "^5.0.0", diff --git a/yarn.lock b/yarn.lock index 20fff8ab7ba..ad6fd85e6f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2980,9 +2980,9 @@ data-uri-to-buffer@1: resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-1.2.0.tgz#77163ea9c20d8641b4707e8f18abdf9a78f34835" integrity sha512-vKQ9DTQPN1FLYiiEEOQ6IBGFqvjCa5rSK3cWMy/Nespm5d/x3dGFT9UBZnkLxCwua/IXBi2TYnwTEpsOvhC4UQ== -"davclient.js@https://github.com/owncloud/davclient.js.git": +"davclient.js@git+https://github.com/owncloud/davclient.js.git": version "0.2.1" - resolved "https://github.com/owncloud/davclient.js.git#bf19f590451b3c0658913568053ec7f300f7dfc1" + resolved "git+https://github.com/owncloud/davclient.js.git#bf19f590451b3c0658913568053ec7f300f7dfc1" de-indent@^1.0.2: version "1.0.2" @@ -6919,10 +6919,10 @@ owncloud-design-system@^1.9.0: webfontloader "^1.6.28" weekstart "^1.0.0" -owncloud-sdk@^1.0.0-728: - version "1.0.0-728" - resolved "https://registry.yarnpkg.com/owncloud-sdk/-/owncloud-sdk-1.0.0-728.tgz#69f35830625e6a213e6e49a5eae5a925a688d4f0" - integrity sha512-XQQIlV15mCUd2k4d0/+QSS0PCHYtGLkvUA/BzO4P7TPhVh/RmnLLxTgL4XSPM2MTQCk0C0geXK3C6bqhdm5QWQ== +owncloud-sdk@^1.0.0-740: + version "1.0.0-740" + resolved "https://registry.yarnpkg.com/owncloud-sdk/-/owncloud-sdk-1.0.0-740.tgz#cfa6306d3ec28f4a4dd288fd9cdc2ed1e45747f0" + integrity sha512-iQ9HW+P6+4O3vhh8oU7UQlGYTFgyKvdA3krEJAwW4+iKnKxNQ9BxIl8JNcv1NxNOILf/PVkJjFDz/+vcHuhmrw== dependencies: axios "^0.19.2" browser-request "^0.3.3"