Skip to content
Snippets Groups Projects
Commit 0b8fafb3 authored by Angelina Filippova's avatar Angelina Filippova
Browse files

Add remove buttons only to user's settings

parent 2b62b48e
No related branches found
No related tags found
1 merge request!77Ability to remove settings from db
This commit is part of merge request !77. Comments created here will be created in the context of that merge request.
...@@ -381,6 +381,7 @@ export default { ...@@ -381,6 +381,7 @@ export default {
file: 'File', file: 'File',
update: 'Update', update: 'Update',
remove: 'Remove', remove: 'Remove',
removeFromDB: 'Remove setting from the DB',
selectLocalPack: 'Select the local pack to copy to', selectLocalPack: 'Select the local pack to copy to',
localPack: 'Local pack', localPack: 'Local pack',
specifyShortcode: 'Specify a custom shortcode', specifyShortcode: 'Specify a custom shortcode',
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<el-form-item :label-width="customLabelWidth" :class="labelClass"> <el-form-item :label-width="customLabelWidth" :class="labelClass">
<span slot="label"> <span slot="label">
{{ setting.label }} {{ setting.label }}
<el-tooltip v-if="canBeDeleted" content="This would remove the setting from the DB" placement="bottom-end"> <el-tooltip v-if="canBeDeleted" :content="$t('settings.removeFromDB')" placement="bottom-end">
<el-button icon="el-icon-delete" circle size="mini" style="margin-left:5px" @click="removeSetting"/> <el-button icon="el-icon-delete" circle size="mini" style="margin-left:5px" @click="removeSetting"/>
</el-tooltip> </el-tooltip>
</span> </span>
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
import i18n from '@/lang' import i18n from '@/lang'
import { AutoLinkerInput, EditableKeywordInput, IconsInput, MascotsInput, MultipleSelect, ProxyUrlInput, PruneInput, RateLimitInput } from './inputComponents' import { AutoLinkerInput, EditableKeywordInput, IconsInput, MascotsInput, MultipleSelect, ProxyUrlInput, PruneInput, RateLimitInput } from './inputComponents'
import { processNested } from '@/store/modules/normalizers' import { processNested } from '@/store/modules/normalizers'
import _ from 'lodash'
export default { export default {
name: 'Inputs', name: 'Inputs',
...@@ -99,12 +100,6 @@ export default { ...@@ -99,12 +100,6 @@ export default {
RateLimitInput RateLimitInput
}, },
props: { props: {
canBeDeleted: {
type: Boolean,
default: function() {
return false
}
},
customLabelWidth: { customLabelWidth: {
type: String, type: String,
default: function() { default: function() {
...@@ -159,6 +154,11 @@ export default { ...@@ -159,6 +154,11 @@ export default {
} }
}, },
computed: { computed: {
canBeDeleted() {
const { group, key } = this.settingGroup
return _.get(this.$store.state.settings.db, [group, key]) &&
this.$store.state.settings.db[group][key].includes(this.setting.key)
},
iconsData() { iconsData() {
return Array.isArray(this.data[':icons']) ? this.data[':icons'] : [] return Array.isArray(this.data[':icons']) ? this.data[':icons'] : []
}, },
......
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
<inputs <inputs
:setting-group="settingGroup" :setting-group="settingGroup"
:setting="setting" :setting="setting"
:data="data" :data="data"/>
:can-be-deleted="true"/>
</div> </div>
<div <div
v-for="setting in emailAdapterChildren" v-for="setting in emailAdapterChildren"
...@@ -17,8 +16,7 @@ ...@@ -17,8 +16,7 @@
<inputs <inputs
:setting-group="settingGroup" :setting-group="settingGroup"
:setting="setting" :setting="setting"
:data="data" :data="data"/>
:can-be-deleted="true"/>
</div> </div>
</div> </div>
<div v-else> <div v-else>
...@@ -28,8 +26,7 @@ ...@@ -28,8 +26,7 @@
:setting-group="settingGroup" :setting-group="settingGroup"
:setting="setting" :setting="setting"
:data="data" :data="data"
:nested="false" :nested="false"/>
:can-be-deleted="true"/>
</div> </div>
<div v-if="compound(setting)"> <div v-if="compound(setting)">
<div v-if="!setting.children"> <div v-if="!setting.children">
...@@ -37,14 +34,13 @@ ...@@ -37,14 +34,13 @@
:setting-group="settingGroup" :setting-group="settingGroup"
:setting="setting" :setting="setting"
:data="data[setting.key]" :data="data[setting.key]"
:nested="true" :nested="true"/>
:can-be-deleted="true"/>
</div> </div>
<div v-else> <div v-else>
<el-form-item> <el-form-item>
<span slot="label"> <span slot="label">
{{ setting.label }}: {{ setting.label }}:
<el-tooltip content="This would remove the setting from the DB" placement="bottom-end"> <el-tooltip v-if="canBeDeleted(setting.key)" :content="$t('settings.removeFromDB')" placement="bottom-end">
<el-button icon="el-icon-delete" circle size="mini" style="margin-left:5px" @click="removeSetting(setting.key)"/> <el-button icon="el-icon-delete" circle size="mini" style="margin-left:5px" @click="removeSetting(setting.key)"/>
</el-tooltip> </el-tooltip>
</span> </span>
...@@ -68,6 +64,7 @@ ...@@ -68,6 +64,7 @@
<script> <script>
import Inputs from './Inputs' import Inputs from './Inputs'
import i18n from '@/lang' import i18n from '@/lang'
import _ from 'lodash'
export default { export default {
name: 'Setting', name: 'Setting',
...@@ -98,6 +95,12 @@ export default { ...@@ -98,6 +95,12 @@ export default {
} }
}, },
methods: { methods: {
canBeDeleted(setting) {
const { group, key } = this.settingGroup
const keyExists = key || setting
return _.get(this.$store.state.settings.db, [group, keyExists]) &&
this.$store.state.settings.db[group][keyExists].includes(setting)
},
compound({ type, key, children }) { compound({ type, key, children }) {
return type === 'keyword' || return type === 'keyword' ||
type === 'map' || type === 'map' ||
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment