Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85804879
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/components/admin_dashboard/tabs/config_entry.vue b/src/components/admin_dashboard/tabs/config_entry.vue
index 1634e1bfa4..86e71775cd 100644
--- a/src/components/admin_dashboard/tabs/config_entry.vue
+++ b/src/components/admin_dashboard/tabs/config_entry.vue
@@ -1,12 +1,13 @@
<template>
<typed-input
:type="type"
:model-value="configs"
+ :suggestions="suggestions"
@update:modelValue="setConfigs"
/>
</template>
<script src="./config_entry.js"></script>
<style lang="scss">
</style>
diff --git a/src/components/admin_dashboard/tabs/config_tree.js b/src/components/admin_dashboard/tabs/config_tree.js
index 28fcf61502..51b5bc9005 100644
--- a/src/components/admin_dashboard/tabs/config_tree.js
+++ b/src/components/admin_dashboard/tabs/config_tree.js
@@ -1,64 +1,65 @@
import { get } from 'lodash'
import ConfigEntry from './config_entry.vue'
const ConfigTree = {
name: 'ConfigTree',
components: {
ConfigEntry
},
props: {
path: {
type: Array
}
},
computed: {
descriptions () {
return this.$store.state.admin.descriptions
},
config () {
return this.$store.state.admin.config
},
descriptionsAtPoint () {
const group = get(this.descriptions, this.path.slice(0, 2))
const rest = this.path.slice(2)
if (!rest.length) {
return group
}
const getInList = (value, path) => {
if (!path.length) {
return value
} else if (value && value.children) {
const maybeNext = value.children.find(k => k.key === path[0])
if (maybeNext) {
return getInList(maybeNext, path.slice(1))
} else {
return {}
}
}
}
return getInList(group, rest) || {}
},
configsAtPoint () {
- const group = get(this.config, this.path.slice(0, 2))
- const rest = this.path.slice(2)
+ const path = this.path.filter(k => k !== 'undefined')
+ const group = get(this.config, path.slice(0, 2))
+ const rest = path.slice(2)
const getInList = (value, path) => {
if (!path.length) {
return value
} else if (Array.isArray(value)) {
const maybeNext = value.find(k => k.tuple && k.tuple[0] === path[0])
if (maybeNext && maybeNext.tuple[1]) {
return getInList(maybeNext.tuple[1], path.slice(1))
}
}
return {}
}
return getInList((group || {}).value, rest)
}
}
}
export default ConfigTree
diff --git a/src/components/admin_dashboard/tabs/typed_input.js b/src/components/admin_dashboard/tabs/typed_input.js
index e4a5225ff6..e489e87b2c 100644
--- a/src/components/admin_dashboard/tabs/typed_input.js
+++ b/src/components/admin_dashboard/tabs/typed_input.js
@@ -1,14 +1,22 @@
import Checkbox from 'src/components/checkbox/checkbox.vue'
+import Select from 'src/components/select/select.vue'
const TypedInput = {
props: [
'modelValue',
- 'type'
+ 'type',
+ 'suggestions'
],
emits: ['update:modelValue'],
components: {
- Checkbox
+ Checkbox,
+ Select
+ },
+ computed: {
+ isDropdown () {
+ return Array.isArray(this.type) && this.type[0] === 'dropdown'
+ }
}
}
export default TypedInput
diff --git a/src/components/admin_dashboard/tabs/typed_input.vue b/src/components/admin_dashboard/tabs/typed_input.vue
index 2ba6cafe37..4bf35e093b 100644
--- a/src/components/admin_dashboard/tabs/typed_input.vue
+++ b/src/components/admin_dashboard/tabs/typed_input.vue
@@ -1,29 +1,42 @@
<template>
<div>
+ <Select
+ v-if="isDropdown"
+ :model-value="modelValue"
+ @update:modelValue="k => $emit('update:modelValue', k)"
+ >
+ <option
+ v-for="option in suggestions"
+ :key="option"
+ :value="option"
+ >
+ {{ option }}
+ </option>
+ </Select>
<input
- v-if="type === 'integer'"
+ v-else-if="type === 'integer'"
type="number"
:value="modelValue"
@change="$emit('update:modelValue', $event.target.value)"
>
<input
v-else-if="type === 'string'"
type="string"
:value="modelValue"
@change="$emit('update:modelValue', $event.target.value)"
>
<Checkbox
v-else-if="type === 'boolean'"
:value="modelValue"
@change="$emit('update:modelValue', $event.target.value)"
/>
<p v-else>
{{ modelValue }}
</p>
</div>
</template>
<script src="./typed_input.js"></script>
<style lang="scss">
</style>
diff --git a/src/modules/admin.js b/src/modules/admin.js
index d1d5c6b82d..a263428331 100644
--- a/src/modules/admin.js
+++ b/src/modules/admin.js
@@ -1,81 +1,82 @@
import { set, get } from 'lodash'
export const defaultState = {
config: {},
descriptions: {}
}
export const mutations = {
setAdminConfig (state, { config, descriptions }) {
state.config = parse(config.configs)
state.descriptions = parse(descriptions)
},
updateAdminConfig (state, { path, newVal }) {
+ path = path.filter(k => k !== 'undefined')
const prefix = path.slice(0, 2).concat(['value'])
const group = get(state.config, prefix)
const rest = path.slice(2)
const getStructurePath = (result, value, path) => {
if (!path.length) {
return result
} else if (Array.isArray(value)) {
const index = value.findIndex(k => k.tuple && k.tuple[0] === path[0])
if (index >= 0 && value[index].tuple[1]) {
return getStructurePath(result.concat([index, 'tuple', 1]), value[index].tuple[1], path.slice(1))
}
}
return null
}
const structurePath = getStructurePath(prefix, group, rest)
set(state.config, structurePath, newVal)
}
}
const parse = desc => {
return desc.reduce((acc, cur) => {
acc[cur.group] ||= {}
acc[cur.group][cur.key] = cur
return acc
}, {})
}
const getTabs = state => {
return Object.keys(state.descriptions).map(group => {
return {
name: group,
configs: Object.keys(state.descriptions[group]).map(key => ({ group, key }))
}
})
}
const admin = {
state: { ...defaultState },
getters: {
adminConfigTabs (state) {
/// XXX placeholder to use group as tab
return getTabs(state)
},
adminConfigTabsObject (state) {
return getTabs(state).reduce((acc, cur) => {
acc[cur.name] = cur
return acc
}, {})
}
},
mutations,
actions: {
async fetchAdminConfig ({ rootState, commit }) {
const config = await rootState.api.backendInteractor.fetchAdminConfig()
const descriptions = await rootState.api.backendInteractor.fetchAdminConfigDescriptions()
commit('setAdminConfig', { config, descriptions })
},
updateAdminConfig ({ commit }, { path, newVal }) {
commit('updateAdminConfig', { path, newVal })
}
}
}
export default admin
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Oct 10, 4:09 PM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1785353
Default Alt Text
(6 KB)
Attached To
Mode
rPUFE pleroma-fe-upstream
Attached
Detach File
Event Timeline
Log In to Comment