Commit 9c3d0e05 authored by Angelina Filippova's avatar Angelina Filippova
Browse files

Disable config tabs if config is disabled

parent 68feb67c
Pipeline #22403 passed with stages
in 8 minutes and 6 seconds
......@@ -4,6 +4,8 @@ import _ from 'lodash'
const settings = {
state: {
activeTab: 'instance',
configDisabled: true,
description: [],
settings: {},
updatedSettings: {},
......@@ -20,6 +22,9 @@ const settings = {
state.updatedSettings = updatedSettings
}
},
SET_ACTIVE_TAB: (state, tab) => {
state.activeTab = tab
},
SET_DESCRIPTION: (state, data) => {
state.description = data
},
......@@ -45,6 +50,9 @@ const settings = {
state.settings = newSettings
state.db = newDbSettings
},
TOGGLE_TABS: (state, status) => {
state.configDisabled = status
},
UPDATE_SETTINGS: (state, { group, key, input, value, type }) => {
const updatedSetting = !state.updatedSettings[group] || (key === 'Pleroma.Emails.Mailer' && input === ':adapter')
? { [key]: { [input]: [type, value] }}
......@@ -61,11 +69,18 @@ const settings = {
actions: {
async FetchSettings({ commit, getters }) {
commit('SET_LOADING', true)
const response = await fetchSettings(getters.authHost, getters.token)
const description = await fetchDescription(getters.authHost, getters.token)
commit('SET_DESCRIPTION', description.data)
commit('SET_SETTINGS', response.data.configs)
try {
const response = await fetchSettings(getters.authHost, getters.token)
const description = await fetchDescription(getters.authHost, getters.token)
commit('SET_DESCRIPTION', description.data)
commit('SET_SETTINGS', response.data.configs)
} catch (_e) {
commit('TOGGLE_TABS', true)
commit('SET_ACTIVE_TAB', 'relays')
commit('SET_LOADING', false)
return
}
commit('TOGGLE_TABS', false)
commit('SET_LOADING', false)
},
async RemoveSetting({ commit, getters }, configs) {
......@@ -75,6 +90,9 @@ const settings = {
commit('SET_SETTINGS', response.data.configs)
commit('REMOVE_SETTING_FROM_UPDATED', { group, key, subkeys: subkeys || [] })
},
SetActiveTab({ commit }, tab) {
commit('SET_ACTIVE_TAB', tab)
},
async SubmitChanges({ getters, commit, state }) {
const updatedData = checkPartialUpdate(state.settings, state.updatedSettings, state.description)
const configs = Object.keys(updatedData).reduce((acc, group) => {
......
......@@ -2,67 +2,64 @@
<div class="settings-container">
<h1>{{ $t('settings.settings') }}</h1>
<el-tabs v-model="activeTab" :tab-position="tabPosition">
<el-tab-pane :label="$t('settings.activityPub')" lazy>
<el-tab-pane :label="$t('settings.activityPub')" :disabled="confidDisabled" lazy>
<activity-pub/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.auth')" lazy>
<el-tab-pane :label="$t('settings.auth')" :disabled="confidDisabled" lazy>
<authentication/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.autoLinker')" lazy>
<el-tab-pane :label="$t('settings.autoLinker')" :disabled="confidDisabled" lazy>
<auto-linker/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.esshd')" lazy>
<el-tab-pane :label="$t('settings.esshd')" :disabled="confidDisabled" lazy>
<esshd/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.captcha')" lazy>
<el-tab-pane :label="$t('settings.captcha')" :disabled="confidDisabled" lazy>
<captcha/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.emojiPacks')" lazy>
<emoji-packs/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.frontend')" lazy>
<el-tab-pane :label="$t('settings.frontend')" :disabled="confidDisabled" lazy>
<frontend/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.gopher')" lazy>
<el-tab-pane :label="$t('settings.gopher')" :disabled="confidDisabled" lazy>
<gopher/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.http')" lazy>
<el-tab-pane :label="$t('settings.http')" :disabled="confidDisabled" lazy>
<http/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.instance')" name="instance">
<el-tab-pane :label="$t('settings.instance')" :disabled="confidDisabled" name="instance">
<instance/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.jobQueue')" lazy>
<el-tab-pane :label="$t('settings.jobQueue')" :disabled="confidDisabled" lazy>
<job-queue/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.logger')" lazy>
<el-tab-pane :label="$t('settings.logger')" :disabled="confidDisabled" lazy>
<logger/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.mailer')" lazy>
<el-tab-pane :label="$t('settings.mailer')" :disabled="confidDisabled" lazy>
<mailer/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.mediaProxy')" lazy>
<el-tab-pane :label="$t('settings.mediaProxy')" :disabled="confidDisabled" lazy>
<media-proxy/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.metadata')" lazy>
<el-tab-pane :label="$t('settings.metadata')" :disabled="confidDisabled" lazy>
<metadata/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.mrf')" lazy>
<el-tab-pane :label="$t('settings.mrf')" :disabled="confidDisabled" lazy>
<mrf/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.rateLimiters')" lazy>
<el-tab-pane :label="$t('settings.rateLimiters')" :disabled="confidDisabled" lazy>
<rate-limiters/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.relays')" lazy>
<el-tab-pane :label="$t('settings.relays')" lazy name="relays">
<relays/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.webPush')" lazy>
<el-tab-pane :label="$t('settings.webPush')" :disabled="confidDisabled" lazy>
<web-push/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.upload')" lazy>
<el-tab-pane :label="$t('settings.upload')" :disabled="confidDisabled" lazy>
<upload/>
</el-tab-pane>
<el-tab-pane :label="$t('settings.other')" lazy>
<el-tab-pane :label="$t('settings.other')" :disabled="confidDisabled" lazy>
<other/>
</el-tab-pane>
</el-tabs>
......@@ -71,16 +68,42 @@
<script>
import { ActivityPub, Authentication, AutoLinker, Captcha, Esshd, Frontend, Gopher, Http, Instance, JobQueue, Logger, Mailer, MediaProxy, Metadata, Mrf, Other, RateLimiters, Relays, Upload, WebPush } from './components'
import EmojiPacks from '../emojiPacks/index'
export default {
components: { ActivityPub, Authentication, AutoLinker, Captcha, EmojiPacks, Esshd, Frontend, Gopher, Http, Instance, JobQueue, Logger, Mailer, MediaProxy, Metadata, Mrf, Other, RateLimiters, Relays, Upload, WebPush },
data() {
return {
activeTab: 'instance'
}
components: {
ActivityPub,
Authentication,
AutoLinker,
Captcha,
Esshd,
Frontend,
Gopher,
Http,
Instance,
JobQueue,
Logger,
Mailer,
MediaProxy,
Metadata,
Mrf,
Other,
RateLimiters,
Relays,
Upload,
WebPush
},
computed: {
activeTab: {
get() {
return this.$store.state.settings.activeTab
},
set(tab) {
this.$store.dispatch('SetActiveTab', tab)
}
},
confidDisabled() {
return this.$store.state.settings.configDisabled
},
isMobile() {
return this.$store.state.app.device === 'mobile'
},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment