diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index 120c3874..d4dcbc1f 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -31,9 +31,14 @@ export const parseNonTuples = (key, value) => { if (key === ':backends') { const index = value.findIndex(el => typeof el === 'object' && el.tuple.includes(':ex_syslogger')) const updated = value.map((el, i) => i === index ? ':ex_syslogger' : el) - return { value: updated } + return updated } - return { value } + if (key === ':args') { + const index = value.findIndex(el => typeof el === 'object' && el.tuple.includes('implode')) + const updated = value.map((el, i) => i === index ? 'implode' : el) + return updated + } + return value } // REFACTOR export const parseTuples = (tuples, key) => { @@ -64,9 +69,11 @@ export const parseTuples = (tuples, key) => { accum[item.tuple[0]] = item.tuple[1] === ':disabled' ? [item.tuple[1]] : item.tuple[1].tuple } else if (item.tuple[0] === ':proxy_url') { accum[item.tuple[0]] = parseProxyUrl(item.tuple[1]) - } else if ((item.tuple[0] === ':sslopts' && item.tuple[1].length === 0) || // should be removed + } else if ((item.tuple[0] === ':sslopts' && item.tuple[1].length === 0) || (item.tuple[0] === ':tlsopts' && item.tuple[1].length === 0)) { accum[item.tuple[0]] = {} + } else if (item.tuple[0] === ':args') { + accum[item.tuple[0]] = parseNonTuples(item.tuple[0], item.tuple[1]) } else if (Array.isArray(item.tuple[1]) && (typeof item.tuple[1][0] === 'object' && !Array.isArray(item.tuple[1][0])) && item.tuple[1][0]['tuple']) { accum[item.tuple[0]] = parseTuples(item.tuple[1], item.tuple[0]) @@ -193,7 +200,7 @@ export const wrapUpdatedSettings = (group, settings, currentState) => { const wrapValues = (settings, currentState) => { return Object.keys(settings).map(setting => { - const [type, value] = Array.isArray(settings[setting]) ? settings[setting] : ['', settings[setting]] + const [type, value] = settings[setting] if (type === 'keyword' || type.includes('keyword') || setting === ':replace') { return { 'tuple': [setting, wrapValues(value, currentState)] } } else if (type === 'atom' && value.length > 0) { @@ -218,6 +225,13 @@ const wrapValues = (settings, currentState) => { return { 'tuple': [setting, { 'tuple': ip }] } } else if (setting === ':ssl_options') { return { 'tuple': [setting, wrapValues(value, currentState)] } + } else if (setting === ':args') { + const index = value.findIndex(el => el === 'implode') + const updatedArray = value.slice() + if (index !== -1) { + updatedArray[index] = { 'tuple': ['implode', '1'] } + } + return { 'tuple': [setting, updatedArray] } } else { return { 'tuple': [setting, value] } } diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index f7d1df79..406bd46d 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -36,7 +36,7 @@ const settings = { SET_SETTINGS: (state, data) => { const newSettings = data.reduce((acc, { group, key, value }) => { const parsedValue = valueHasTuples(key, value) - ? parseNonTuples(key, value) + ? { value: parseNonTuples(key, value) } : parseTuples(value, key) acc[group][key] = { ...acc[group][key], ...parsedValue } return acc diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index c707b859..90d66e46 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -75,7 +75,7 @@ - + @@ -87,7 +87,7 @@ import AceEditor from 'vue2-ace-editor' import 'brace/mode/elixir' import 'default-passive-events' -import { AutoLinkerInput, BackendsLoggerInput, EditableKeywordInput, IconsInput, MascotsInput, ProxyUrlInput, PruneInput, RateLimitInput, SslOptionsInput } from './inputComponents' +import { AutoLinkerInput, EditableKeywordInput, IconsInput, MascotsInput, MultipleSelect, ProxyUrlInput, PruneInput, RateLimitInput, SslOptionsInput } from './inputComponents' import { processNested } from '@/store/modules/normalizers' export default { @@ -95,10 +95,10 @@ export default { components: { editor: AceEditor, AutoLinkerInput, - BackendsLoggerInput, EditableKeywordInput, IconsInput, MascotsInput, + MultipleSelect, ProxyUrlInput, PruneInput, RateLimitInput, @@ -216,7 +216,7 @@ export default { { group, key: parentKey, input: setting.key, value: valueForState }) }, renderMultipleSelect(type) { - return Array.isArray(type) && this.setting.key !== ':backends' && ( + return Array.isArray(type) && this.setting.key !== ':backends' && this.setting.key !== ':args' && ( type.includes('module') || (type.includes('list') && type.includes('string')) || (type.includes('list') && type.includes('atom')) || diff --git a/src/views/settings/components/inputComponents/BackendsLoggerInput.vue b/src/views/settings/components/inputComponents/BackendsLoggerInput.vue deleted file mode 100644 index da6af188..00000000 --- a/src/views/settings/components/inputComponents/BackendsLoggerInput.vue +++ /dev/null @@ -1,49 +0,0 @@ - - - - - diff --git a/src/views/settings/components/inputComponents/MultipleSelect.vue b/src/views/settings/components/inputComponents/MultipleSelect.vue new file mode 100644 index 00000000..bcb766fa --- /dev/null +++ b/src/views/settings/components/inputComponents/MultipleSelect.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/src/views/settings/components/inputComponents/index.js b/src/views/settings/components/inputComponents/index.js index 601f47d0..faf7c1f8 100644 --- a/src/views/settings/components/inputComponents/index.js +++ b/src/views/settings/components/inputComponents/index.js @@ -1,8 +1,8 @@ export { default as AutoLinkerInput } from './AutoLinkerInput' -export { default as BackendsLoggerInput } from './BackendsLoggerInput' -export { default as MascotsInput } from './MascotsInput' export { default as EditableKeywordInput } from './EditableKeywordInput' export { default as IconsInput } from './IconsInput' +export { default as MascotsInput } from './MascotsInput' +export { default as MultipleSelect } from './MultipleSelect' export { default as ProxyUrlInput } from './ProxyUrlInput' export { default as PruneInput } from './PruneInput' export { default as RateLimitInput } from './RateLimitInput' diff --git a/src/views/settings/index.vue b/src/views/settings/index.vue index 91c73493..5be2da66 100644 --- a/src/views/settings/index.vue +++ b/src/views/settings/index.vue @@ -65,14 +65,12 @@ - - - - + + +