Hide unused section of settings based on what uploader is selected

This commit is contained in:
Angelina Filippova 2020-01-26 22:54:16 +03:00
parent 9f8112fe32
commit fb5bfca562
2 changed files with 18 additions and 4 deletions

View file

@ -95,6 +95,9 @@ const settings = {
if (key === 'Pleroma.Emails.Mailer' && input === ':adapter') {
const subkeys = Object.keys(state.settings[group][key]).filter(el => el !== ':adapter')
await removeSettings([{ group, key, delete: true, subkeys }], getters.authHost, getters.token)
} else if (key === 'Pleroma.Upload' && input === ':uploader') {
const deletedKey = value === 'Pleroma.Uploaders.Local' ? 'Pleroma.Uploaders.S3' : 'Pleroma.Uploaders.Local'
await removeSettings([{ group, key: deletedKey, delete: true }], getters.authHost, getters.token)
}
key
? commit('UPDATE_STATE', { group, key, input, value })

View file

@ -3,14 +3,17 @@
<el-form ref="uploadData" :model="uploadData" :label-width="labelWidth">
<setting :setting-group="upload" :data="uploadData"/>
</el-form>
<el-form ref="uploadersLocal" :model="uploadersLocalData" :label-width="labelWidth">
<el-form v-if="showUploadersLocal" ref="uploadersLocal" :model="uploadersLocalData" :label-width="labelWidth">
<el-form-item class="description-container description">
<span class="description"><p>Pleroma.Uploaders.Local</p></span>
</el-form-item>
<setting :setting-group="uploadersLocal" :data="uploadersLocalData"/>
</el-form>
<div class="line"/>
<el-form ref="uploadersS3" :model="uploadersS3Data" :label-width="labelWidth">
</el-form>
<el-form v-if="showUploadersS3" ref="uploadersS3" :model="uploadersS3Data" :label-width="labelWidth">
<setting :setting-group="uploadersS3" :data="uploadersS3Data"/>
</el-form>
<div class="line"/>
</el-form>
<el-form ref="uploadFilterMogrify" :model="uploadFilterMogrifyData" :label-width="labelWidth">
<setting :setting-group="uploadFilterMogrify" :data="uploadFilterMogrifyData"/>
</el-form>
@ -46,6 +49,14 @@ export default {
loading() {
return this.settings.loading
},
showUploadersS3() {
const uploader = _.get(this.settings.settings, [':pleroma', 'Pleroma.Upload', ':uploader'])
return uploader === 'Pleroma.Uploaders.S3'
},
showUploadersLocal() {
const uploader = _.get(this.settings.settings, [':pleroma', 'Pleroma.Upload', ':uploader'])
return uploader === 'Pleroma.Uploaders.Local'
},
upload() {
return this.settings.description.find(setting => setting.key === 'Pleroma.Upload')
},