grouped settings/managed drafts support added
This commit is contained in:
parent
6992439c92
commit
c7a16bdfe2
@ -2,6 +2,7 @@ import BooleanSetting from '../helpers/boolean_setting.vue'
|
|||||||
import ChoiceSetting from '../helpers/choice_setting.vue'
|
import ChoiceSetting from '../helpers/choice_setting.vue'
|
||||||
import IntegerSetting from '../helpers/integer_setting.vue'
|
import IntegerSetting from '../helpers/integer_setting.vue'
|
||||||
import StringSetting from '../helpers/string_setting.vue'
|
import StringSetting from '../helpers/string_setting.vue'
|
||||||
|
import GroupSetting from '../helpers/group_setting.vue'
|
||||||
|
|
||||||
import SharedComputedObject from '../helpers/shared_computed_object.js'
|
import SharedComputedObject from '../helpers/shared_computed_object.js'
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
@ -24,7 +25,8 @@ const InstanceTab = {
|
|||||||
BooleanSetting,
|
BooleanSetting,
|
||||||
ChoiceSetting,
|
ChoiceSetting,
|
||||||
IntegerSetting,
|
IntegerSetting,
|
||||||
StringSetting
|
StringSetting,
|
||||||
|
GroupSetting
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...SharedComputedObject()
|
...SharedComputedObject()
|
||||||
|
@ -70,6 +70,11 @@
|
|||||||
FED TIMELINES
|
FED TIMELINES
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<GroupSetting path=":pleroma.:restrict_unauthenticated.:timelines">
|
||||||
|
TIMELINES
|
||||||
|
</GroupSetting>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<h4>{{ $t('admin_dash.instance.restrict.profiles') }}</h4>
|
<h4>{{ $t('admin_dash.instance.restrict.profiles') }}</h4>
|
||||||
</li>
|
</li>
|
||||||
@ -89,6 +94,11 @@
|
|||||||
FED PROFILES
|
FED PROFILES
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<GroupSetting path=":pleroma.:restrict_unauthenticated.:profiles">
|
||||||
|
PROFILES
|
||||||
|
</GroupSetting>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<h4>{{ $t('admin_dash.instance.restrict.activities') }}</h4>
|
<h4>{{ $t('admin_dash.instance.restrict.activities') }}</h4>
|
||||||
</li>
|
</li>
|
||||||
@ -108,6 +118,11 @@
|
|||||||
FED STATUSES
|
FED STATUSES
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<GroupSetting path=":pleroma.:restrict_unauthenticated.:activities">
|
||||||
|
STATUSES
|
||||||
|
</GroupSetting>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-item">
|
<div class="setting-item">
|
||||||
|
14
src/components/settings_modal/helpers/group_setting.js
Normal file
14
src/components/settings_modal/helpers/group_setting.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { isEqual } from 'lodash'
|
||||||
|
|
||||||
|
import Setting from './setting.js'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
...Setting,
|
||||||
|
computed: {
|
||||||
|
...Setting.computed,
|
||||||
|
isDirty () {
|
||||||
|
console.log(this.state, this.draft)
|
||||||
|
return !isEqual(this.state, this.draft)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
src/components/settings_modal/helpers/group_setting.vue
Normal file
15
src/components/settings_modal/helpers/group_setting.vue
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<template>
|
||||||
|
<span
|
||||||
|
v-if="matchesExpertLevel"
|
||||||
|
class="GroupSetting"
|
||||||
|
>
|
||||||
|
<ModifiedIndicator
|
||||||
|
:changed="isChanged"
|
||||||
|
:onclick="reset"
|
||||||
|
/>
|
||||||
|
<ProfileSettingIndicator :is-profile="isProfileSetting" />
|
||||||
|
<DraftButtons />
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./group_setting.js"></script>
|
@ -48,15 +48,32 @@ export default {
|
|||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
draft: null
|
localDraft: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
if (this.realDraftMode) {
|
if (this.realDraftMode && this.realSource !== 'admin') {
|
||||||
this.draft = this.state
|
this.draft = this.state
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
draft: {
|
||||||
|
// TODO allow passing shared draft object?
|
||||||
|
get () {
|
||||||
|
if (this.realSource === 'admin') {
|
||||||
|
return get(this.$store.state.adminSettings.draft, this.path)
|
||||||
|
} else {
|
||||||
|
return this.localDraft
|
||||||
|
}
|
||||||
|
},
|
||||||
|
set (value) {
|
||||||
|
if (this.realSource === 'admin') {
|
||||||
|
this.$store.commit('updateAdminDraft', { path: this.canonPath, value })
|
||||||
|
} else {
|
||||||
|
this.localDraft = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
state () {
|
state () {
|
||||||
const value = get(this.configSource, this.path)
|
const value = get(this.configSource, this.path)
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
@ -130,11 +147,18 @@ export default {
|
|||||||
return this.state !== this.defaultState
|
return this.state !== this.defaultState
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
canonPath () {
|
||||||
|
return Array.isArray(this.path) ? this.path : this.path.split('.')
|
||||||
|
},
|
||||||
isDirty () {
|
isDirty () {
|
||||||
return this.realDraftMode && this.draft !== this.state
|
if (this.realSource === 'admin' && this.canonPath.length > 3) {
|
||||||
|
return false // should not show draft buttons for "grouped" values
|
||||||
|
} else {
|
||||||
|
return this.realDraftMode && this.draft !== this.state
|
||||||
|
}
|
||||||
},
|
},
|
||||||
canHardReset () {
|
canHardReset () {
|
||||||
return this.realSource === 'admin' && this.$store.state.adminSettings.modifiedPaths.has(this.path)
|
return this.realSource === 'admin' && this.$store.state.adminSettings.modifiedPaths.has(this.canonPath.join(' -> '))
|
||||||
},
|
},
|
||||||
matchesExpertLevel () {
|
matchesExpertLevel () {
|
||||||
return (this.expert || 0) <= this.$store.state.config.expertLevel > 0
|
return (this.expert || 0) <= this.$store.state.config.expertLevel > 0
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import { set, cloneDeep } from 'lodash'
|
import { set, get, cloneDeep } from 'lodash'
|
||||||
|
|
||||||
export const defaultState = {
|
export const defaultState = {
|
||||||
needsReboot: null,
|
needsReboot: null,
|
||||||
config: null,
|
config: null,
|
||||||
modifiedPaths: null,
|
modifiedPaths: null,
|
||||||
descriptions: null
|
descriptions: null,
|
||||||
|
draft: null
|
||||||
}
|
}
|
||||||
|
|
||||||
export const newUserFlags = {
|
export const newUserFlags = {
|
||||||
@ -22,6 +23,20 @@ const adminSettingsStorage = {
|
|||||||
},
|
},
|
||||||
updateAdminDescriptions (state, { descriptions }) {
|
updateAdminDescriptions (state, { descriptions }) {
|
||||||
state.descriptions = descriptions
|
state.descriptions = descriptions
|
||||||
|
},
|
||||||
|
updateAdminDraft (state, { path, value }) {
|
||||||
|
const [group, key, subkey] = path
|
||||||
|
const parent = [group, key, subkey]
|
||||||
|
|
||||||
|
set(state.draft, path, value)
|
||||||
|
|
||||||
|
// force-updating grouped draft to trigger refresh of group settings
|
||||||
|
if (path.length > parent.length) {
|
||||||
|
set(state.draft, parent, cloneDeep(get(state.draft, parent)))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
resetAdminDraft (state) {
|
||||||
|
state.draft = cloneDeep(state.config)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@ -31,7 +46,9 @@ const adminSettingsStorage = {
|
|||||||
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))
|
// Path elements can contain dot, therefore we use ' -> ' as a separator instead
|
||||||
|
// Using strings for modified paths for easier searching
|
||||||
|
c.db.forEach(x => modifiedPaths.add([...path, x].join(' -> ')))
|
||||||
}
|
}
|
||||||
const convert = (value) => {
|
const convert = (value) => {
|
||||||
if (Array.isArray(value) && value.length > 0 && value[0].tuple) {
|
if (Array.isArray(value) && value.length > 0 && value[0].tuple) {
|
||||||
@ -46,6 +63,7 @@ const adminSettingsStorage = {
|
|||||||
})
|
})
|
||||||
console.log(config[':pleroma'])
|
console.log(config[':pleroma'])
|
||||||
commit('updateAdminSettings', { config, modifiedPaths })
|
commit('updateAdminSettings', { config, modifiedPaths })
|
||||||
|
commit('resetAdminDraft')
|
||||||
},
|
},
|
||||||
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) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user