forked from AkkomaGang/admin-fe
Merge branch 'update-settings-tab-when-config-is-disabled' into 'develop'
Disable config tabs if config is disabled Closes #72 and #73 See merge request pleroma/admin-fe!86
This commit is contained in:
commit
ee659bc984
2 changed files with 75 additions and 34 deletions
|
@ -4,6 +4,8 @@ import _ from 'lodash'
|
||||||
|
|
||||||
const settings = {
|
const settings = {
|
||||||
state: {
|
state: {
|
||||||
|
activeTab: 'instance',
|
||||||
|
configDisabled: true,
|
||||||
description: [],
|
description: [],
|
||||||
settings: {},
|
settings: {},
|
||||||
updatedSettings: {},
|
updatedSettings: {},
|
||||||
|
@ -20,6 +22,9 @@ const settings = {
|
||||||
state.updatedSettings = updatedSettings
|
state.updatedSettings = updatedSettings
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
SET_ACTIVE_TAB: (state, tab) => {
|
||||||
|
state.activeTab = tab
|
||||||
|
},
|
||||||
SET_DESCRIPTION: (state, data) => {
|
SET_DESCRIPTION: (state, data) => {
|
||||||
state.description = data
|
state.description = data
|
||||||
},
|
},
|
||||||
|
@ -45,6 +50,9 @@ const settings = {
|
||||||
state.settings = newSettings
|
state.settings = newSettings
|
||||||
state.db = newDbSettings
|
state.db = newDbSettings
|
||||||
},
|
},
|
||||||
|
TOGGLE_TABS: (state, status) => {
|
||||||
|
state.configDisabled = status
|
||||||
|
},
|
||||||
UPDATE_SETTINGS: (state, { group, key, input, value, type }) => {
|
UPDATE_SETTINGS: (state, { group, key, input, value, type }) => {
|
||||||
const updatedSetting = !state.updatedSettings[group] || (key === 'Pleroma.Emails.Mailer' && input === ':adapter')
|
const updatedSetting = !state.updatedSettings[group] || (key === 'Pleroma.Emails.Mailer' && input === ':adapter')
|
||||||
? { [key]: { [input]: [type, value] }}
|
? { [key]: { [input]: [type, value] }}
|
||||||
|
@ -61,11 +69,18 @@ const settings = {
|
||||||
actions: {
|
actions: {
|
||||||
async FetchSettings({ commit, getters }) {
|
async FetchSettings({ commit, getters }) {
|
||||||
commit('SET_LOADING', true)
|
commit('SET_LOADING', true)
|
||||||
const response = await fetchSettings(getters.authHost, getters.token)
|
try {
|
||||||
const description = await fetchDescription(getters.authHost, getters.token)
|
const response = await fetchSettings(getters.authHost, getters.token)
|
||||||
|
const description = await fetchDescription(getters.authHost, getters.token)
|
||||||
commit('SET_DESCRIPTION', description.data)
|
commit('SET_DESCRIPTION', description.data)
|
||||||
commit('SET_SETTINGS', response.data.configs)
|
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)
|
commit('SET_LOADING', false)
|
||||||
},
|
},
|
||||||
async RemoveSetting({ commit, getters }, configs) {
|
async RemoveSetting({ commit, getters }, configs) {
|
||||||
|
@ -75,6 +90,9 @@ const settings = {
|
||||||
commit('SET_SETTINGS', response.data.configs)
|
commit('SET_SETTINGS', response.data.configs)
|
||||||
commit('REMOVE_SETTING_FROM_UPDATED', { group, key, subkeys: subkeys || [] })
|
commit('REMOVE_SETTING_FROM_UPDATED', { group, key, subkeys: subkeys || [] })
|
||||||
},
|
},
|
||||||
|
SetActiveTab({ commit }, tab) {
|
||||||
|
commit('SET_ACTIVE_TAB', tab)
|
||||||
|
},
|
||||||
async SubmitChanges({ getters, commit, state }) {
|
async SubmitChanges({ getters, commit, state }) {
|
||||||
const updatedData = checkPartialUpdate(state.settings, state.updatedSettings, state.description)
|
const updatedData = checkPartialUpdate(state.settings, state.updatedSettings, state.description)
|
||||||
const configs = Object.keys(updatedData).reduce((acc, group) => {
|
const configs = Object.keys(updatedData).reduce((acc, group) => {
|
||||||
|
|
|
@ -2,67 +2,64 @@
|
||||||
<div class="settings-container">
|
<div class="settings-container">
|
||||||
<h1>{{ $t('settings.settings') }}</h1>
|
<h1>{{ $t('settings.settings') }}</h1>
|
||||||
<el-tabs v-model="activeTab" :tab-position="tabPosition">
|
<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/>
|
<activity-pub/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.auth')" lazy>
|
<el-tab-pane :label="$t('settings.auth')" :disabled="confidDisabled" lazy>
|
||||||
<authentication/>
|
<authentication/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.autoLinker')" lazy>
|
<el-tab-pane :label="$t('settings.autoLinker')" :disabled="confidDisabled" lazy>
|
||||||
<auto-linker/>
|
<auto-linker/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.esshd')" lazy>
|
<el-tab-pane :label="$t('settings.esshd')" :disabled="confidDisabled" lazy>
|
||||||
<esshd/>
|
<esshd/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.captcha')" lazy>
|
<el-tab-pane :label="$t('settings.captcha')" :disabled="confidDisabled" lazy>
|
||||||
<captcha/>
|
<captcha/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.emojiPacks')" lazy>
|
<el-tab-pane :label="$t('settings.frontend')" :disabled="confidDisabled" lazy>
|
||||||
<emoji-packs/>
|
|
||||||
</el-tab-pane>
|
|
||||||
<el-tab-pane :label="$t('settings.frontend')" lazy>
|
|
||||||
<frontend/>
|
<frontend/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.gopher')" lazy>
|
<el-tab-pane :label="$t('settings.gopher')" :disabled="confidDisabled" lazy>
|
||||||
<gopher/>
|
<gopher/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.http')" lazy>
|
<el-tab-pane :label="$t('settings.http')" :disabled="confidDisabled" lazy>
|
||||||
<http/>
|
<http/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.instance')" name="instance">
|
<el-tab-pane :label="$t('settings.instance')" :disabled="confidDisabled" name="instance">
|
||||||
<instance/>
|
<instance/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.jobQueue')" lazy>
|
<el-tab-pane :label="$t('settings.jobQueue')" :disabled="confidDisabled" lazy>
|
||||||
<job-queue/>
|
<job-queue/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.logger')" lazy>
|
<el-tab-pane :label="$t('settings.logger')" :disabled="confidDisabled" lazy>
|
||||||
<logger/>
|
<logger/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.mailer')" lazy>
|
<el-tab-pane :label="$t('settings.mailer')" :disabled="confidDisabled" lazy>
|
||||||
<mailer/>
|
<mailer/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.mediaProxy')" lazy>
|
<el-tab-pane :label="$t('settings.mediaProxy')" :disabled="confidDisabled" lazy>
|
||||||
<media-proxy/>
|
<media-proxy/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.metadata')" lazy>
|
<el-tab-pane :label="$t('settings.metadata')" :disabled="confidDisabled" lazy>
|
||||||
<metadata/>
|
<metadata/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.mrf')" lazy>
|
<el-tab-pane :label="$t('settings.mrf')" :disabled="confidDisabled" lazy>
|
||||||
<mrf/>
|
<mrf/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.rateLimiters')" lazy>
|
<el-tab-pane :label="$t('settings.rateLimiters')" :disabled="confidDisabled" lazy>
|
||||||
<rate-limiters/>
|
<rate-limiters/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.relays')" lazy>
|
<el-tab-pane :label="$t('settings.relays')" lazy name="relays">
|
||||||
<relays/>
|
<relays/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.webPush')" lazy>
|
<el-tab-pane :label="$t('settings.webPush')" :disabled="confidDisabled" lazy>
|
||||||
<web-push/>
|
<web-push/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.upload')" lazy>
|
<el-tab-pane :label="$t('settings.upload')" :disabled="confidDisabled" lazy>
|
||||||
<upload/>
|
<upload/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('settings.other')" lazy>
|
<el-tab-pane :label="$t('settings.other')" :disabled="confidDisabled" lazy>
|
||||||
<other/>
|
<other/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
|
@ -71,16 +68,42 @@
|
||||||
|
|
||||||
<script>
|
<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 { 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 {
|
export default {
|
||||||
components: { ActivityPub, Authentication, AutoLinker, Captcha, EmojiPacks, Esshd, Frontend, Gopher, Http, Instance, JobQueue, Logger, Mailer, MediaProxy, Metadata, Mrf, Other, RateLimiters, Relays, Upload, WebPush },
|
components: {
|
||||||
data() {
|
ActivityPub,
|
||||||
return {
|
Authentication,
|
||||||
activeTab: 'instance'
|
AutoLinker,
|
||||||
}
|
Captcha,
|
||||||
|
Esshd,
|
||||||
|
Frontend,
|
||||||
|
Gopher,
|
||||||
|
Http,
|
||||||
|
Instance,
|
||||||
|
JobQueue,
|
||||||
|
Logger,
|
||||||
|
Mailer,
|
||||||
|
MediaProxy,
|
||||||
|
Metadata,
|
||||||
|
Mrf,
|
||||||
|
Other,
|
||||||
|
RateLimiters,
|
||||||
|
Relays,
|
||||||
|
Upload,
|
||||||
|
WebPush
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
activeTab: {
|
||||||
|
get() {
|
||||||
|
return this.$store.state.settings.activeTab
|
||||||
|
},
|
||||||
|
set(tab) {
|
||||||
|
this.$store.dispatch('SetActiveTab', tab)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
confidDisabled() {
|
||||||
|
return this.$store.state.settings.configDisabled
|
||||||
|
},
|
||||||
isMobile() {
|
isMobile() {
|
||||||
return this.$store.state.app.device === 'mobile'
|
return this.$store.state.app.device === 'mobile'
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue