mirror of
https://git.pleroma.social/sjw/pleroma-fe.git
synced 2024-12-23 16:05:09 +01:00
handle db config disabled case
This commit is contained in:
parent
df9fe6d261
commit
4c3af5c362
@ -9,7 +9,7 @@ import { library } from '@fortawesome/fontawesome-svg-core'
|
||||
import {
|
||||
faWrench,
|
||||
faHand,
|
||||
faFilter,
|
||||
faLaptopCode,
|
||||
faPaintBrush,
|
||||
faBell,
|
||||
faDownload,
|
||||
@ -20,7 +20,7 @@ import {
|
||||
library.add(
|
||||
faWrench,
|
||||
faHand,
|
||||
faFilter,
|
||||
faLaptopCode,
|
||||
faPaintBrush,
|
||||
faBell,
|
||||
faDownload,
|
||||
@ -38,6 +38,9 @@ const SettingsModalAdminContent = {
|
||||
LimitsTab
|
||||
},
|
||||
computed: {
|
||||
user () {
|
||||
return this.$store.state.users.currentUser
|
||||
},
|
||||
isLoggedIn () {
|
||||
return !!this.$store.state.users.currentUser
|
||||
},
|
||||
@ -46,6 +49,17 @@ const SettingsModalAdminContent = {
|
||||
},
|
||||
bodyLock () {
|
||||
return this.$store.state.interface.settingsModalState === 'visible'
|
||||
},
|
||||
adminDbLoaded () {
|
||||
return this.$store.state.adminSettings.loaded
|
||||
},
|
||||
noDb () {
|
||||
return this.$store.state.adminSettings.dbConfigEnabled === false
|
||||
}
|
||||
},
|
||||
created () {
|
||||
if (this.user.rights.admin) {
|
||||
this.$store.dispatch('loadAdminStuff')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -4,9 +4,40 @@
|
||||
class="settings_tab-switcher"
|
||||
:side-tab-bar="true"
|
||||
:scrollable-tabs="true"
|
||||
:render-only-focused="true"
|
||||
:body-scroll-lock="bodyLock"
|
||||
>
|
||||
<div
|
||||
v-if="noDb"
|
||||
:label="$t('admin_dash.tabs.nodb')"
|
||||
icon="exclamation-triangle"
|
||||
data-tab-name="nodb-notice"
|
||||
>
|
||||
<div :label="$t('admin_dash.tabs.nodb')">
|
||||
<div class="setting-item">
|
||||
<h2>{{ $t('admin_dash.nodb.heading') }}</h2>
|
||||
<i18n-t keypath="admin_dash.nodb.text">
|
||||
<template #documentation>
|
||||
<a
|
||||
href="https://docs-develop.pleroma.social/backend/configuration/howto_database_config/"
|
||||
target="_blank"
|
||||
>
|
||||
{{ $t("admin_dash.nodb.documentation") }}
|
||||
</a>
|
||||
</template>
|
||||
<template #property>
|
||||
<code>config :pleroma, configurable_from_database</code>
|
||||
</template>
|
||||
<template #value>
|
||||
<code>true</code>
|
||||
</template>
|
||||
</i18n-t>
|
||||
<p>{{ $t('admin_dash.nodb.text2') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="adminDbLoaded"
|
||||
:label="$t('admin_dash.tabs.instance')"
|
||||
icon="wrench"
|
||||
data-tab-name="general"
|
||||
@ -14,12 +45,20 @@
|
||||
<InstanceTab />
|
||||
</div>
|
||||
<div
|
||||
v-if="adminDbLoaded"
|
||||
:label="$t('admin_dash.tabs.limits')"
|
||||
icon="hand"
|
||||
data-tab-name="limits"
|
||||
>
|
||||
<LimitsTab />
|
||||
</div>
|
||||
<div
|
||||
:label="$t('admin_dash.tabs.frontends')"
|
||||
icon="laptop-code"
|
||||
data-tab-name="frontends"
|
||||
>
|
||||
<FrontendsTab />
|
||||
</div>
|
||||
</tab-switcher>
|
||||
</template>
|
||||
|
||||
|
@ -845,8 +845,16 @@
|
||||
"reset_all": "Reset all",
|
||||
"commit_all": "Save all",
|
||||
"tabs": {
|
||||
"nodb": "No DB Config",
|
||||
"instance": "Instance",
|
||||
"limits": "Limits"
|
||||
"limits": "Limits",
|
||||
"frontends": "Front-ends"
|
||||
},
|
||||
"nodb": {
|
||||
"heading": "Database config is disabled",
|
||||
"text": "You need to change backend config files so that {property} is set to {value}, see more in {documentation}.",
|
||||
"documentation": "documentation",
|
||||
"text2": "Most configuration options will be unavailable."
|
||||
},
|
||||
"captcha": {
|
||||
"native": "Native",
|
||||
|
@ -1,11 +1,13 @@
|
||||
import { set, get, cloneDeep, differenceWith, isEqual, flatten } from 'lodash'
|
||||
|
||||
export const defaultState = {
|
||||
loaded: false,
|
||||
needsReboot: null,
|
||||
config: null,
|
||||
modifiedPaths: null,
|
||||
descriptions: null,
|
||||
draft: null
|
||||
draft: null,
|
||||
dbConfigEnabled: null
|
||||
}
|
||||
|
||||
export const newUserFlags = {
|
||||
@ -17,7 +19,13 @@ const adminSettingsStorage = {
|
||||
...cloneDeep(defaultState)
|
||||
},
|
||||
mutations: {
|
||||
setInstanceAdminNoDbConfig (state) {
|
||||
state.loaded = false
|
||||
state.dbConfigEnabled = false
|
||||
},
|
||||
updateAdminSettings (state, { config, modifiedPaths }) {
|
||||
state.loaded = true
|
||||
state.dbConfigEnabled = true
|
||||
state.config = config
|
||||
state.modifiedPaths = modifiedPaths
|
||||
},
|
||||
@ -40,6 +48,26 @@ const adminSettingsStorage = {
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
loadAdminStuff ({ state, rootState, dispatch, commit }) {
|
||||
rootState.api.backendInteractor.fetchInstanceDBConfig()
|
||||
.then(backendDbConfig => {
|
||||
if (backendDbConfig.error) {
|
||||
if (backendDbConfig.error.status === 400) {
|
||||
backendDbConfig.error.json().then(errorJson => {
|
||||
if (/configurable_from_database/.test(errorJson.error)) {
|
||||
commit('setInstanceAdminNoDbConfig')
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
dispatch('setInstanceAdminSettings', { backendDbConfig })
|
||||
}
|
||||
})
|
||||
if (state.descriptions === null) {
|
||||
rootState.api.backendInteractor.fetchInstanceConfigDescriptions()
|
||||
.then(backendDescriptions => this.$store.dispatch('setInstanceAdminDescriptions', { backendDescriptions }))
|
||||
}
|
||||
},
|
||||
setInstanceAdminSettings ({ state, commit, dispatch }, { backendDbConfig }) {
|
||||
const config = state.config || {}
|
||||
const modifiedPaths = new Set()
|
||||
|
@ -564,12 +564,6 @@ const users = {
|
||||
user.domainMutes = []
|
||||
commit('setCurrentUser', user)
|
||||
commit('setServerSideStorage', user)
|
||||
if (user.rights.admin) {
|
||||
store.rootState.api.backendInteractor.fetchInstanceDBConfig()
|
||||
.then(backendDbConfig => dispatch('setInstanceAdminSettings', { backendDbConfig }))
|
||||
store.rootState.api.backendInteractor.fetchInstanceConfigDescriptions()
|
||||
.then(backendDescriptions => dispatch('setInstanceAdminDescriptions', { backendDescriptions }))
|
||||
}
|
||||
commit('addNewUsers', [user])
|
||||
|
||||
dispatch('fetchEmoji')
|
||||
|
Loading…
Reference in New Issue
Block a user