diff --git a/CHANGELOG.md b/CHANGELOG.md index 63adcd3e..ac740f23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Displays both labels and description in the header of group of settiings - Ability to add custom values in Pleroma.Upload.Filter.Mogrify setting - Show only those MRF settings that have been enabled in MRF Policies setting +- Move Auto Linker settings to Link Formatter Tab as its configuration was moved to :pleroma, Pleroma.Formatter ### Fixed diff --git a/src/lang/en.js b/src/lang/en.js index e11740d9..3b644597 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -358,10 +358,10 @@ export default { instance: 'Instance', upload: 'Upload', mailer: 'Mailer', + linkFormatter: 'Link Formatter', logger: 'Logger', activityPub: 'ActivityPub', auth: 'Authentication', - autoLinker: 'Auto Linker', captcha: 'Captcha', frontend: 'Frontend', http: 'HTTP', diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index c146d60e..349cebff 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -9,28 +9,6 @@ export const getBooleanValue = value => { return value } -export const checkPartialUpdate = (settings, updatedSettings, description) => { - return Object.keys(updatedSettings).reduce((acc, group) => { - acc[group] = Object.keys(updatedSettings[group]).reduce((acc, key) => { - if (!partialUpdate(group, key)) { - const updated = Object.keys(settings[group][key]).reduce((acc, settingName) => { - const setting = description - .find(element => element.group === group && element.key === key).children - .find(child => child.key === settingName) - const type = setting ? setting.type : '' - acc[settingName] = [type, settings[group][key][settingName]] - return acc - }, {}) - acc[key] = updated - return acc - } - acc[key] = updatedSettings[group][key] - return acc - }, {}) - return acc - }, {}) -} - const getCurrentValue = (type, value, path) => { if (type === 'state') { return _.get(value, path) @@ -50,7 +28,7 @@ const getCurrentValue = (type, value, path) => { } const getValueWithoutKey = (key, [type, value]) => { - if (type === 'atom' && value.length > 1) { + if (prependWithСolon(type, value)) { return `:${value}` } else if (key === ':backends') { const index = value.findIndex(el => el === ':ex_syslogger') @@ -154,8 +132,9 @@ const parseProxyUrl = value => { return { socks5: false, host: null, port: null } } -const partialUpdate = (group, key) => { - return !(group === ':auto_linker' && key === ':opts') +const prependWithСolon = (type, value) => { + return (type === 'atom' && value.length > 0) || + (Array.isArray(type) && type.includes('boolean') && type.includes('atom') && typeof value === 'string') } export const processNested = (valueForState, valueForUpdatedSettings, group, parentKey, parents, settings, updatedSettings) => { @@ -242,7 +221,7 @@ const wrapValues = (settings, currentState) => { setting === ':replace' ) { return { 'tuple': [setting, wrapValues(value, currentState)] } - } else if (type === 'atom' && value.length > 0) { + } else if (prependWithСolon(type, value)) { return { 'tuple': [setting, `:${value}`] } } else if (type.includes('tuple') && (type.includes('string') || type.includes('atom'))) { return typeof value === 'string' diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index 6053ec2d..6c193e57 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -1,5 +1,5 @@ import { fetchDescription, fetchSettings, removeSettings, updateSettings } from '@/api/settings' -import { checkPartialUpdate, formSearchObject, parseNonTuples, parseTuples, valueHasTuples, wrapUpdatedSettings } from './normalizers' +import { formSearchObject, parseNonTuples, parseTuples, valueHasTuples, wrapUpdatedSettings } from './normalizers' import _ from 'lodash' const settings = { @@ -101,9 +101,8 @@ const settings = { commit('SET_ACTIVE_TAB', tab) }, async SubmitChanges({ getters, commit, state }) { - const updatedData = checkPartialUpdate(state.settings, state.updatedSettings, state.description) - const configs = Object.keys(updatedData).reduce((acc, group) => { - return [...acc, ...wrapUpdatedSettings(group, updatedData[group], state.settings)] + const configs = Object.keys(state.updatedSettings).reduce((acc, group) => { + return [...acc, ...wrapUpdatedSettings(group, state.updatedSettings[group], state.settings)] }, []) await updateSettings(configs, getters.authHost, getters.token) diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index b22ba620..8bbd8121 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -102,10 +102,10 @@ - + @@ -129,11 +129,11 @@ - - diff --git a/src/views/settings/components/inputComponents/LinkFormatterInput.vue b/src/views/settings/components/inputComponents/LinkFormatterInput.vue new file mode 100644 index 00000000..38ec2e50 --- /dev/null +++ b/src/views/settings/components/inputComponents/LinkFormatterInput.vue @@ -0,0 +1,90 @@ + + + + + diff --git a/src/views/settings/components/inputComponents/index.js b/src/views/settings/components/inputComponents/index.js index 11281950..c7ac42bf 100644 --- a/src/views/settings/components/inputComponents/index.js +++ b/src/views/settings/components/inputComponents/index.js @@ -1,8 +1,8 @@ -export { default as AutoLinkerInput } from './AutoLinkerInput' export { default as EditableKeywordInput } from './EditableKeywordInput' export { default as CrontabInput } from './CrontabInput' export { default as IconsInput } from './IconsInput' export { default as ImageUploadInput } from './ImageUploadInput' +export { default as LinkFormatterInput } from './LinkFormatterInput' export { default as MascotsInput } from './MascotsInput' export { default as ProxyUrlInput } from './ProxyUrlInput' export { default as PruneInput } from './PruneInput' diff --git a/src/views/settings/components/tabs.js b/src/views/settings/components/tabs.js index 7190dddd..bf3c752f 100644 --- a/src/views/settings/components/tabs.js +++ b/src/views/settings/components/tabs.js @@ -7,10 +7,6 @@ export const tabs = { label: 'settings.auth', settings: [':auth', ':ldap', ':oauth2', 'Pleroma.Web.Auth.Authenticator'] }, - 'auto-linker': { - label: 'settings.autoLinker', - settings: [':opts'] - }, 'esshd': { label: 'settings.esshd', settings: [':esshd'] @@ -39,6 +35,10 @@ export const tabs = { label: 'settings.jobQueue', settings: ['Pleroma.ActivityExpiration', 'Oban', ':workers'] }, + 'link-formatter': { + label: 'settings.linkFormatter', + settings: ['Pleroma.Formatter'] + }, 'logger': { label: 'settings.logger', settings: [':console', ':ex_syslogger', ':quack', ':logger'] diff --git a/src/views/settings/index.vue b/src/views/settings/index.vue index 6f02a451..45f20324 100644 --- a/src/views/settings/index.vue +++ b/src/views/settings/index.vue @@ -69,7 +69,7 @@
- + @@ -97,7 +97,6 @@ import { tabs } from './components/tabs' import { ActivityPub, Authentication, - AutoLinker, Captcha, Esshd, Frontend, @@ -105,6 +104,7 @@ import { Http, Instance, JobQueue, + LinkFormatter, Logger, Mailer, MediaProxy, @@ -122,7 +122,6 @@ export default { components: { ActivityPub, Authentication, - AutoLinker, Captcha, Esshd, Frontend, @@ -130,6 +129,7 @@ export default { Http, Instance, JobQueue, + LinkFormatter, Logger, Mailer, MediaProxy, @@ -147,7 +147,7 @@ export default { options: [ { value: 'activityPub', label: i18n.t('settings.activityPub') }, { value: 'auth', label: i18n.t('settings.auth') }, - { value: 'autoLinker', label: i18n.t('settings.autoLinker') }, + { value: 'linkFormatter', label: i18n.t('settings.linkFormatter') }, { value: 'esshd', label: i18n.t('settings.esshd') }, { value: 'captcha', label: i18n.t('settings.captcha') }, { value: 'frontend', label: i18n.t('settings.frontend') }, @@ -222,9 +222,7 @@ export default { querySearch(queryString, cb) { const results = this.searchData.filter(searchObj => searchObj.search.find(el => el.includes(queryString.toLowerCase()))) .map(searchObj => { - return searchObj.groupKey === ':opts' - ? { value: `${searchObj.label} in Auto Linker`, group: searchObj.groupKey, key: searchObj.key } - : { value: `${searchObj.label} in ${searchObj.groupLabel}`, group: searchObj.groupKey, key: searchObj.key } + return { value: `${searchObj.label} in ${searchObj.groupLabel}`, group: searchObj.groupKey, key: searchObj.key } }) cb(results) }, diff --git a/test/modules/normalizers/checkPartialUpdate.test.js b/test/modules/normalizers/checkPartialUpdate.test.js deleted file mode 100644 index 87e6f104..00000000 --- a/test/modules/normalizers/checkPartialUpdate.test.js +++ /dev/null @@ -1,48 +0,0 @@ -import { checkPartialUpdate } from '@/store/modules/normalizers' -import _ from 'lodash' - -describe('Partial update', () => { - it('partial update for settings that do not allow partial update', () => { - const settings = { ':auto_linker': { ':opts': - { ':strip_prefix': true, ':new_window': false, ':rel': 'ugc', ':truncate': 3 } - }} - const updatedSettings = { ':auto_linker': { ':opts': { ':new_window': false }}} - const description = [{ - children: [ - { key: ':strip_prefix', type: 'boolean' }, - { key: ':truncate', type: ['integer', false] }, - { key: ':new_window', type: 'boolean' }], - description: 'Configuration for the auto_linker library', - group: ':auto_linker', - key: ':opts', - label: 'Opts', - type: 'group' - }] - - const expectedData = { ':auto_linker': { ':opts': { - ':strip_prefix': ['boolean', true], - ':new_window': ['boolean', false], - ':rel': ['', 'ugc'], - ':truncate': [['integer', false], 3] - }}} - const updatedData = checkPartialUpdate(settings, updatedSettings, description) - expect(_.isEqual(updatedData, expectedData)).toBeTruthy() - }) - - it('partial update for settings that allow partial update', () => { - const settings = { ':pleroma': { 'Pleroma.Captcha': { ':enabled': true, ':seconds_valid': 70, ':method': 'Pleroma.Captcha.Kocaptcha' }}} - const updatedSettings = { ':pleroma': { 'Pleroma.Captcha': { ':seconds_valid': ['integer', 70] }}} - const description = [{ - children: [], - description: 'Captcha-related settings', - group: ':pleroma', - key: 'Pleroma.Captcha', - label: 'Pleroma.Captcha', - type: 'group' - }] - - const expectedData = { ':pleroma': { 'Pleroma.Captcha': { ':seconds_valid': ['integer', 70] }}} - const updatedData = checkPartialUpdate(settings, updatedSettings, description) - expect(_.isEqual(updatedData, expectedData)).toBeTruthy() - }) -}) diff --git a/test/views/settings/index.test.js b/test/views/settings/index.test.js index 9455dbb7..4cacf881 100644 --- a/test/views/settings/index.test.js +++ b/test/views/settings/index.test.js @@ -58,8 +58,6 @@ describe('Settings search', () => { wrapper.vm.handleSearchSelect({ group: ':media_proxy', key: ':ssl_options' }) expect(store.state.settings.activeTab).toBe('media-proxy') - wrapper.vm.handleSearchSelect({ group: ':opts', key: ':opts' }) - expect(store.state.settings.activeTab).toBe('auto-linker') done() }) })