From e488e3f8524beae3977f972fba9e4f255ea26079 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sat, 25 Apr 2020 22:07:48 +0300 Subject: [PATCH] Reduce options and labels for Pleroma authenticator input --- src/views/settings/components/Inputs.vue | 9 +++-- .../inputComponents/RewritePolicyInput.vue | 39 ++++++++++++++----- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index e84e5a6f..a5181ed1 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -55,7 +55,7 @@ :data-search="setting.key || setting.group" @change="update($event, settingGroup.group, settingGroup.key, settingParent, setting.key, setting.type, nested)"/> - + @@ -253,6 +253,9 @@ export default { keywordData() { return Array.isArray(this.data) ? this.data : [] }, + reducedSelects() { + return [':rewrite_policy', 'Pleroma.Web.Auth.Authenticator'].includes(this.setting.key) + }, settings() { return this.$store.state.settings.settings }, diff --git a/src/views/settings/components/inputComponents/RewritePolicyInput.vue b/src/views/settings/components/inputComponents/RewritePolicyInput.vue index 587a4faa..d7af0a67 100644 --- a/src/views/settings/components/inputComponents/RewritePolicyInput.vue +++ b/src/views/settings/components/inputComponents/RewritePolicyInput.vue @@ -1,7 +1,7 @@ @@ -29,7 +31,7 @@ export default { name: 'RewritePolicyInput', props: { data: { - type: [String, Array], + type: [Array, Object], default: function() { return {} } @@ -52,10 +54,27 @@ export default { return this.$store.state.app.device === 'mobile' }, rewritePolicyValue() { - return typeof this.data === 'string' ? [this.data] : this.data + return typeof this.data[this.setting.key] === 'string' ? [this.data[this.setting.key]] : this.data[this.setting.key] } }, methods: { + authenticatorOptions(suggestions) { + return suggestions.map(element => { + const label = element.split('Pleroma.Web.Auth.')[1] + ? element.split('Pleroma.Web.Auth.')[1] + : element + return { value: element, label } + }) + }, + renderMultipleSelect(type) { + return Array.isArray(type) && this.setting.key !== ':backends' && this.setting.key !== ':args' && ( + type.includes('module') || + (type.includes('list') && type.includes('string')) || + (type.includes('list') && type.includes('atom')) || + (type.includes('regex') && type.includes('string')) || + this.setting.key === ':args' + ) + }, rewritePolicyOptions(suggestions) { return suggestions.map(element => { const label = element.split('Pleroma.Web.ActivityPub.MRF.')[1]