Commit 961bf8ae authored by Angelina Filippova's avatar Angelina Filippova

Fix processing values with type map

parent 529a8469
......@@ -107,7 +107,7 @@ export const valueHasTuples = (key, value) => {
valueIsArrayOfNonObjects
}
export const wrapUpdatedSettings = (group, settings) => {
export const wrapUpdatedSettings = (group, settings, currentState) => {
return Object.keys(settings).map((key) => {
if (settings[key]._value) {
const value = settings[key]._value[0] === 'atom' && settings[key]._value[1].length > 1
......@@ -115,11 +115,11 @@ export const wrapUpdatedSettings = (group, settings) => {
: settings[key]._value[1]
return { group, key, value }
}
return { group, key, value: wrapValues(settings[key]) }
return { group, key, value: wrapValues(settings[key], currentState[group][key]) }
})
}
const wrapValues = settings => {
const wrapValues = (settings, currentState) => {
return Object.keys(settings).map(setting => {
const [type, value] = Array.isArray(settings[setting]) ? settings[setting] : ['', settings[setting]]
if (type === 'keyword' || type.includes('keyword')) {
......@@ -129,11 +129,11 @@ const wrapValues = settings => {
} else if (type.includes('tuple') && Array.isArray(value)) {
return { 'tuple': [setting, { 'tuple': value }] }
} else if (type === 'map') {
const objectValue = Object.keys(value).reduce((acc, key) => {
const mapValue = Object.keys(value).reduce((acc, key) => {
acc[key] = value[key][1]
return acc
}, {})
return { 'tuple': [setting, objectValue] }
return { 'tuple': [setting, { ...currentState[setting], ...mapValue }] }
} else if (setting === ':ip') {
const ip = value.split('.').map(s => parseInt(s, 10))
return { 'tuple': [setting, { 'tuple': ip }] }
......
......@@ -86,7 +86,7 @@ const settings = {
}, {})
const configs = Object.keys(updatedData).reduce((acc, group) => {
return [...acc, ...wrapUpdatedSettings(group, updatedData[group])]
return [...acc, ...wrapUpdatedSettings(group, updatedData[group], state.settings)]
}, [])
const response = await updateSettings(configs, getters.authHost, getters.token)
commit('SET_SETTINGS', response.data.configs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment