ChoiceSetting support added, added captcha settings

This commit is contained in:
Henry Jameson 2023-03-20 23:36:47 +02:00
commit 0b5e536b4c
7 changed files with 121 additions and 13 deletions

View file

@ -29,7 +29,7 @@ const adminSettingsStorage = {
const config = state.config || {}
const modifiedPaths = state.modifiedPaths || new Set()
backendDbConfig.configs.forEach(c => {
const path = c.group + '.' + c.key
const path = [c.group, c.key]
if (c.db) {
c.db.forEach(x => modifiedPaths.add(path + '.' + x))
}
@ -44,16 +44,16 @@ const adminSettingsStorage = {
}
set(config, path, convert(c.value))
})
console.log(config[':pleroma'][':welcome'])
console.log(config[':pleroma'])
commit('updateAdminSettings', { config, modifiedPaths })
},
setInstanceAdminDescriptions ({ state, commit, dispatch }, { backendDescriptions }) {
const convert = ({ children, description, label, key = '<ROOT>', group, suggestions }, path, acc) => {
const newPath = group ? group + '.' + key : key
const newPath = group ? [group, key] : [key]
const obj = { description, label, suggestions }
if (Array.isArray(children)) {
children.forEach(c => {
convert(c, '.' + newPath, obj)
convert(c, newPath, obj)
})
}
set(acc, newPath, obj)
@ -61,12 +61,13 @@ const adminSettingsStorage = {
const descriptions = {}
backendDescriptions.forEach(d => convert(d, '', descriptions))
console.log(descriptions[':pleroma']['Pleroma.Captcha'])
commit('updateAdminDescriptions', { descriptions })
},
pushAdminSetting ({ rootState, state, commit, dispatch }, { path, value }) {
const [group, key, ...rest] = path.split(/\./g)
const [group, key, ...rest] = Array.isArray(path) ? path : path.split(/\./g)
const clone = {} // not actually cloning the entire thing to avoid excessive writes
set(clone, rest.join('.'), value)
set(clone, rest, value)
// TODO cleanup paths in modifiedPaths
const convert = (value) => {