forked from AkkomaGang/admin-fe
Merge branch 'fix/log-level-value' into 'develop'
Fix sending booleans as values of single selects Closes #109 See merge request pleroma/admin-fe!128
This commit is contained in:
commit
3bedf77b44
5 changed files with 32 additions and 20 deletions
|
@ -1,5 +1,14 @@
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
|
||||||
|
export const getBooleanValue = value => {
|
||||||
|
if (value === 'true') {
|
||||||
|
return true
|
||||||
|
} else if (value === 'false') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
export const checkPartialUpdate = (settings, updatedSettings, description) => {
|
export const checkPartialUpdate = (settings, updatedSettings, description) => {
|
||||||
return Object.keys(updatedSettings).reduce((acc, group) => {
|
return Object.keys(updatedSettings).reduce((acc, group) => {
|
||||||
acc[group] = Object.keys(updatedSettings[group]).reduce((acc, key) => {
|
acc[group] = Object.keys(updatedSettings[group]).reduce((acc, key) => {
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
:data-search="setting.key || setting.group"
|
:data-search="setting.key || setting.group"
|
||||||
@change="update($event, settingGroup.group, settingGroup.key, settingParent, setting.key, setting.type, nested)"/>
|
@change="update($event, settingGroup.group, settingGroup.key, settingParent, setting.key, setting.type, nested)"/>
|
||||||
<el-select
|
<el-select
|
||||||
v-if="!reducedSelects && (setting.type === 'module' || (setting.type.includes('atom') && setting.type.includes('dropdown')))"
|
v-if="renderSingleSelect(setting.type)"
|
||||||
:value="inputValue === false ? 'false' : inputValue"
|
:value="inputValue === false ? 'false' : inputValue"
|
||||||
:data-search="setting.key || setting.group"
|
:data-search="setting.key || setting.group"
|
||||||
clearable
|
clearable
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
:key="index"/>
|
:key="index"/>
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-select
|
<el-select
|
||||||
v-if="!reducedSelects && renderMultipleSelect(setting.type)"
|
v-if="renderMultipleSelect(setting.type)"
|
||||||
:value="inputValue"
|
:value="inputValue"
|
||||||
:data-search="setting.key || setting.group"
|
:data-search="setting.key || setting.group"
|
||||||
multiple
|
multiple
|
||||||
|
@ -99,12 +99,12 @@
|
||||||
<editable-keyword-input v-if="editableKeyword(setting.key, setting.type)" :data="keywordData" :setting-group="settingGroup" :setting="setting"/>
|
<editable-keyword-input v-if="editableKeyword(setting.key, setting.type)" :data="keywordData" :setting-group="settingGroup" :setting="setting"/>
|
||||||
<icons-input v-if="setting.key === ':icons'" :data="iconsData" :setting-group="settingGroup" :setting="setting"/>
|
<icons-input v-if="setting.key === ':icons'" :data="iconsData" :setting-group="settingGroup" :setting="setting"/>
|
||||||
<mascots-input v-if="setting.key === ':mascots'" :data="keywordData" :setting-group="settingGroup" :setting="setting"/>
|
<mascots-input v-if="setting.key === ':mascots'" :data="keywordData" :setting-group="settingGroup" :setting="setting"/>
|
||||||
<multiple-select v-if="setting.key === ':backends' || setting.key === ':args'" :data="data" :setting-group="settingGroup" :setting="setting"/>
|
|
||||||
<proxy-url-input v-if="setting.key === ':proxy_url'" :data="data[setting.key]" :setting-group="settingGroup" :setting="setting" :parents="settingParent"/>
|
<proxy-url-input v-if="setting.key === ':proxy_url'" :data="data[setting.key]" :setting-group="settingGroup" :setting="setting" :parents="settingParent"/>
|
||||||
<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"/>
|
||||||
<select-input-with-reduced-labels 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"/>
|
||||||
|
<specific-multiple-select v-if="setting.key === ':backends' || setting.key === ':args'" :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"/>
|
||||||
|
@ -126,13 +126,13 @@ import {
|
||||||
EditableKeywordInput,
|
EditableKeywordInput,
|
||||||
IconsInput,
|
IconsInput,
|
||||||
MascotsInput,
|
MascotsInput,
|
||||||
MultipleSelect,
|
|
||||||
ProxyUrlInput,
|
ProxyUrlInput,
|
||||||
PruneInput,
|
PruneInput,
|
||||||
RateLimitInput,
|
RateLimitInput,
|
||||||
RegInvitesInput,
|
RegInvitesInput,
|
||||||
SelectInputWithReducedLabels } from './inputComponents'
|
SelectInputWithReducedLabels,
|
||||||
import { processNested } from '@/store/modules/normalizers'
|
SpecificMultipleSelect } from './inputComponents'
|
||||||
|
import { getBooleanValue, processNested } from '@/store/modules/normalizers'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import marked from 'marked'
|
import marked from 'marked'
|
||||||
|
|
||||||
|
@ -144,12 +144,12 @@ export default {
|
||||||
EditableKeywordInput,
|
EditableKeywordInput,
|
||||||
IconsInput,
|
IconsInput,
|
||||||
MascotsInput,
|
MascotsInput,
|
||||||
MultipleSelect,
|
|
||||||
ProxyUrlInput,
|
ProxyUrlInput,
|
||||||
PruneInput,
|
PruneInput,
|
||||||
RateLimitInput,
|
RateLimitInput,
|
||||||
RegInvitesInput,
|
RegInvitesInput,
|
||||||
SelectInputWithReducedLabels
|
SelectInputWithReducedLabels,
|
||||||
|
SpecificMultipleSelect
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
customLabelWidth: {
|
customLabelWidth: {
|
||||||
|
@ -323,7 +323,7 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
renderMultipleSelect(type) {
|
renderMultipleSelect(type) {
|
||||||
return Array.isArray(type) && this.setting.key !== ':backends' && this.setting.key !== ':args' && (
|
return !this.reducedSelects && Array.isArray(type) && this.setting.key !== ':backends' && this.setting.key !== ':args' && (
|
||||||
type.includes('module') ||
|
type.includes('module') ||
|
||||||
(type.includes('list') && type.includes('string')) ||
|
(type.includes('list') && type.includes('string')) ||
|
||||||
(type.includes('list') && type.includes('atom')) ||
|
(type.includes('list') && type.includes('atom')) ||
|
||||||
|
@ -331,10 +331,14 @@ export default {
|
||||||
this.setting.key === ':args'
|
this.setting.key === ':args'
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
renderSingleSelect(type) {
|
||||||
|
return !this.reducedSelects && (type === 'module' || (type.includes('atom') && type.includes('dropdown')))
|
||||||
|
},
|
||||||
update(value, group, key, parents, input, type, nested) {
|
update(value, group, key, parents, input, type, nested) {
|
||||||
|
const updatedValue = this.renderSingleSelect(type) ? getBooleanValue(value) : value
|
||||||
nested
|
nested
|
||||||
? this.processNestedData(value, group, key, parents)
|
? this.processNestedData(updatedValue, group, key, parents)
|
||||||
: this.updateSetting(value, group, key, input, type)
|
: this.updateSetting(updatedValue, group, key, input, type)
|
||||||
},
|
},
|
||||||
updateSetting(value, group, key, input, type) {
|
updateSetting(value, group, key, input, type) {
|
||||||
this.$store.dispatch('UpdateSettings', { group, key, input, value, type })
|
this.$store.dispatch('UpdateSettings', { group, key, input, value, type })
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-select
|
<el-select
|
||||||
v-if="setting.type === 'module' || (setting.type.includes('atom') && setting.type.includes('dropdown'))"
|
v-if="setting.type === 'module' || (setting.type.includes('atom') && setting.type.includes('dropdown'))"
|
||||||
:value="inputValue"
|
:value="inputValue === false ? 'false' : inputValue"
|
||||||
:data-search="setting.key || setting.group"
|
:data-search="setting.key || setting.group"
|
||||||
clearable
|
clearable
|
||||||
class="input"
|
class="input"
|
||||||
|
@ -28,6 +28,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { getBooleanValue } from '@/store/modules/normalizers'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'SelectInputWithReducedLabels',
|
name: 'SelectInputWithReducedLabels',
|
||||||
props: {
|
props: {
|
||||||
|
@ -107,8 +109,9 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateSetting(value, group, key, input, type) {
|
updateSetting(value, group, key, input, type) {
|
||||||
this.$store.dispatch('UpdateSettings', { group, key, input, value, type })
|
const updatedValue = getBooleanValue(value)
|
||||||
this.$store.dispatch('UpdateState', { group, key, input, value })
|
this.$store.dispatch('UpdateSettings', { group, key, input, value: updatedValue, type })
|
||||||
|
this.$store.dispatch('UpdateState', { group, key, input, value: updatedValue })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
:value="data.value"
|
:value="data.value"
|
||||||
:data-search="setting.key || setting.group"
|
:data-search="setting.key || setting.group"
|
||||||
multiple
|
multiple
|
||||||
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 value=":console" label="console"/>
|
<el-option value=":console" label="console"/>
|
||||||
|
@ -18,8 +16,6 @@
|
||||||
:value="data[setting.key]"
|
:value="data[setting.key]"
|
||||||
:data-search="setting.key || setting.group"
|
:data-search="setting.key || setting.group"
|
||||||
multiple
|
multiple
|
||||||
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 value="strip" label="strip"/>
|
<el-option value="strip" label="strip"/>
|
||||||
|
@ -31,7 +27,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'MultipleSelect',
|
name: 'SpecificMultipleSelect',
|
||||||
props: {
|
props: {
|
||||||
data: {
|
data: {
|
||||||
type: [Object, Array],
|
type: [Object, Array],
|
|
@ -3,9 +3,9 @@ export { default as EditableKeywordInput } from './EditableKeywordInput'
|
||||||
export { default as CrontabInput } from './CrontabInput'
|
export { default as CrontabInput } from './CrontabInput'
|
||||||
export { default as IconsInput } from './IconsInput'
|
export { default as IconsInput } from './IconsInput'
|
||||||
export { default as MascotsInput } from './MascotsInput'
|
export { default as MascotsInput } from './MascotsInput'
|
||||||
export { default as MultipleSelect } from './MultipleSelect'
|
|
||||||
export { default as ProxyUrlInput } from './ProxyUrlInput'
|
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 SelectInputWithReducedLabels } from './SelectInputWithReducedLabels'
|
export { default as SelectInputWithReducedLabels } from './SelectInputWithReducedLabels'
|
||||||
|
export { default as SpecificMultipleSelect } from './SpecificMultipleSelect'
|
||||||
|
|
Loading…
Reference in a new issue