From d5168b5e8500286cfeace214a429ef6b6569314d Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Wed, 4 Mar 2020 19:46:31 +0300 Subject: [PATCH 1/4] Add Oban.Cron setting --- src/store/modules/normalizers.js | 18 ++++++++--- src/views/settings/components/Inputs.vue | 11 +++++-- .../inputComponents/EditableKeywordInput.vue | 31 ++++++++++++++----- src/views/settings/styles/main.scss | 10 ++++++ 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index 123847aa..8be6220d 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -80,7 +80,12 @@ export const parseTuples = (tuples, key) => { accum[item.tuple[0]] = item.tuple[1].reduce((acc, mascot) => { return [...acc, { [mascot.tuple[0]]: { ...mascot.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] }, []) - } else if (item.tuple[0] === ':groups' || item.tuple[0] === ':replace' || item.tuple[0] === ':retries') { + } else if ( + item.tuple[0] === ':groups' || + item.tuple[0] === ':replace' || + item.tuple[0] === ':retries' || + item.tuple[0] === ':crontab' + ) { accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => { return [...acc, { [group.tuple[0]]: { value: group.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] }, []) @@ -218,7 +223,12 @@ export const wrapUpdatedSettings = (group, settings, currentState) => { const wrapValues = (settings, currentState) => { return Object.keys(settings).map(setting => { const [type, value] = settings[setting] - if (type === 'keyword' || type.includes('keyword') || setting === ':replace') { + if ( + type === 'keyword' || + type.includes('keyword') || + type.includes('tuple') && type.includes('list') || + setting === ':replace' + ) { return { 'tuple': [setting, wrapValues(value, currentState)] } } else if (type === 'atom' && value.length > 0) { return { 'tuple': [setting, `:${value}`] } @@ -226,8 +236,8 @@ const wrapValues = (settings, currentState) => { return typeof value === 'string' ? { 'tuple': [setting, value] } : { 'tuple': [setting, { 'tuple': value }] } - } else if (type.includes('tuple') && type.includes('list')) { - return { 'tuple': [setting, value] } + } else if (type === 'reversed_tuple') { + return { 'tuple': [value, setting] } } else if (type === 'map') { const mapValue = Object.keys(value).reduce((acc, key) => { acc[key] = setting === ':match_actor' ? value[key] : value[key][1] diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index 581324d9..d99871b2 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -223,7 +223,11 @@ export default { } }, keywordData() { - return Array.isArray(this.data) ? this.data : [] + if (this.setting.key === ':crontab') { + return this.data[this.setting.key] || [] + } else { + return Array.isArray(this.data) ? this.data : [] + } }, rewritePolicyValue() { return typeof this.data[this.setting.key] === 'string' ? [this.data[this.setting.key]] : this.data[this.setting.key] @@ -238,9 +242,10 @@ export default { methods: { editableKeyword(key, type) { return key === ':replace' || - (Array.isArray(type) && type.includes('keyword') && type.includes('integer')) || type === 'map' || - (Array.isArray(type) && type.includes('keyword') && type.findIndex(el => el.includes('list') && el.includes('string')) !== -1) + (Array.isArray(type) && type.includes('keyword') && type.includes('integer')) || + (Array.isArray(type) && type.includes('keyword') && type.findIndex(el => el.includes('list') && el.includes('string')) !== -1) || + (Array.isArray(type) && type.includes('list') && type.includes('tuple')) }, getFormattedDescription(desc) { return marked(desc) diff --git a/src/views/settings/components/inputComponents/EditableKeywordInput.vue b/src/views/settings/components/inputComponents/EditableKeywordInput.vue index bc2bb65c..f86f600d 100644 --- a/src/views/settings/components/inputComponents/EditableKeywordInput.vue +++ b/src/views/settings/components/inputComponents/EditableKeywordInput.vue @@ -8,6 +8,14 @@ +
+
+ : + + +
+ +
: @@ -96,15 +104,24 @@ export default { this.updateSetting(updatedValue, this.settingGroup.group, this.settingGroup.key, this.setting.key, this.setting.type) }, updateSetting(value, group, key, input, type) { - const updatedSettings = type !== 'map' - ? value.reduce((acc, element) => { - return { ...acc, [Object.keys(element)[0]]: ['list', Object.values(element)[0].value] } - }, {}) - : value.reduce((acc, element) => { - return { ...acc, [Object.keys(element)[0]]: Object.values(element)[0].value } - }, {}) + const updatedSettings = this.wrapUpdatedSettings(value, group, key, input, type) this.$store.dispatch('UpdateSettings', { group, key, input, value: updatedSettings, type }) this.$store.dispatch('UpdateState', { group, key, input, value }) + }, + wrapUpdatedSettings(value, input, type) { + if (type === 'map') { + return value.reduce((acc, element) => { + return { ...acc, [Object.keys(element)[0]]: Object.values(element)[0].value } + }, {}) + } else if (input === ':crontab') { + return value.reduce((acc, element) => { + return { ...acc, [Object.values(element)[0].value]: ['reversed_tuple', Object.keys(element)[0]] } + }, {}) + } else { + return value.reduce((acc, element) => { + return { ...acc, [Object.keys(element)[0]]: ['list', Object.values(element)[0].value] } + }, {}) + } } } } diff --git a/src/views/settings/styles/main.scss b/src/views/settings/styles/main.scss index 5b68e0c6..fd8e69d2 100644 --- a/src/views/settings/styles/main.scss +++ b/src/views/settings/styles/main.scss @@ -14,6 +14,15 @@ font-family: monospace; padding: 0 3px 0 3px; } + .crontab-name-input { + width: 30%; + margin-left: 8px; + margin-right: 10px + } + .crontab-value-input { + width: 70%; + margin-right: 8px + } .delete-setting-button { margin-left: 5px; } @@ -325,6 +334,7 @@ margin-right: 10px } + @media only screen and (min-width: 1824px) { .submit-button-container { max-width: 1637px; From 08ed6630159ebcc2059ee0ea994ccefedd64d89e Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Thu, 5 Mar 2020 00:25:55 +0300 Subject: [PATCH 2/4] Fix wrapping updated settings in EditableKeywordInput --- .../components/inputComponents/EditableKeywordInput.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/settings/components/inputComponents/EditableKeywordInput.vue b/src/views/settings/components/inputComponents/EditableKeywordInput.vue index f86f600d..a6ecde4d 100644 --- a/src/views/settings/components/inputComponents/EditableKeywordInput.vue +++ b/src/views/settings/components/inputComponents/EditableKeywordInput.vue @@ -104,7 +104,7 @@ export default { this.updateSetting(updatedValue, this.settingGroup.group, this.settingGroup.key, this.setting.key, this.setting.type) }, updateSetting(value, group, key, input, type) { - const updatedSettings = this.wrapUpdatedSettings(value, group, key, input, type) + const updatedSettings = this.wrapUpdatedSettings(value, input, type) this.$store.dispatch('UpdateSettings', { group, key, input, value: updatedSettings, type }) this.$store.dispatch('UpdateState', { group, key, input, value }) }, From 19e2b296129a292d535b3722f51ed6bb786c02fc Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Thu, 5 Mar 2020 00:39:53 +0300 Subject: [PATCH 3/4] Add settings for notifications streamer --- src/views/settings/components/Instance.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/views/settings/components/Instance.vue b/src/views/settings/components/Instance.vue index f87c7736..a8698350 100644 --- a/src/views/settings/components/Instance.vue +++ b/src/views/settings/components/Instance.vue @@ -31,6 +31,9 @@ + + +
Submit
@@ -112,6 +115,12 @@ export default { scheduledActivityData() { return _.get(this.settings.settings, [':pleroma', 'Pleroma.ScheduledActivity']) || {} }, + streamer() { + return this.$store.state.settings.description.find(setting => setting.key === ':streamer') + }, + streamerData() { + return _.get(this.settings.settings, [':pleroma', ':streamer']) || {} + }, uriSchemes() { return this.settings.description.find(setting => setting.key === ':uri_schemes') }, From 39e3ab1c67c03ff125b84219929ca8a684d1e245 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Thu, 5 Mar 2020 02:13:00 +0300 Subject: [PATCH 4/4] Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdefcea9..07947ea5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - Ability to see local statuses in Statuses by instance section +- Ability to configure Oban.Cron settings and settings for notifications streamer ## [2.0] - 2020-02-27