Merge branch 'simplePolicy_reasons_for_instance_specific_policies' into 'develop'

Make MRF and Quarantine work with tuples

See merge request pleroma/admin-fe!187
This commit is contained in:
Haelwenn 2021-07-23 03:41:04 +00:00
commit a57925fce9
2 changed files with 25 additions and 4 deletions

View file

@ -78,14 +78,25 @@ export const parseTuples = (tuples, key) => {
item.tuple[0] === ':replace' || item.tuple[0] === ':replace' ||
item.tuple[0] === ':retries' || item.tuple[0] === ':retries' ||
(item.tuple[0] === ':headers' && key === 'Pleroma.Web.MediaProxy.Invalidation.Http') || (item.tuple[0] === ':headers' && key === 'Pleroma.Web.MediaProxy.Invalidation.Http') ||
item.tuple[0] === ':crontab')) { item.tuple[0] === ':crontab' ||
item.tuple[0] === ':transparency_exclusions' ||
item.tuple[0] === ':quarantined_instances' ||
key === ':mrf_simple')) {
if (item.tuple[0] === ':crontab') { if (item.tuple[0] === ':crontab') {
accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => { accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => {
return [...acc, { [group.tuple[1]]: { value: group.tuple[0], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] return [...acc, { [group.tuple[1]]: { value: group.tuple[0], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}]
}, []) }, [])
} else { } else {
accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => { accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => {
/**
* The ':quarantined_instances' and ':mrf_simple' settings have changed to a list of tuples instead of a list of strings.
* This is to have backwards compatibility for instances that still use strings.
*/
if (typeof group === 'string') {
return [...acc, group]
} else {
return [...acc, { [group.tuple[0]]: { value: group.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] return [...acc, { [group.tuple[0]]: { value: group.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}]
}
}, []) }, [])
} }
} else if (item.tuple[0] === ':icons') { } else if (item.tuple[0] === ':icons') {

View file

@ -87,7 +87,12 @@ export default {
return this.$store.state.app.device === 'desktop' return this.$store.state.app.device === 'desktop'
}, },
keyPlaceholder() { keyPlaceholder() {
return this.setting.key === ':replace' ? 'pattern' : 'key' /**
* We can get 'key_placeholder' from the Pleroma BE. This wasn't always the case.
* We check for the key ':replace' for backwards compatibility for older Pleroma instances who didn't send 'key_placeholder' yet.
* The ':replace' key was the only key where this was needed.
*/
return this.setting.key_placeholder ? this.setting.key_placeholder : (this.setting.key === ':replace' ? 'pattern' : 'key')
}, },
settings() { settings() {
return this.$store.state.settings.settings return this.$store.state.settings.settings
@ -96,7 +101,12 @@ export default {
return this.$store.state.settings.updatedSettings return this.$store.state.settings.updatedSettings
}, },
valuePlaceholder() { valuePlaceholder() {
return this.setting.key === ':replace' ? 'replacement' : 'value' /**
* We can get 'value_placeholder' from the Pleroma BE. This wasn't always the case.
* We check for the key ':replace' for backwards compatibility for older Pleroma instances who didn't send 'value_placeholder' yet.
* The ':replace' key was the only key where this was needed.
*/
return this.setting.value_placeholder ? this.setting.value_placeholder : (this.setting.key === ':replace' ? 'replacement' : 'value')
} }
}, },
methods: { methods: {