From 39abd05b3fc70339e8db2d61118efbf2a7d65de3 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sun, 29 Dec 2019 00:47:50 +0300 Subject: [PATCH] Fix parsing and wrapping mime_types setting --- src/store/modules/normalizers.js | 3 ++- src/views/settings/components/Inputs.vue | 19 ++++++++++++++++--- src/views/settings/components/Other.vue | 4 ++-- src/views/settings/index.vue | 13 ++++++------- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index 801e95a0..1d3a3b23 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -13,6 +13,8 @@ const getValueWithoutKey = (key, [type, value]) => { updatedArray[index] = { 'tuple': ['ExSyslogger', ':ex_syslogger'] } } return updatedArray + } else if (key === ':types') { + return Object.keys(value).reduce((acc, key) => { return { ...acc, [key]: value[key][1] } }, {}) } return value } @@ -116,7 +118,6 @@ const parseProxyUrl = value => { export const partialUpdate = (group, key) => { if ((group === ':pleroma' && key === 'Oban') || - (group === ':mime' && key === ':types') || (group === ':auto_linker' && key === ':opts')) { return false } diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index 05dc0ad6..751ec913 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -140,7 +140,7 @@ export default { } }, inputValue() { - if ([':esshd', ':cors_plug', ':quack', ':http_signatures'].includes(this.settingGroup.group) && + if ([':esshd', ':cors_plug', ':quack', ':http_signatures', ':tesla'].includes(this.settingGroup.group) && this.data[this.setting.key]) { return this.setting.type === 'atom' && this.data[this.setting.key].value[0] === ':' ? this.data[this.setting.key].value.substr(1) @@ -149,6 +149,8 @@ export default { this.setting.key === 'Pleroma.Web.Auth.Authenticator' || this.setting.key === ':admin_token') { return this.data.value + } else if (this.settingGroup.group === ':mime' && this.settingParent.key === ':types') { + return this.data.value[this.setting.key] } else if (this.setting.type === 'atom') { return this.data[this.setting.key] && this.data[this.setting.key][0] === ':' ? this.data[this.setting.key].substr(1) : this.data[this.setting.key] } else { @@ -177,12 +179,23 @@ export default { }, processNestedData(value, group, key, parentInput, parentType, childInput, childType) { const valueExists = value => value[group] && value[group][key] && value[group][key][parentInput] - const updatedValueForState = valueExists(this.settings) + let updatedValueForState = valueExists(this.settings) ? { ...this.settings[group][key][parentInput], ...{ [childInput]: value }} : { [childInput]: value } - const updatedValue = valueExists(this.updatedSettings) + let updatedValue = valueExists(this.updatedSettings) ? { ...this.updatedSettings[group][key][parentInput][1], ...{ [childInput]: [childType, value] }} : { [childInput]: [childType, value] } + + if (group === ':mime' && parentInput === ':types') { + updatedValueForState = { ...this.settings[group][parentInput].value, ...updatedValueForState } + updatedValue = { + ...Object.keys(this.settings[group][parentInput].value) + .reduce((acc, el) => { + return { ...acc, [el]: [['list', 'string'], this.settings[group][parentInput].value[el]] } + }, {}), + ...updatedValue + } + } this.$store.dispatch('UpdateSettings', { group, key, input: parentInput, value: updatedValue, type: parentType }) this.$store.dispatch('UpdateState', { group, key, input: parentInput, value: updatedValueForState }) }, diff --git a/src/views/settings/components/Other.vue b/src/views/settings/components/Other.vue index 650e08e2..ed29a863 100644 --- a/src/views/settings/components/Other.vue +++ b/src/views/settings/components/Other.vue @@ -38,13 +38,13 @@ export default { return this.settings.description.find(setting => setting.group === ':mime') }, mimeTypesData() { - return this.settings.settings[':mime'][':types'] + return this.settings.settings[':mime'] }, teslaAdapter() { return this.settings.description.find(setting => setting.group === ':tesla') }, teslaAdapterData() { - return this.settings.settings[':tesla'][':adapter'] + return this.settings.settings[':tesla'] } }, methods: { diff --git a/src/views/settings/index.vue b/src/views/settings/index.vue index 90976b3d..14f34e40 100644 --- a/src/views/settings/index.vue +++ b/src/views/settings/index.vue @@ -56,21 +56,20 @@ -