forked from AkkomaGang/admin-fe
Fix parsing and sending backend logger values as an array of strings and tuples
This commit is contained in:
parent
a518cc492f
commit
51a2b72793
2 changed files with 21 additions and 19 deletions
|
@ -3,9 +3,23 @@ const nonAtomsObjects = ['match_actor', ':match_actor']
|
||||||
const objects = ['digest', 'pleroma_fe', 'masto_fe', 'poll_limits', 'styling']
|
const objects = ['digest', 'pleroma_fe', 'masto_fe', 'poll_limits', 'styling']
|
||||||
const objectParents = ['mascots']
|
const objectParents = ['mascots']
|
||||||
|
|
||||||
|
const getValueWithoutKey = (key, [type, value]) => {
|
||||||
|
if (type === 'atom' && value.length > 1) {
|
||||||
|
return `:${value}`
|
||||||
|
} else if (key === ':backends') {
|
||||||
|
const index = value.findIndex(el => el === ':ex_syslogger')
|
||||||
|
const updatedArray = value.slice()
|
||||||
|
if (index !== -1) {
|
||||||
|
updatedArray[index] = { 'tuple': ['ExSyslogger', ':ex_syslogger'] }
|
||||||
|
}
|
||||||
|
return updatedArray
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
export const parseNonTuples = (key, value) => {
|
export const parseNonTuples = (key, value) => {
|
||||||
if (key === ':backends') {
|
if (key === ':backends') {
|
||||||
const index = value.findIndex(el => Array.isArray(el) && el.includes(':ex_syslogger'))
|
const index = value.findIndex(el => typeof el === 'object' && el.tuple.includes(':ex_syslogger'))
|
||||||
const updated = value.map((el, i) => i === index ? ':ex_syslogger' : el)
|
const updated = value.map((el, i) => i === index ? ':ex_syslogger' : el)
|
||||||
return { value: updated }
|
return { value: updated }
|
||||||
}
|
}
|
||||||
|
@ -108,9 +122,10 @@ export const partialUpdate = (group, key) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const valueHasTuples = (key, value) => {
|
export const valueHasTuples = (key, value) => {
|
||||||
const valueIsArrayOfNonObjects = Array.isArray(value) && value.length > 0 && typeof value[0] !== 'object'
|
const valueIsArrayOfNonObjects = Array.isArray(value) && value.length > 0 && value.every(el => typeof el !== 'object')
|
||||||
return key === ':meta' ||
|
return key === ':meta' ||
|
||||||
key === ':types' ||
|
key === ':types' ||
|
||||||
|
key === ':backends' ||
|
||||||
key === ':compiled_template_engines' ||
|
key === ':compiled_template_engines' ||
|
||||||
key === ':compiled_format_encoders' ||
|
key === ':compiled_format_encoders' ||
|
||||||
typeof value === 'string' ||
|
typeof value === 'string' ||
|
||||||
|
@ -122,13 +137,9 @@ export const valueHasTuples = (key, value) => {
|
||||||
|
|
||||||
export const wrapUpdatedSettings = (group, settings, currentState) => {
|
export const wrapUpdatedSettings = (group, settings, currentState) => {
|
||||||
return Object.keys(settings).map((key) => {
|
return Object.keys(settings).map((key) => {
|
||||||
if (settings[key]._value) {
|
return settings[key]._value
|
||||||
const value = settings[key]._value[0] === 'atom' && settings[key]._value[1].length > 1
|
? { group, key, value: getValueWithoutKey(key, settings[key]._value) }
|
||||||
? `:${settings[key]._value[1]}`
|
: { group, key, value: wrapValues(settings[key], currentState[group][key]) }
|
||||||
: settings[key]._value[1]
|
|
||||||
return { group, key, value }
|
|
||||||
}
|
|
||||||
return { group, key, value: wrapValues(settings[key], currentState[group][key]) }
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,16 +36,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateSetting(value, group, key, input, type) {
|
updateSetting(value, group, key, input, type) {
|
||||||
const updatedValue = () => {
|
this.$store.dispatch('UpdateSettings', { group, key, input, value, type })
|
||||||
const index = value.findIndex(el => el === ':ex_syslogger')
|
|
||||||
const updatedArray = value.slice()
|
|
||||||
if (index !== -1) {
|
|
||||||
updatedArray[index] = ['ExSyslogger', ':ex_syslogger']
|
|
||||||
}
|
|
||||||
return updatedArray
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$store.dispatch('UpdateSettings', { group, key, input, value: updatedValue(), type })
|
|
||||||
this.$store.dispatch('UpdateState', { group, key, input, value })
|
this.$store.dispatch('UpdateState', { group, key, input, value })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue