Add ability to select a setting and go to the tab of the selected setting
This commit is contained in:
parent
26889c28e3
commit
584401a3d7
3 changed files with 14 additions and 9 deletions
|
@ -256,21 +256,21 @@ const wrapValues = (settings, currentState) => {
|
|||
}
|
||||
|
||||
export const formSearchObject = description => {
|
||||
const parseNestedSettings = (description, key) => description.reduce((acc, setting) => {
|
||||
const parseNestedSettings = (description, label, key) => description.reduce((acc, setting) => {
|
||||
const searchArray = _.compact([setting.key, setting.label, setting.description]).map(el => el.toLowerCase())
|
||||
if (setting.children) {
|
||||
const updatedAcc = [...acc, { key: setting.label, group: key, search: searchArray }]
|
||||
return [...updatedAcc, ...parseNestedSettings(setting.children, setting.label)]
|
||||
const updatedAcc = [...acc, { label: setting.label, key: setting.key, groupKey: key, groupLabel: label, search: searchArray }]
|
||||
return [...updatedAcc, ...parseNestedSettings(setting.children, setting.label, setting.key)]
|
||||
}
|
||||
return [...acc, { key: [setting.label], group: key, search: searchArray }]
|
||||
return [...acc, { label: setting.label, key: setting.label, groupKey: key, groupLabel: label, search: searchArray }]
|
||||
}, [])
|
||||
|
||||
return description.reduce((acc, setting) => {
|
||||
const searchArray = _.compact([setting.key, setting.label, setting.description]).map(el => el.toLowerCase())
|
||||
if (setting.children) {
|
||||
const updatedAcc = [...acc, { key: setting.label, group: setting.label, search: searchArray }]
|
||||
return [...updatedAcc, ...parseNestedSettings(setting.children, setting.label)]
|
||||
const updatedAcc = [...acc, { label: setting.label, key: setting.key, groupKey: setting.key, groupLabel: setting.label, search: searchArray }]
|
||||
return [...updatedAcc, ...parseNestedSettings(setting.children, setting.label, setting.key)]
|
||||
}
|
||||
return [...acc, { key: setting.label, group: setting.label, search: searchArray }]
|
||||
return [...acc, { label: setting.label, key: setting.label, groupKey: setting.key, groupLabel: setting.label, search: searchArray }]
|
||||
}, [])
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import _ from 'lodash'
|
|||
export const tabs = {
|
||||
'activity-pub': {
|
||||
label: 'settings.activityPub',
|
||||
settings: [':activitypub', ':user'],
|
||||
activitypub: () => this.settings.description.find(setting => setting.key === ':activitypub'),
|
||||
activitypubData: () => _.get(this.settings.settings, [':pleroma', ':activitypub']) || {},
|
||||
user: () => this.settings.description.find(setting => setting.key === ':user'),
|
||||
|
|
|
@ -223,12 +223,16 @@ export default {
|
|||
message: i18n.t('settings.restartSuccess')
|
||||
})
|
||||
},
|
||||
handleSearchSelect() {
|
||||
handleSearchSelect(selectedValue) {
|
||||
const tab = Object.keys(this.tabs).find(tab => {
|
||||
return this.tabs[tab].settings.includes(selectedValue.group)
|
||||
})
|
||||
this.$store.dispatch('SetActiveTab', tab)
|
||||
},
|
||||
querySearch(queryString, cb) {
|
||||
const results = this.searchData.filter(searchObj => searchObj.search.find(el => el.includes(queryString.toLowerCase())))
|
||||
.map(searchObj => {
|
||||
return { value: `${searchObj.key} in ${searchObj.group}` }
|
||||
return { value: `${searchObj.label} in ${searchObj.groupLabel}`, group: searchObj.groupKey }
|
||||
})
|
||||
cb(results)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue