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 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/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') }, diff --git a/src/views/settings/components/inputComponents/EditableKeywordInput.vue b/src/views/settings/components/inputComponents/EditableKeywordInput.vue index bc2bb65c..a6ecde4d 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, 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;