ChoiceSetting support added, added captcha settings
This commit is contained in:
parent
819cd41cf0
commit
0b5e536b4c
|
@ -111,6 +111,57 @@
|
||||||
APPROVAL REQUIRED
|
APPROVAL REQUIRED
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<h3>{{ $t('admin_dash.captcha.header') }}</h3>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<BooleanSetting
|
||||||
|
source="admin"
|
||||||
|
:path="[':pleroma', 'Pleroma.Captcha', ':enabled']"
|
||||||
|
draft-mode
|
||||||
|
>
|
||||||
|
CAPTCHA
|
||||||
|
</BooleanSetting>
|
||||||
|
<ul class="setting-list suboptions">
|
||||||
|
<li>
|
||||||
|
<ChoiceSetting
|
||||||
|
source="admin"
|
||||||
|
:path="[':pleroma', 'Pleroma.Captcha', ':method']"
|
||||||
|
:parent-path="[':pleroma', 'Pleroma.Captcha', ':enabled']"
|
||||||
|
:option-label-map="{
|
||||||
|
'Pleroma.Captcha.Native': $t('admin_dash.captcha.native'),
|
||||||
|
'Pleroma.Captcha.Kocaptcha': $t('admin_dash.captcha.kocaptcha')
|
||||||
|
}"
|
||||||
|
draft-mode
|
||||||
|
>
|
||||||
|
CAPTCHA TYPE
|
||||||
|
</ChoiceSetting>
|
||||||
|
<IntegerSetting
|
||||||
|
source="admin"
|
||||||
|
:path="[':pleroma', 'Pleroma.Captcha', ':seconds_valid']"
|
||||||
|
:parent-path="[':pleroma', 'Pleroma.Captcha', ':enabled']"
|
||||||
|
draft-mode
|
||||||
|
>
|
||||||
|
VALID
|
||||||
|
</IntegerSetting>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<ul
|
||||||
|
v-if="adminConfig[':pleroma']['Pleroma.Captcha'][':enabled'] && adminConfig[':pleroma']['Pleroma.Captcha'][':method'] === 'Pleroma.Captcha.Kocaptcha'"
|
||||||
|
class="setting-list suboptions"
|
||||||
|
>
|
||||||
|
<h4>{{ $t('admin_dash.kocaptcha') }}</h4>
|
||||||
|
<li>
|
||||||
|
<StringSetting
|
||||||
|
source="admin"
|
||||||
|
:path="[':pleroma', 'Pleroma.Captcha.Kocaptcha', ':endpoint']"
|
||||||
|
draft-mode
|
||||||
|
>
|
||||||
|
cockAPTCHA ENDPOINT
|
||||||
|
</StringSetting>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,7 +11,32 @@ export default {
|
||||||
...Setting.props,
|
...Setting.props,
|
||||||
options: {
|
options: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: false
|
||||||
|
},
|
||||||
|
optionLabelMap: {
|
||||||
|
type: Object,
|
||||||
|
required: false,
|
||||||
|
default: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...Setting.computed,
|
||||||
|
realOptions () {
|
||||||
|
if (this.source === 'admin') {
|
||||||
|
console.log(this.backendDescriptionSuggestions)
|
||||||
|
return this.backendDescriptionSuggestions.map(x => ({
|
||||||
|
key: x,
|
||||||
|
value: x,
|
||||||
|
label: this.optionLabelMap[x] || x
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
return this.options
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...Setting.methods,
|
||||||
|
getValue (e) {
|
||||||
|
return e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,20 @@
|
||||||
v-if="matchesExpertLevel"
|
v-if="matchesExpertLevel"
|
||||||
class="ChoiceSetting"
|
class="ChoiceSetting"
|
||||||
>
|
>
|
||||||
<slot />
|
<template v-if="backendDescription">
|
||||||
|
{{ backendDescriptionLabel }}
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<slot />
|
||||||
|
</template>
|
||||||
{{ ' ' }}
|
{{ ' ' }}
|
||||||
<Select
|
<Select
|
||||||
:model-value="state"
|
:model-value="draftMode ? draft :state"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
@update:modelValue="update"
|
@update:modelValue="update"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
v-for="option in options"
|
v-for="option in realOptions"
|
||||||
:key="option.key"
|
:key="option.key"
|
||||||
:value="option.value"
|
:value="option.value"
|
||||||
>
|
>
|
||||||
|
@ -24,6 +29,13 @@
|
||||||
:onclick="reset"
|
:onclick="reset"
|
||||||
/>
|
/>
|
||||||
<ProfileSettingIndicator :is-profile="isProfileSetting" />
|
<ProfileSettingIndicator :is-profile="isProfileSetting" />
|
||||||
|
<DraftButtons />
|
||||||
|
<p
|
||||||
|
v-if="backendDescriptionDescription"
|
||||||
|
class="setting-description"
|
||||||
|
>
|
||||||
|
{{ backendDescriptionDescription + ' ' }}
|
||||||
|
</p>
|
||||||
</label>
|
</label>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,12 @@
|
||||||
class="NumberSetting"
|
class="NumberSetting"
|
||||||
>
|
>
|
||||||
<label :for="path">
|
<label :for="path">
|
||||||
<slot />
|
<template v-if="backendDescription">
|
||||||
|
{{ backendDescriptionLabel + ' ' }}
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<slot />
|
||||||
|
</template>
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
:id="path"
|
:id="path"
|
||||||
|
@ -21,6 +26,14 @@
|
||||||
:changed="isChanged"
|
:changed="isChanged"
|
||||||
:onclick="reset"
|
:onclick="reset"
|
||||||
/>
|
/>
|
||||||
|
<ProfileSettingIndicator :is-profile="isProfileSetting" />
|
||||||
|
<DraftButtons />
|
||||||
|
<p
|
||||||
|
v-if="backendDescriptionDescription"
|
||||||
|
class="setting-description"
|
||||||
|
>
|
||||||
|
{{ backendDescriptionDescription + ' ' }}
|
||||||
|
</p>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ export default {
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
path: {
|
path: {
|
||||||
type: String,
|
type: [String, Array],
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
disabled: {
|
disabled: {
|
||||||
|
@ -21,7 +21,7 @@ export default {
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
parentPath: {
|
parentPath: {
|
||||||
type: String
|
type: [String, Array]
|
||||||
},
|
},
|
||||||
parentInvert: {
|
parentInvert: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -68,6 +68,9 @@ export default {
|
||||||
backendDescriptionDescription () {
|
backendDescriptionDescription () {
|
||||||
return this.backendDescription?.description
|
return this.backendDescription?.description
|
||||||
},
|
},
|
||||||
|
backendDescriptionSuggestions () {
|
||||||
|
return this.backendDescription?.suggestions
|
||||||
|
},
|
||||||
shouldBeDisabled () {
|
shouldBeDisabled () {
|
||||||
const parentValue = this.parentPath !== undefined ? get(this.configSource, this.parentPath) : null
|
const parentValue = this.parentPath !== undefined ? get(this.configSource, this.parentPath) : null
|
||||||
return this.disabled || (parentValue !== null ? (this.parentInvert ? parentValue : !parentValue) : false)
|
return this.disabled || (parentValue !== null ? (this.parentInvert ? parentValue : !parentValue) : false)
|
||||||
|
|
|
@ -7,6 +7,9 @@ const SharedComputedObject = () => ({
|
||||||
},
|
},
|
||||||
mergedConfig () {
|
mergedConfig () {
|
||||||
return this.$store.getters.mergedConfig
|
return this.$store.getters.mergedConfig
|
||||||
|
},
|
||||||
|
adminConfig () {
|
||||||
|
return this.$store.state.adminSettings.config
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ const adminSettingsStorage = {
|
||||||
const config = state.config || {}
|
const config = state.config || {}
|
||||||
const modifiedPaths = state.modifiedPaths || new Set()
|
const modifiedPaths = state.modifiedPaths || new Set()
|
||||||
backendDbConfig.configs.forEach(c => {
|
backendDbConfig.configs.forEach(c => {
|
||||||
const path = c.group + '.' + c.key
|
const path = [c.group, c.key]
|
||||||
if (c.db) {
|
if (c.db) {
|
||||||
c.db.forEach(x => modifiedPaths.add(path + '.' + x))
|
c.db.forEach(x => modifiedPaths.add(path + '.' + x))
|
||||||
}
|
}
|
||||||
|
@ -44,16 +44,16 @@ const adminSettingsStorage = {
|
||||||
}
|
}
|
||||||
set(config, path, convert(c.value))
|
set(config, path, convert(c.value))
|
||||||
})
|
})
|
||||||
console.log(config[':pleroma'][':welcome'])
|
console.log(config[':pleroma'])
|
||||||
commit('updateAdminSettings', { config, modifiedPaths })
|
commit('updateAdminSettings', { config, modifiedPaths })
|
||||||
},
|
},
|
||||||
setInstanceAdminDescriptions ({ state, commit, dispatch }, { backendDescriptions }) {
|
setInstanceAdminDescriptions ({ state, commit, dispatch }, { backendDescriptions }) {
|
||||||
const convert = ({ children, description, label, key = '<ROOT>', group, suggestions }, path, acc) => {
|
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 }
|
const obj = { description, label, suggestions }
|
||||||
if (Array.isArray(children)) {
|
if (Array.isArray(children)) {
|
||||||
children.forEach(c => {
|
children.forEach(c => {
|
||||||
convert(c, '.' + newPath, obj)
|
convert(c, newPath, obj)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
set(acc, newPath, obj)
|
set(acc, newPath, obj)
|
||||||
|
@ -61,12 +61,13 @@ const adminSettingsStorage = {
|
||||||
|
|
||||||
const descriptions = {}
|
const descriptions = {}
|
||||||
backendDescriptions.forEach(d => convert(d, '', descriptions))
|
backendDescriptions.forEach(d => convert(d, '', descriptions))
|
||||||
|
console.log(descriptions[':pleroma']['Pleroma.Captcha'])
|
||||||
commit('updateAdminDescriptions', { descriptions })
|
commit('updateAdminDescriptions', { descriptions })
|
||||||
},
|
},
|
||||||
pushAdminSetting ({ rootState, state, commit, dispatch }, { path, value }) {
|
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
|
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
|
// TODO cleanup paths in modifiedPaths
|
||||||
const convert = (value) => {
|
const convert = (value) => {
|
||||||
|
|
Loading…
Reference in New Issue