Add allow-create, refactor getting prefixes and rename custom component

This commit is contained in:
Angelina Filippova 2020-04-27 02:34:40 +03:00
parent 4160a89c66
commit c94810994f
3 changed files with 21 additions and 46 deletions

View file

@ -67,7 +67,7 @@
:key="index"/>
</el-select>
<el-select
v-if="renderMultipleSelect(setting.type) && !reducedSelects"
v-if="!reducedSelects && renderMultipleSelect(setting.type)"
:value="inputValue"
:data-search="setting.key || setting.group"
multiple
@ -104,7 +104,7 @@
<prune-input v-if="setting.key === ':prune'" :data="data[setting.key]" :setting-group="settingGroup" :setting="setting"/>
<rate-limit-input v-if="settingGroup.key === ':rate_limit'" :data="data" :setting-group="settingGroup" :setting="setting"/>
<reg-invites-input v-if="[':registrations_open', ':invites_enabled'].includes(setting.key)" :data="data" :setting-group="settingGroup" :setting="setting"/>
<rewrite-policy-input v-if="reducedSelects" :data="data" :setting-group="settingGroup" :setting="setting"/>
<select-input-with-reduced-labels v-if="reducedSelects" :data="data" :setting-group="settingGroup" :setting="setting"/>
<!-------------------->
<el-tooltip v-if="canBeDeleted && isTablet" :content="$t('settings.removeFromDB')" placement="bottom-end" class="delete-setting-button-container">
<el-button icon="el-icon-delete" circle size="mini" class="delete-setting-button" @click="removeSetting"/>
@ -131,7 +131,7 @@ import {
PruneInput,
RateLimitInput,
RegInvitesInput,
RewritePolicyInput } from './inputComponents'
SelectInputWithReducedLabels } from './inputComponents'
import { processNested } from '@/store/modules/normalizers'
import _ from 'lodash'
import marked from 'marked'
@ -149,7 +149,7 @@ export default {
PruneInput,
RateLimitInput,
RegInvitesInput,
RewritePolicyInput
SelectInputWithReducedLabels
},
props: {
customLabelWidth: {

View file

@ -6,6 +6,7 @@
:data-search="setting.key"
multiple
filterable
allow-create
class="input"
@change="updateSetting($event, settingGroup.group, settingGroup.key, setting.key, setting.type)">
<el-option v-for="(option, index) in options(setting.suggestions)" :key="index" :value="option.value" :label="option.label" />
@ -28,7 +29,7 @@
<script>
export default {
name: 'RewritePolicyInput',
name: 'SelectInputWithReducedLabels',
props: {
data: {
type: [Array, Object],
@ -67,49 +68,23 @@ export default {
},
methods: {
options(suggestions) {
let prefix
switch (this.setting.key) {
case ':rewrite_policy':
prefix = 'Pleroma.Web.ActivityPub.MRF.'
break
case 'Pleroma.Web.Auth.Authenticator':
prefix = 'Pleroma.Web.Auth.'
break
case ':method':
prefix = 'Pleroma.Captcha.'
break
case ':adapter':
prefix = 'Swoosh.Adapters.'
break
case ':providers':
prefix = 'Pleroma.Web.Metadata.Providers.'
break
case ':parsers':
prefix = 'Pleroma.Web.RichMedia.Parsers.'
break
case ':ttl_setters':
prefix = 'Pleroma.Web.RichMedia.Parser.'
break
case ':scrub_policy':
prefix = 'Pleroma.HTML.'
break
case ':federation_publisher_modules':
prefix = 'Pleroma.Web.'
break
case ':uploader':
prefix = 'Pleroma.Uploaders.'
break
case ':filters':
prefix = 'Pleroma.Upload.Filter.'
break
default:
prefix = ''
const prefixes = {
':rewrite_policy': 'Pleroma.Web.ActivityPub.MRF.',
'Pleroma.Web.Auth.Authenticator': 'Pleroma.Web.Auth.',
':method': 'Pleroma.Captcha.',
':adapter': 'Swoosh.Adapters.',
':providers': 'Pleroma.Web.Metadata.Providers.',
':parsers': 'Pleroma.Web.RichMedia.Parsers.',
':ttl_setters': 'Pleroma.Web.RichMedia.Parser.',
':scrub_policy': 'Pleroma.HTML.',
':federation_publisher_modules': 'Pleroma.Web.',
':uploader': 'Pleroma.Uploaders.',
':filters': 'Pleroma.Upload.Filter.'
}
return suggestions.map(element => {
const label = element.split(prefix)[1]
? element.split(prefix)[1]
const label = element.split(prefixes[this.setting.key])[1]
? element.split(prefixes[this.setting.key])[1]
: element
return { value: element, label }
})

View file

@ -8,4 +8,4 @@ export { default as ProxyUrlInput } from './ProxyUrlInput'
export { default as PruneInput } from './PruneInput'
export { default as RateLimitInput } from './RateLimitInput'
export { default as RegInvitesInput } from './RegInvitesInput'
export { default as RewritePolicyInput } from './RewritePolicyInput'
export { default as SelectInputWithReducedLabels } from './SelectInputWithReducedLabels'