From 9c3d0e05a3cbf71197c8f0dedb3a3626f33ff8b2 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Thu, 30 Jan 2020 15:40:39 +0300 Subject: [PATCH] Disable config tabs if config is disabled --- src/store/modules/settings.js | 28 +++++++++--- src/views/settings/index.vue | 81 ++++++++++++++++++++++------------- 2 files changed, 75 insertions(+), 34 deletions(-) diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index 06c9ceba..0ecbc9a2 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -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) => { diff --git a/src/views/settings/index.vue b/src/views/settings/index.vue index a2edc686..9ad815cb 100644 --- a/src/views/settings/index.vue +++ b/src/views/settings/index.vue @@ -2,67 +2,64 @@

{{ $t('settings.settings') }}

- + - + - + - + - + - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -71,16 +68,42 @@