From 11da7c9c7f05c3528137cf8c10f0b632fdb04370 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Thu, 30 Jul 2020 00:41:09 +0300 Subject: [PATCH 01/14] Fix link formatter tab issue --- src/views/settings/components/tabs.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/views/settings/components/tabs.js b/src/views/settings/components/tabs.js index 394f0670..f480a4a4 100644 --- a/src/views/settings/components/tabs.js +++ b/src/views/settings/components/tabs.js @@ -8,10 +8,6 @@ export const tabs = description => { label: 'settings.auth', settings: [':auth', ':ldap', ':oauth2', 'Pleroma.Web.Auth.Authenticator'] }, - 'auto-linker': { - label: 'settings.autoLinker', - settings: [':opts'] - }, 'esshd': { label: 'settings.esshd', settings: [':esshd'] @@ -40,6 +36,10 @@ export const tabs = description => { 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'] From 7f7a1813c9b60d756963623675ae7efaaa950b44 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 31 Jul 2020 19:30:39 +0300 Subject: [PATCH 02/14] Add :modules and Pleroma.Web.ApiSpec.CastAndValidate settings --- src/views/settings/components/MRF.vue | 3 --- src/views/settings/components/Other.vue | 20 ++++++++++++++++++++ src/views/settings/components/tabs.js | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/views/settings/components/MRF.vue b/src/views/settings/components/MRF.vue index ba2454a5..a7275d83 100644 --- a/src/views/settings/components/MRF.vue +++ b/src/views/settings/components/MRF.vue @@ -49,9 +49,6 @@ export default { loading() { return this.settings.loading }, - modules() { - return this.settings.description.find(setting => setting.key === ':modules') - }, mrfSettings() { return this.settings.description.filter(el => el.tab === 'mrf') } diff --git a/src/views/settings/components/Other.vue b/src/views/settings/components/Other.vue index 978b93e4..b1ee7369 100644 --- a/src/views/settings/components/Other.vue +++ b/src/views/settings/components/Other.vue @@ -7,6 +7,14 @@ + + + + + + + +
Submit
@@ -26,6 +34,12 @@ export default { ...mapGetters([ 'settings' ]), + castAndValidate() { + return this.settings.description.find(setting => setting.key === 'Pleroma.Web.ApiSpec.CastAndValidate') + }, + castAndValidateData() { + return _.get(this.settings.settings, [':pleroma', 'Pleroma.Web.ApiSpec.CastAndValidate']) || {} + }, isMobile() { return this.$store.state.app.device === 'mobile' }, @@ -56,6 +70,12 @@ export default { mimeTypesData() { return _.get(this.settings.settings, [':mime']) || {} }, + modules() { + return this.settings.description.find(setting => setting.key === ':modules') + }, + modulesData() { + return _.get(this.settings.settings, [':pleroma', ':modules']) || {} + }, remoteIp() { return this.settings.description.find(setting => setting.key === 'Pleroma.Plugs.RemoteIp') }, diff --git a/src/views/settings/components/tabs.js b/src/views/settings/components/tabs.js index f480a4a4..e7ff10c7 100644 --- a/src/views/settings/components/tabs.js +++ b/src/views/settings/components/tabs.js @@ -78,7 +78,7 @@ export const tabs = description => { }, 'other': { label: 'settings.other', - settings: [':mime', 'Pleroma.Plugs.RemoteIp'] + settings: [':mime', 'Pleroma.Plugs.RemoteIp', ':modules', 'Pleroma.Web.ApiSpec.CastAndValidate'] } } } From 198ac3e035a6ed0b7866c224d8a3b5c6c3d9df76 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 31 Jul 2020 19:44:39 +0300 Subject: [PATCH 03/14] Add Pools, Connections pools and Hackney pools settings on Job Queue tab --- src/views/settings/components/JobQueue.vue | 30 ++++++++++++++++++++++ src/views/settings/components/tabs.js | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/views/settings/components/JobQueue.vue b/src/views/settings/components/JobQueue.vue index a2c03349..63554eea 100644 --- a/src/views/settings/components/JobQueue.vue +++ b/src/views/settings/components/JobQueue.vue @@ -11,6 +11,18 @@ + + + + + + + + + + + +
Submit
@@ -36,6 +48,18 @@ export default { activityExpirationData() { return _.get(this.settings.settings, [':pleroma', 'Pleroma.ActivityExpiration']) || {} }, + connectionsPools() { + return this.settings.description.find(setting => setting.key === ':connections_pool') + }, + connectionsPoolsData() { + return _.get(this.settings.settings, [':pleroma', ':connections_pool']) || {} + }, + hackneyPools() { + return this.settings.description.find(setting => setting.key === ':hackney_pools') + }, + hackneyPoolsData() { + return _.get(this.settings.settings, [':pleroma', ':hackney_pools']) || {} + }, isMobile() { return this.$store.state.app.device === 'mobile' }, @@ -66,6 +90,12 @@ export default { obanQueuesData() { return _.get(this.settings.settings, [':pleroma', 'Oban']) || {} }, + pools() { + return this.settings.description.find(setting => setting.key === ':pools') + }, + poolsData() { + return _.get(this.settings.settings, [':pleroma', ':pools']) || {} + }, workers() { return this.settings.description.find(setting => setting.key === ':workers') }, diff --git a/src/views/settings/components/tabs.js b/src/views/settings/components/tabs.js index e7ff10c7..d58b2d1a 100644 --- a/src/views/settings/components/tabs.js +++ b/src/views/settings/components/tabs.js @@ -34,7 +34,7 @@ export const tabs = description => { }, 'job-queue': { label: 'settings.jobQueue', - settings: ['Pleroma.ActivityExpiration', 'Oban', ':workers'] + settings: ['Pleroma.ActivityExpiration', ':connections_pool', ':hackney_pools', 'Oban', ':pools', ':workers'] }, 'link-formatter': { label: 'settings.linkFormatter', From b60cd7635035808e086e3bb78f15faa5a7bb192e Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 31 Jul 2020 20:10:44 +0300 Subject: [PATCH 04/14] Add :restrict_unauthenticated setting on Authentication tab --- src/views/settings/components/Authentication.vue | 12 +++++++++++- src/views/settings/components/tabs.js | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/views/settings/components/Authentication.vue b/src/views/settings/components/Authentication.vue index 8ad33f88..3e919c11 100644 --- a/src/views/settings/components/Authentication.vue +++ b/src/views/settings/components/Authentication.vue @@ -11,10 +11,14 @@ - + + + + +
Submit
@@ -81,6 +85,12 @@ export default { }, pleromaAuthenticatorData() { return _.get(this.settings.settings, [':pleroma', 'Pleroma.Web.Auth.Authenticator']) || {} + }, + restrictUnauthenticated() { + return this.settings.description.find(setting => setting.key === ':restrict_unauthenticated') + }, + restrictUnauthenticatedData() { + return _.get(this.settings.settings, [':pleroma', ':restrict_unauthenticated']) || {} } }, methods: { diff --git a/src/views/settings/components/tabs.js b/src/views/settings/components/tabs.js index d58b2d1a..9a5f9b4e 100644 --- a/src/views/settings/components/tabs.js +++ b/src/views/settings/components/tabs.js @@ -6,7 +6,7 @@ export const tabs = description => { }, 'authentication': { label: 'settings.auth', - settings: [':auth', ':ldap', ':oauth2', 'Pleroma.Web.Auth.Authenticator'] + settings: [':auth', ':ldap', ':oauth2', 'Pleroma.Web.Auth.Authenticator', ':restrict_unauthenticated'] }, 'esshd': { label: 'settings.esshd', From c12d3c0451864154967b991e8b1edf0a3f8e26d4 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 31 Jul 2020 23:29:16 +0300 Subject: [PATCH 05/14] Add favicons and welcome messages settings on Instance tab --- src/views/settings/components/Instance.vue | 22 +++++++++++++++++++++- src/views/settings/components/tabs.js | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/views/settings/components/Instance.vue b/src/views/settings/components/Instance.vue index 245d53d8..362393fe 100644 --- a/src/views/settings/components/Instance.vue +++ b/src/views/settings/components/Instance.vue @@ -8,6 +8,10 @@ + + + + @@ -20,6 +24,10 @@ + + + + @@ -27,7 +35,7 @@ - + @@ -58,6 +66,12 @@ export default { adminTokenData() { return _.get(this.settings.settings, [':pleroma', ':admin_token']) || {} }, + favicons() { + return this.settings.description.find(setting => setting.key === ':instances_favicons') + }, + faviconsData() { + return _.get(this.settings.settings, [':pleroma', ':instances_favicons']) || {} + }, feed() { return this.settings.description.find(setting => setting.key === ':feed') }, @@ -123,6 +137,12 @@ export default { }, uriSchemesData() { return _.get(this.settings.settings, [':pleroma', ':uri_schemes']) || {} + }, + welcome() { + return this.settings.description.find(setting => setting.key === ':welcome') + }, + welcomeData() { + return _.get(this.settings.settings, [':pleroma', ':welcome']) || {} } }, methods: { diff --git a/src/views/settings/components/tabs.js b/src/views/settings/components/tabs.js index 9a5f9b4e..24f03b6f 100644 --- a/src/views/settings/components/tabs.js +++ b/src/views/settings/components/tabs.js @@ -30,7 +30,7 @@ export const tabs = description => { }, 'instance': { label: 'settings.instance', - settings: [':admin_token', ':instance', ':manifest', 'Pleroma.User', 'Pleroma.ScheduledActivity', ':uri_schemes', ':feed', ':streamer'] + settings: [':admin_token', ':instance', ':instances_favicons', ':welcome', ':manifest', 'Pleroma.User', 'Pleroma.ScheduledActivity', ':uri_schemes', ':feed', ':streamer'] }, 'job-queue': { label: 'settings.jobQueue', From 54c8c2ddebc9ce71e081a2aa3baf9bb72a0cfec4 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sun, 2 Aug 2020 03:21:39 +0300 Subject: [PATCH 06/14] Add special input for Sender setting in Welcome setting group --- src/views/settings/components/Inputs.vue | 6 ++ .../inputComponents/SenderInput.vue | 98 +++++++++++++++++++ src/views/settings/styles/main.scss | 13 +++ 3 files changed, 117 insertions(+) create mode 100644 src/views/settings/components/inputComponents/SenderInput.vue diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index 0639994e..d6a1a475 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -112,6 +112,7 @@ + @@ -138,6 +139,7 @@ import { RateLimitInput, RegInvitesInput, SelectInputWithReducedLabels, + SenderInput, SpecificMultipleSelect } from './inputComponents' import { getBooleanValue, processNested } from '@/store/modules/normalizers' import _ from 'lodash' @@ -156,6 +158,7 @@ export default { RateLimitInput, RegInvitesInput, SelectInputWithReducedLabels, + SenderInput, SpecificMultipleSelect }, props: { @@ -357,6 +360,9 @@ export default { renderSingleSelect(type) { return !this.reducedSelects && (type === 'module' || (type.includes('atom') && type.includes('dropdown'))) }, + senderInput({ key, type }) { + return Array.isArray(type) && type.includes('string') && type.includes('tuple') && key === ':sender' + }, update(value, group, key, parents, input, type, nested) { const updatedValue = this.renderSingleSelect(type) ? getBooleanValue(value) : value nested diff --git a/src/views/settings/components/inputComponents/SenderInput.vue b/src/views/settings/components/inputComponents/SenderInput.vue new file mode 100644 index 00000000..3e303c8a --- /dev/null +++ b/src/views/settings/components/inputComponents/SenderInput.vue @@ -0,0 +1,98 @@ + + + + + diff --git a/src/views/settings/styles/main.scss b/src/views/settings/styles/main.scss index ce6712ae..383761cf 100644 --- a/src/views/settings/styles/main.scss +++ b/src/views/settings/styles/main.scss @@ -46,6 +46,10 @@ .el-tabs__header { z-index: 2002; } + .email-address-input { + width: 50%; + margin-right: 10px; + } .esshd-list { margin: 0; } @@ -175,6 +179,9 @@ width: 30%; margin-right: 8px } + .nickname-input { + width: 50%; + } .no-top-margin { margin-top: 0; p { @@ -254,6 +261,12 @@ margin-left: 8px; margin-right: 10px } + .sender-input { + display: flex; + align-items: center; + margin-bottom: 10px; + width: 100%; + } .scale-input { width: 47%; margin: 0 1% 5px 0 From 3d1087986f34b12bfe42283774b5a621de3b1262 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 3 Aug 2020 21:12:13 +0300 Subject: [PATCH 07/14] Add parsing Sender settings value --- src/store/modules/normalizers.js | 37 ++++++++++++------- .../components/inputComponents/index.js | 1 + 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index c7fc33e8..14561c9f 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -89,8 +89,8 @@ export const parseTuples = (tuples, key) => { }, []) } else if (item.tuple[0] === ':prune') { accum[item.tuple[0]] = item.tuple[1] === ':disabled' ? [item.tuple[1]] : item.tuple[1].tuple - } else if (item.tuple[0] === ':proxy_url') { - accum[item.tuple[0]] = parseProxyUrl(item.tuple[1]) + } else if (item.tuple[0] === ':proxy_url' || item.tuple[0] === ':sender') { + accum[item.tuple[0]] = parseStringOrTupleValue(item.tuple[0], item.tuple[1]) } else if (item.tuple[0] === ':args') { accum[item.tuple[0]] = parseNonTuples(item.tuple[0], item.tuple[1]) } else if (Array.isArray(item.tuple[1]) && @@ -122,18 +122,29 @@ const parseObject = object => { }, {}) } -const parseProxyUrl = value => { - if (value && !Array.isArray(value) && - typeof value === 'object' && - value.tuple.length === 3 && - value.tuple[0] === ':socks5') { - const [, host, port] = value.tuple - return { socks5: true, host, port } - } else if (typeof value === 'string') { - const [host, port] = value.split(':') - return { socks5: false, host, port } +const parseStringOrTupleValue = (key, value) => { + if (key === ':proxy_url') { + if (value && !Array.isArray(value) && + typeof value === 'object' && + value.tuple.length === 3 && + value.tuple[0] === ':socks5') { + const [, host, port] = value.tuple + return { socks5: true, host, port } + } else if (typeof value === 'string') { + const [host, port] = value.split(':') + return { socks5: false, host, port } + } + return { socks5: false, host: null, port: null } + } else if (key === ':sender') { + if (typeof value === 'string') { + return { email: value } + } else if (value && + typeof value === 'object' && + value.tuple.length === 2) { + const [nickname, email] = value.tuple + return { nickname, email } + } } - return { socks5: false, host: null, port: null } } const prependWithСolon = (type, value) => { diff --git a/src/views/settings/components/inputComponents/index.js b/src/views/settings/components/inputComponents/index.js index 0ef58841..a5a9a7f1 100644 --- a/src/views/settings/components/inputComponents/index.js +++ b/src/views/settings/components/inputComponents/index.js @@ -8,4 +8,5 @@ export { default as PruneInput } from './PruneInput' export { default as RateLimitInput } from './RateLimitInput' export { default as RegInvitesInput } from './RegInvitesInput' export { default as SelectInputWithReducedLabels } from './SelectInputWithReducedLabels' +export { default as SenderInput } from './SenderInput' export { default as SpecificMultipleSelect } from './SpecificMultipleSelect' From 659adbe6d73a52ae272d69ebfbcc20c6e50d3198 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 3 Aug 2020 21:41:25 +0300 Subject: [PATCH 08/14] Add test for parsing sender setting in :welcome group --- test/modules/normalizers/parseTuples.test.js | 68 ++++++++++++-------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/test/modules/normalizers/parseTuples.test.js b/test/modules/normalizers/parseTuples.test.js index 9cbe9d2f..a918c618 100644 --- a/test/modules/normalizers/parseTuples.test.js +++ b/test/modules/normalizers/parseTuples.test.js @@ -223,10 +223,10 @@ describe('Parse tuples', () => { }) it('parses match_actor setting in mrf_subchain group', () => { - const tuples = [{ tuple: [":match_actor", - { '~r/https:\/\/example.com/s': ["Elixir.Pleroma.Web.ActivityPub.MRF.DropPolicy"]}]}] - const expectedResult = { ":match_actor": - [{ '~r/https:\/\/example.com/s': { value: ["Elixir.Pleroma.Web.ActivityPub.MRF.DropPolicy"] }}]} + const tuples = [{ tuple: [':match_actor', + { '~r/https:\/\/example.com/s': ['Elixir.Pleroma.Web.ActivityPub.MRF.DropPolicy']}]}] + const expectedResult = { ':match_actor': + [{ '~r/https:\/\/example.com/s': { value: ['Elixir.Pleroma.Web.ActivityPub.MRF.DropPolicy'] }}]} const parsed = parseTuples(tuples, ':mrf_subchain') @@ -241,7 +241,7 @@ describe('Parse tuples', () => { }) it('parses options setting in MediaProxy.Invalidation.Http group', () => { - const tuples = [{ tuple: [":options", [{ tuple: [":params", { xxx: "zzz", aaa: "bbb" }]}]]}] + const tuples = [{ tuple: [':options', [{ tuple: [':params', { xxx: 'zzz', aaa: 'bbb' }]}]]}] const expectedResult = { ':options': { ':params': [ { xxx: { value: 'zzz' }}, { aaa: { value: 'bbb' }}] }} @@ -260,14 +260,30 @@ describe('Parse tuples', () => { expect(_.isEqual(expectedResult, parsed)).toBeTruthy() }) - it('parses proxy_url', () => { - const proxyUrlNull = [{ tuple: [":proxy_url", null] }] - const proxyUrlTuple = [{ tuple: [":proxy_url", { tuple: [":socks5", ":localhost", 3090] }]}] - const proxyUrlString = [{ tuple: [":proxy_url", 'localhost:9020'] }] + it('parses sender setting in :welcome', () => { + const senderEmpty = [{ tuple: [':sender', ''] }] + const senderTuple = [{ tuple: [':sender', { tuple: ['test', 'test@email.com'] }]}] + const senderString = [{ tuple: [':sender', 'test@email.com'] }] - const expectedProxyUrlNull = { ":proxy_url": { socks5: false, host: null, port: null }} - const expectedProxyUrlTuple = { ":proxy_url": { socks5: true, host: ":localhost", port: 3090 }} - const expectedProxyUrlString = { ":proxy_url": { socks5: false, host: 'localhost', port: '9020' }} + const expectedSenderEmpty = { ':sender': { email: '' }} + const expectedSenderTuple = { ':sender': { email: 'test@email.com', nickname: 'test' }} + const expectedSenderString = { ':sender': { email: 'test@email.com' }} + + console.log(parseTuples(senderEmpty, ':welcome')) + + expect(_.isEqual(expectedSenderEmpty, parseTuples(senderEmpty, ':welcome'))).toBeTruthy() + expect(_.isEqual(expectedSenderTuple, parseTuples(senderTuple, ':welcome'))).toBeTruthy() + expect(_.isEqual(expectedSenderString, parseTuples(senderString, ':welcome'))).toBeTruthy() + }) + + it('parses proxy_url', () => { + const proxyUrlNull = [{ tuple: [':proxy_url', null] }] + const proxyUrlTuple = [{ tuple: [':proxy_url', { tuple: [':socks5', ':localhost', 3090] }]}] + const proxyUrlString = [{ tuple: [':proxy_url', 'localhost:9020'] }] + + const expectedProxyUrlNull = { ':proxy_url': { socks5: false, host: null, port: null }} + const expectedProxyUrlTuple = { ':proxy_url': { socks5: true, host: ':localhost', port: 3090 }} + const expectedProxyUrlString = { ':proxy_url': { socks5: false, host: 'localhost', port: '9020' }} expect(_.isEqual(expectedProxyUrlNull, parseTuples(proxyUrlNull, ':http'))).toBeTruthy() expect(_.isEqual(expectedProxyUrlTuple, parseTuples(proxyUrlTuple, ':http'))).toBeTruthy() @@ -275,8 +291,8 @@ describe('Parse tuples', () => { }) it('parses args setting in Pleroma.Upload.Filter.Mogrify', () => { - const tuples = [{ tuple: [":args", ["strip", { tuple: ["implode", "1"] }]]}] - const expectedResult = { ":args": ["strip", "implode"] } + const tuples = [{ tuple: [':args', ['strip', { tuple: ['implode', '1'] }]]}] + const expectedResult = { ':args': ['strip', 'implode'] } const result = parseTuples(tuples, 'Pleroma.Upload.Filter.Mogrify') expect(_.isEqual(expectedResult, result)).toBeTruthy() @@ -284,19 +300,19 @@ describe('Parse tuples', () => { it('parses nested tuples', () => { const tuples = [{ tuple: [':proxy_opts', [ - { tuple: [":redirect_on_failure", false] }, - { tuple: [":max_body_length", 26214400] }, - { tuple: [":http", [ - { tuple: [":follow_redirect", true] }, - { tuple: [":pool", ":media"] } + { tuple: [':redirect_on_failure', false] }, + { tuple: [':max_body_length', 26214400] }, + { tuple: [':http', [ + { tuple: [':follow_redirect', true] }, + { tuple: [':pool', ':media'] } ]]}, ]]}] const expectedResult = { ':proxy_opts': { - ":redirect_on_failure": false, - ":max_body_length": 26214400, - ":http": { - ":follow_redirect": true, - ":pool": ":media" + ':redirect_on_failure': false, + ':max_body_length': 26214400, + ':http': { + ':follow_redirect': true, + ':pool': ':media' } }} const result = parseTuples(tuples, ':media_proxy') @@ -304,8 +320,8 @@ describe('Parse tuples', () => { }) it('parses tuples with arrays', () => { - const tuples = [{ tuple: [":ignore_hosts", []]}, { tuple: [":ignore_tld", ["local", "localdomain", "lan"]]}] - const expectedResult = { ":ignore_hosts": [], ":ignore_tld": ["local", "localdomain", "lan"] } + const tuples = [{ tuple: [':ignore_hosts', []]}, { tuple: [':ignore_tld', ['local', 'localdomain', 'lan']]}] + const expectedResult = { ':ignore_hosts': [], ':ignore_tld': ['local', 'localdomain', 'lan'] } const result = parseTuples(tuples, ':rich_media') expect(_.isEqual(expectedResult, result)).toBeTruthy() From 8e1825ae1a68a64fbdb5021fb0b9c5f0607d51f7 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 3 Aug 2020 22:31:53 +0300 Subject: [PATCH 09/14] Fix parsing and wrapping tuple values in Args setting inside Pleroma.Upload.Filter.Mogrify --- src/store/modules/normalizers.js | 14 +------------- .../inputComponents/SpecificMultipleSelect.vue | 8 +++++--- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index 14561c9f..3ca63ca2 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -50,12 +50,7 @@ export const parseNonTuples = (key, value) => { return updated } if (key === ':args') { - if (typeof value === 'string') { - return [value] - } - const index = value.findIndex(el => typeof el === 'object' && el.tuple.includes('implode')) - const updated = value.map((el, i) => i === index ? 'implode' : el) - return updated + return typeof value === 'string' ? [value] : value } return value } @@ -259,13 +254,6 @@ const wrapValues = (settings, currentState) => { } else if (setting === ':ip') { const ip = value.split('.').map(s => parseInt(s, 10)) return { 'tuple': [setting, { 'tuple': ip }] } - } else if (setting === ':args') { - const index = value.findIndex(el => el === 'implode') - const updatedArray = value.slice() - if (index !== -1) { - updatedArray[index] = { 'tuple': ['implode', '1'] } - } - return { 'tuple': [setting, updatedArray] } } else { return { 'tuple': [setting, value] } } diff --git a/src/views/settings/components/inputComponents/SpecificMultipleSelect.vue b/src/views/settings/components/inputComponents/SpecificMultipleSelect.vue index 06f06436..a9fb60eb 100644 --- a/src/views/settings/components/inputComponents/SpecificMultipleSelect.vue +++ b/src/views/settings/components/inputComponents/SpecificMultipleSelect.vue @@ -20,9 +20,11 @@ allow-create class="input" @change="updateSetting($event, settingGroup.group, settingGroup.key, setting.key, setting.type)"> - - - + + + + + From 3b4abed18b9ff578fd0fdc8200e5338062e607a3 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Tue, 4 Aug 2020 00:57:17 +0300 Subject: [PATCH 10/14] Fix tests for args setting in Pleroma.Upload.Filter.Mogrify --- test/modules/normalizers/parseTuples.test.js | 6 ++---- test/modules/normalizers/wrapUpdatedSettings.test.js | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/test/modules/normalizers/parseTuples.test.js b/test/modules/normalizers/parseTuples.test.js index a918c618..ff039135 100644 --- a/test/modules/normalizers/parseTuples.test.js +++ b/test/modules/normalizers/parseTuples.test.js @@ -269,8 +269,6 @@ describe('Parse tuples', () => { const expectedSenderTuple = { ':sender': { email: 'test@email.com', nickname: 'test' }} const expectedSenderString = { ':sender': { email: 'test@email.com' }} - console.log(parseTuples(senderEmpty, ':welcome')) - expect(_.isEqual(expectedSenderEmpty, parseTuples(senderEmpty, ':welcome'))).toBeTruthy() expect(_.isEqual(expectedSenderTuple, parseTuples(senderTuple, ':welcome'))).toBeTruthy() expect(_.isEqual(expectedSenderString, parseTuples(senderString, ':welcome'))).toBeTruthy() @@ -291,8 +289,8 @@ describe('Parse tuples', () => { }) it('parses args setting in Pleroma.Upload.Filter.Mogrify', () => { - const tuples = [{ tuple: [':args', ['strip', { tuple: ['implode', '1'] }]]}] - const expectedResult = { ':args': ['strip', 'implode'] } + const tuples = [{ tuple: [':args', ['strip', '{ "implode", "1" }']]}] + const expectedResult = { ':args': ['strip', '{ "implode", "1" }'] } const result = parseTuples(tuples, 'Pleroma.Upload.Filter.Mogrify') expect(_.isEqual(expectedResult, result)).toBeTruthy() diff --git a/test/modules/normalizers/wrapUpdatedSettings.test.js b/test/modules/normalizers/wrapUpdatedSettings.test.js index dedb5c34..78f8ee6e 100644 --- a/test/modules/normalizers/wrapUpdatedSettings.test.js +++ b/test/modules/normalizers/wrapUpdatedSettings.test.js @@ -357,14 +357,14 @@ describe('Wrap settings', () => { it('wraps args setting in Pleroma.Upload.Filter.Mogrify group', () => { const settings = { 'Pleroma.Upload.Filter.Mogrify': { ':args': [ ['string', ['list', 'string'], ['list', 'tuple']], - ['strip', 'implode'] + ['strip', '{ "implode", "1"]}'] ]}} const state = { ':pleroma': { 'Pleroma.Upload.Filter.Mogrify': {}}} const result = wrapUpdatedSettings(':pleroma', settings, state) const expectedResult = [{ group: ':pleroma', key: 'Pleroma.Upload.Filter.Mogrify', - value: [{tuple: [':args', ['strip', {tuple: ['implode', '1']}]]}] + value: [{tuple: [':args', ['strip', '{ "implode", "1"]}']]}] }] expect(_.isEqual(result, expectedResult)).toBeTruthy() From b36676169afcb5dcebad109a1050f9bb11351574 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Tue, 4 Aug 2020 01:10:13 +0300 Subject: [PATCH 11/14] Update Changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 116b247e..f9857d58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Add ability to disable multi-factor authentication for a user - Add ability to manually evict and ban URLs from the Pleroma MediaProxy cache - Add Invalidation settings on MediaProxy tab -- Ability to configure S3 settings on Upload tab +- Ability to configure S3 settings on Upload tab, Pleroma.Web.ApiSpec.CastAndValidate and :modules settings on Other tab, Pools, Connections pools and Hackney pools settings on Job Queue tab, :restrict_unauthenticated settings on Authentication tab, :favicons and :welcome settings on Instance tab - Show number of open reports in Sidebar Menu - Add confirmation message when deleting a user @@ -31,7 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - When rendering user's profile, statuses, reports and notes check if required properties exist - Remove ability to moderate users that don't have valid nickname - Displays both labels and description in the header of group of settiings -- Ability to add custom values in Pleroma.Upload.Filter.Mogrify setting +- Ability to add custom values in Pleroma.Upload.Filter.Mogrify setting in the following format: '{"implode", "1"}' - Change types of the following settings: ':groups', ':replace', ':federated_timeline_removal', ':reject', ':match_actor'. Update functions that parses and wraps settings data according to this change. - Move rendering Crontab setting from a separate component to EditableKeyword component - Show only those MRF settings that have been enabled in MRF Policies setting From b9f1c93f65c45c16b1c548442e35fee8113a0964 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Tue, 4 Aug 2020 03:02:32 +0300 Subject: [PATCH 12/14] Add :frontends settings on Frontend tab --- CHANGELOG.md | 2 +- src/views/settings/components/Frontend.vue | 10 ++++++++++ src/views/settings/components/tabs.js | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9857d58..8cb6ac99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Add ability to disable multi-factor authentication for a user - Add ability to manually evict and ban URLs from the Pleroma MediaProxy cache - Add Invalidation settings on MediaProxy tab -- Ability to configure S3 settings on Upload tab, Pleroma.Web.ApiSpec.CastAndValidate and :modules settings on Other tab, Pools, Connections pools and Hackney pools settings on Job Queue tab, :restrict_unauthenticated settings on Authentication tab, :favicons and :welcome settings on Instance tab +- Ability to configure S3 settings on Upload tab, Pleroma.Web.ApiSpec.CastAndValidate and :modules settings on Other tab, Pools, Connections pools and Hackney pools settings on Job Queue tab, :restrict_unauthenticated settings on Authentication tab, :favicons and :welcome settings on Instance tab, :frontends settings on Frontend tab - Show number of open reports in Sidebar Menu - Add confirmation message when deleting a user diff --git a/src/views/settings/components/Frontend.vue b/src/views/settings/components/Frontend.vue index 15d29084..ec3675b8 100644 --- a/src/views/settings/components/Frontend.vue +++ b/src/views/settings/components/Frontend.vue @@ -8,6 +8,10 @@ + + + + @@ -66,6 +70,12 @@ export default { frontendData() { return _.get(this.settings.settings, [':pleroma', ':frontend_configurations']) || {} }, + frontends() { + return this.settings.description.find(setting => setting.key === ':frontends') + }, + frontendsData() { + return _.get(this.settings.settings, [':pleroma', ':frontends']) || {} + }, isMobile() { return this.$store.state.app.device === 'mobile' }, diff --git a/src/views/settings/components/tabs.js b/src/views/settings/components/tabs.js index 24f03b6f..011a16b8 100644 --- a/src/views/settings/components/tabs.js +++ b/src/views/settings/components/tabs.js @@ -18,7 +18,7 @@ export const tabs = description => { }, 'frontend': { label: 'settings.frontend', - settings: [':assets', ':chat', ':emoji', ':frontend_configurations', ':markup', ':static_fe'] + settings: [':assets', ':chat', ':frontends', ':emoji', ':frontend_configurations', ':markup', ':static_fe'] }, 'gopher': { label: 'settings.gopher', From e85d5123a549e869a871213a4a37c883fee0360a Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 7 Aug 2020 21:01:31 +0300 Subject: [PATCH 13/14] Fix rendering settings that have type ['string', 'image'] --- src/views/settings/components/Inputs.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index d6a1a475..b412c1e4 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -295,7 +295,7 @@ export default { return this.$store.state.settings.updatedSettings }, isImageUrl() { - return [':background', ':logo', ':nsfwCensorImage', ':default_user_avatar', ':instance_thumbnail'].includes(this.setting.key) + return Array.isArray(this.setting.type) && this.setting.type.includes('image') } }, methods: { From 1cdf3aa17a4ab949cccce5220fde56057f4ec0e8 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 7 Aug 2020 21:50:07 +0300 Subject: [PATCH 14/14] Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cb6ac99..2c8eb5cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Send `true` and `false` as booleans if they are values of single selects on the Settings page - Fix sorting users on Users page if there is an acount with missing nickname or ID +- Add new type of settings: `['string', 'image']`. Render Image upload Input depending on the type of setting, not its key ## [2.0.3] - 2020-04-29