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"/> :key="index"/>
</el-select> </el-select>
<el-select <el-select
v-if="renderMultipleSelect(setting.type) && !reducedSelects" v-if="!reducedSelects && renderMultipleSelect(setting.type)"
:value="inputValue" :value="inputValue"
:data-search="setting.key || setting.group" :data-search="setting.key || setting.group"
multiple multiple
@ -104,7 +104,7 @@
<prune-input v-if="setting.key === ':prune'" :data="data[setting.key]" :setting-group="settingGroup" :setting="setting"/> <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"/> <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"/> <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-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"/> <el-button icon="el-icon-delete" circle size="mini" class="delete-setting-button" @click="removeSetting"/>
@ -131,7 +131,7 @@ import {
PruneInput, PruneInput,
RateLimitInput, RateLimitInput,
RegInvitesInput, RegInvitesInput,
RewritePolicyInput } from './inputComponents' SelectInputWithReducedLabels } from './inputComponents'
import { processNested } from '@/store/modules/normalizers' import { processNested } from '@/store/modules/normalizers'
import _ from 'lodash' import _ from 'lodash'
import marked from 'marked' import marked from 'marked'
@ -149,7 +149,7 @@ export default {
PruneInput, PruneInput,
RateLimitInput, RateLimitInput,
RegInvitesInput, RegInvitesInput,
RewritePolicyInput SelectInputWithReducedLabels
}, },
props: { props: {
customLabelWidth: { customLabelWidth: {

View file

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