Commit 222697d0 authored by Angelina Filippova's avatar Angelina Filippova

Fix processing Oban job queue and Oban retries settings

parent ec2f5623
......@@ -12,7 +12,7 @@ export const parseTuples = (tuples, key) => {
accum[item.tuple[0]] = item.tuple[1].reduce((acc, mascot) => {
return [...acc, { [mascot.tuple[0]]: { ...mascot.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}]
}, [])
} else if (item.tuple[0] === ':groups' || item.tuple[0] === ':replace') {
} else if (item.tuple[0] === ':groups' || item.tuple[0] === ':replace' || item.tuple[0] === ':retries') {
accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => {
return [...acc, { [group.tuple[0]]: { value: group.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}]
}, [])
......@@ -91,10 +91,9 @@ const parseProxyUrl = value => {
}
export const partialUpdate = (group, key) => {
if ((group === ':pleroma' && key === ':ecto_repos') ||
(group === ':mime' && key === ':types') ||
(group === ':auto_linker' && key === ':opts') ||
(group === ':swarm' && key === ':node_blacklist')) {
if ((group === ':pleroma' && key === 'Oban') ||
(group === ':mime' && key === ':types') ||
(group === ':auto_linker' && key === ':opts')) {
return false
}
return true
......@@ -129,7 +128,7 @@ 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') || setting === ':replace') {
return { 'tuple': [setting, wrapValues(value)] }
return { 'tuple': [setting, wrapValues(value, currentState)] }
} else if (type === 'atom' && value.length > 0) {
return { 'tuple': [setting, `:${value}`] }
} else if (type.includes('tuple') && Array.isArray(value)) {
......@@ -149,7 +148,7 @@ const wrapValues = (settings, currentState) => {
const ip = value.split('.').map(s => parseInt(s, 10))
return { 'tuple': [setting, { 'tuple': ip }] }
} else if (setting === ':ssl_options') {
return { 'tuple': [setting, wrapValues(value)] }
return { 'tuple': [setting, wrapValues(value, currentState)] }
} else {
return { 'tuple': [setting, value] }
}
......
......@@ -75,7 +75,10 @@ const settings = {
acc[group] = Object.keys(state.updatedSettings[group]).reduce((acc, key) => {
if (!partialUpdate(group, key)) {
const updated = Object.keys(state.settings[group][key]).reduce((acc, settingName) => {
acc[settingName] = ['', state.settings[group][key][settingName]]
const settingType = state.description
.find(element => element.group === group && element.key === key).children
.find(child => child.key === settingName).type
acc[settingName] = [settingType, state.settings[group][key][settingName]]
return acc
}, {})
acc[key] = updated
......@@ -86,7 +89,6 @@ const settings = {
}, {})
return acc
}, {})
const configs = Object.keys(updatedData).reduce((acc, group) => {
return [...acc, ...wrapUpdatedSettings(group, updatedData[group], state.settings)]
}, [])
......
......@@ -58,12 +58,12 @@ export default {
methods: {
addRowToEditableKeyword() {
const updatedValue = [...this.data, { '': { value: '', id: this.generateID() }}]
this.updateSetting(updatedValue, this.settingGroup.group, this.settingGroup.key, this.setting.key)
this.updateSetting(updatedValue, this.settingGroup.group, this.settingGroup.key, this.setting.key, this.setting.type)
},
deleteEditableKeywordRow(element) {
const deletedId = this.getId(element)
const filteredValues = this.data.filter(element => Object.values(element)[0].id !== deletedId)
this.updateSetting(filteredValues, this.settingGroup.group, this.settingGroup.key, this.setting.key)
this.updateSetting(filteredValues, this.settingGroup.group, this.settingGroup.key, this.setting.key, this.setting.type)
},
generateID() {
return `f${(~~(Math.random() * 1e8)).toString(16)}`
......@@ -95,7 +95,7 @@ export default {
updateSetting(value, group, key, input, type) {
const updatedSettings = type !== 'map'
? value.reduce((acc, element) => {
return { ...acc, [Object.keys(element)[0]]: [['list', 'string'], Object.values(element)[0].value] }
return { ...acc, [Object.keys(element)[0]]: [['list'], Object.values(element)[0].value] }
}, {})
: value.reduce((acc, element) => {
return { ...acc, [Object.keys(element)[0]]: Object.values(element)[0].value }
......
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