Merge branch 'feature/update-mrf' into 'develop'

Show MRF settings that are enabled in MRF Policies setting

Closes #129 and #126

See merge request pleroma/admin-fe!145
This commit is contained in:
Angelina Filippova 2020-07-24 19:29:09 +00:00
commit 55eb374d36
4 changed files with 16 additions and 13 deletions

View file

@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- 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
- Show only those MRF settings that have been enabled in MRF Policies setting
### Fixed

View file

@ -276,7 +276,7 @@ export default {
':parsers',
':providers',
':method',
':rewrite_policy',
':policies',
'Pleroma.Web.Auth.Authenticator'
].includes(this.setting.key) ||
(this.settingGroup.key === 'Pleroma.Emails.Mailer' && this.setting.key === ':adapter')

View file

@ -1,10 +1,10 @@
<template>
<div v-if="!loading" :class="isSidebarOpen" class="form-container">
<div v-for="setting in mrfSettings" :key="setting.key">
<el-form :model="getSettingData(setting)" :label-position="labelPosition" :label-width="labelWidth">
<el-form v-if="showMrfPolicy(setting.key)" :model="getSettingData(setting)" :label-position="labelPosition" :label-width="labelWidth">
<setting :setting-group="setting" :data="getSettingData(setting)"/>
<el-divider v-if="setting" class="divider thick-line"/>
</el-form>
<el-divider v-if="setting" class="divider thick-line"/>
</div>
<div class="submit-button-container">
<el-button class="submit-button" type="primary" @click="onSubmit">Submit</el-button>
@ -70,6 +70,16 @@ export default {
type: 'success',
message: i18n.t('settings.success')
})
},
showMrfPolicy(key) {
const selectedMrfPolicies = _.get(this.settings.settings, [':pleroma', ':mrf', ':policies'])
const mappedPolicies = this.mrfSettings.reduce((acc, { key, related_policy }) => {
if (key !== ':mrf') {
acc[key] = related_policy
}
return acc
}, {})
return !Object.keys(mappedPolicies).includes(key) || selectedMrfPolicies.includes(mappedPolicies[key])
}
}
}

View file

@ -56,7 +56,7 @@ export default {
inputValue() {
if (this.setting.key === 'Pleroma.Web.Auth.Authenticator') {
return this.data.value
} else if (this.setting.key === ':rewrite_policy') {
} else if (this.setting.key === ':policies') {
return typeof this.data[this.setting.key] === 'string'
? [this.data[this.setting.key]]
: this.data[this.setting.key]
@ -71,7 +71,7 @@ export default {
methods: {
options(suggestions) {
const prefixes = {
':rewrite_policy': 'Pleroma.Web.ActivityPub.MRF.',
':policies': 'Pleroma.Web.ActivityPub.MRF.',
'Pleroma.Web.Auth.Authenticator': 'Pleroma.Web.Auth.',
':method': 'Pleroma.Captcha.',
':adapter': 'Swoosh.Adapters.',
@ -100,14 +100,6 @@ export default {
this.setting.key === ':args'
)
},
rewritePolicyOptions(suggestions) {
return suggestions.map(element => {
const label = element.split('Pleroma.Web.ActivityPub.MRF.')[1]
? element.split('Pleroma.Web.ActivityPub.MRF.')[1]
: element
return { value: element, label }
})
},
updateSetting(value, group, key, input, type) {
const updatedValue = getBooleanValue(value)
this.$store.dispatch('UpdateSettings', { group, key, input, value: updatedValue, type })