Update Instance tab to accept values from API

This commit is contained in:
Angelina Filippova 2019-11-11 11:36:10 +09:00
parent a9453448b5
commit 88bae9ced8
2 changed files with 32 additions and 29 deletions

View file

@ -19,14 +19,14 @@
class="top-margin" class="top-margin"
@change="updateSetting($event, settingsGroup.key, setting.key)"/> @change="updateSetting($event, settingsGroup.key, setting.key)"/>
<el-select <el-select
v-if="setting.type === 'module'" v-if="setting.type === 'module' || (setting.type.includes('atom') && setting.type.includes(false))"
:value="data[setting.key]" :value="data[setting.key]"
clearable clearable
@change="updateSetting($event, settingsGroup.key, setting.key)"> @change="updateSetting($event, settingsGroup.key, setting.key)">
<el-option <el-option
v-for="option in setting.suggestions" v-for="(option, index) in setting.suggestions"
:value="option" :value="option"
:key="option"/> :key="index"/>
</el-select> </el-select>
<el-select <el-select
v-if="Array.isArray(setting.type) && ( v-if="Array.isArray(setting.type) && (
@ -36,7 +36,7 @@
filterable filterable
allow-create allow-create
@change="updateSetting($event, settingsGroup.key, setting.key)"> @change="updateSetting($event, settingsGroup.key, setting.key)">
<el-option v-for="option in setting.suggestions" :key="option" :value="option"/> <el-option v-for="(option, index) in setting.suggestions" :key="index" :value="option"/>
</el-select> </el-select>
<el-select <el-select
v-if="Array.isArray(setting.type) && setting.type.includes('list') && setting.type.includes('string')" v-if="Array.isArray(setting.type) && setting.type.includes('list') && setting.type.includes('string')"
@ -45,7 +45,7 @@
filterable filterable
allow-create allow-create
@change="updateSetting($event, settingsGroup.key, setting.key)"> @change="updateSetting($event, settingsGroup.key, setting.key)">
<el-option v-for="option in setting.suggestions" :key="option" :value="option"/> <el-option v-for="(option, index) in setting.suggestions" :key="index" :value="option"/>
</el-select> </el-select>
<editor <editor
v-if="Array.isArray(setting.type) v-if="Array.isArray(setting.type)

View file

@ -37,7 +37,6 @@
<script> <script>
import i18n from '@/lang' import i18n from '@/lang'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { options } from './options'
import Setting from './Setting' import Setting from './Setting'
export default { export default {
@ -47,22 +46,25 @@ export default {
}, },
computed: { computed: {
...mapGetters([ ...mapGetters([
'adminTokenData', 'settings'
'fetchInitialPostsData',
'instanceData',
'pleromaUserData',
'scheduledActivityData',
'suggestionsData',
'uriSchemesData'
]), ]),
adminToken() { adminToken() {
return this.$store.state.settings.description.find(setting => setting.description === `Allows to set a token that can be used to authenticate with the admin api without using an actual user by giving it as the 'admin_token' parameter`) return this.settings.description.find(setting => setting.description === `Allows to set a token that can be used to authenticate with the admin api without using an actual user by giving it as the 'admin_token' parameter`)
},
adminTokenData() {
return this.settings.settings[':admin_token']
}, },
fetchInitialPosts() { fetchInitialPosts() {
return this.$store.state.settings.description.find(setting => setting.key === ':fetch_initial_posts') return this.settings.description.find(setting => setting.key === ':fetch_initial_posts')
},
fetchInitialPostsData() {
return this.settings.settings[':fetch_initial_posts']
}, },
instance() { instance() {
return this.$store.state.settings.description.find(setting => setting.key === ':instance') return this.settings.description.find(setting => setting.key === ':instance')
},
instanceData() {
return this.settings.settings[':instance']
}, },
isMobile() { isMobile() {
return this.$store.state.app.device === 'mobile' return this.$store.state.app.device === 'mobile'
@ -71,33 +73,34 @@ export default {
return this.isMobile ? '100px' : '240px' return this.isMobile ? '100px' : '240px'
}, },
loading() { loading() {
return this.$store.state.settings.loading return this.settings.loading
}, },
pleromaUser() { pleromaUser() {
return this.$store.state.settings.description.find(setting => setting.key === 'Pleroma.User') return this.settings.description.find(setting => setting.key === 'Pleroma.User')
},
pleromaUserData() {
return this.settings.settings['Pleroma.User']
}, },
scheduledActivity() { scheduledActivity() {
return this.$store.state.settings.description.find(setting => setting.key === 'Pleroma.ScheduledActivity') return this.$store.state.settings.description.find(setting => setting.key === 'Pleroma.ScheduledActivity')
}, },
scheduledActivityData() {
return this.settings.settings['Pleroma.ScheduledActivity']
},
suggestions() { suggestions() {
return this.$store.state.settings.description.find(setting => setting.key === ':suggestions') return this.$store.state.settings.description.find(setting => setting.key === ':suggestions')
}, },
suggestionsData() {
return this.settings.settings[':suggestions']
},
uriSchemes() { uriSchemes() {
return this.$store.state.settings.description.find(setting => setting.key === ':uri_schemes') return this.$store.state.settings.description.find(setting => setting.key === ':uri_schemes')
},
uriSchemesData() {
return this.settings.settings[':uri_schemes']
} }
}, },
methods: { methods: {
getRewritePolicyExpl(value) {
const policy = options.rewritePolicyOptions.find(el => el.value === value)
return policy.expl
},
processNestedData(value, tab, inputName, childName) {
const updatedValue = { ...this.$store.state.settings.settings[tab][inputName], ...{ [childName]: value }}
this.updateSetting(updatedValue, tab, inputName)
},
updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
},
async onSubmit() { async onSubmit() {
try { try {
await this.$store.dispatch('SubmitChanges') await this.$store.dispatch('SubmitChanges')