diff --git a/CHANGELOG.md b/CHANGELOG.md index ac4e0a92..e3c7f132 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Ability to see local statuses in Statuses by instance section - Ability to configure Oban.Cron settings and settings for notifications streamer +- Settings search ### Fixed diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index 4d23c957..6eecebca 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -267,3 +267,25 @@ const wrapValues = (settings, currentState) => { } }) } + +export const formSearchObject = description => { + const parseNestedSettings = (description, label, key) => description.reduce((acc, setting) => { + const searchArray = _.compact([setting.key, setting.label, setting.description]).map(el => el.toLowerCase()) + const resultObject = { label: setting.label, key: setting.key || setting.group, groupKey: key, groupLabel: label, search: searchArray } + if (setting.children) { + const updatedAcc = [...acc, resultObject] + return [...updatedAcc, ...parseNestedSettings(setting.children, label, key)] + } + return [...acc, resultObject] + }, []) + + return description.reduce((acc, setting) => { + const searchArray = _.compact([setting.key, setting.label, setting.description]).map(el => el.toLowerCase()) + const resultObject = { label: setting.label, key: setting.key || setting.group, groupKey: setting.key || setting.group, groupLabel: setting.label, search: searchArray } + if (setting.children) { + const updatedAcc = !setting.key && setting.group === ':pleroma' ? acc : [...acc, resultObject] + return [...updatedAcc, ...parseNestedSettings(setting.children, setting.label, setting.key || setting.group)] + } + return !setting.key && setting.group === ':pleroma' ? acc : [...acc, resultObject] + }, []) +} diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index ab7a3b36..5adc16a0 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -1,5 +1,5 @@ import { fetchDescription, fetchSettings, removeSettings, restartApp, updateSettings } from '@/api/settings' -import { checkPartialUpdate, parseNonTuples, parseTuples, valueHasTuples, wrapUpdatedSettings } from './normalizers' +import { checkPartialUpdate, formSearchObject, parseNonTuples, parseTuples, valueHasTuples, wrapUpdatedSettings } from './normalizers' import _ from 'lodash' const settings = { @@ -10,6 +10,7 @@ const settings = { description: [], loading: true, needReboot: false, + searchData: {}, settings: {}, updatedSettings: {} }, @@ -32,6 +33,9 @@ const settings = { SET_LOADING: (state, status) => { state.loading = status }, + SET_SEARCH: (state, searchObject) => { + state.searchData = searchObject + }, SET_SETTINGS: (state, data) => { const newSettings = data.reduce((acc, { group, key, value }) => { const parsedValue = valueHasTuples(key, value) @@ -77,6 +81,8 @@ const settings = { const response = await fetchSettings(getters.authHost, getters.token) const description = await fetchDescription(getters.authHost, getters.token) commit('SET_DESCRIPTION', description.data) + const searchObject = formSearchObject(description.data) + commit('SET_SEARCH', searchObject) commit('SET_SETTINGS', response.data.configs) commit('TOGGLE_REBOOT', response.data.need_reboot) } catch (_e) { diff --git a/src/views/invites/index.vue b/src/views/invites/index.vue index 60111430..55aa6fc0 100644 --- a/src/views/invites/index.vue +++ b/src/views/invites/index.vue @@ -39,7 +39,7 @@ - {{ $t('invites.cancel') }} + {{ $t('invites.cancel') }} {{ $t('invites.create') }} diff --git a/src/views/settings/components/ActivityPub.vue b/src/views/settings/components/ActivityPub.vue index abd03f10..3e71e0c2 100644 --- a/src/views/settings/components/ActivityPub.vue +++ b/src/views/settings/components/ActivityPub.vue @@ -1,10 +1,10 @@