commit: 4c3af5c362574aad4d851990265ebc7252c6f990
parent df9fe6d261ca554b8f886e45ccf70b44b47e53f5
Author: Henry Jameson <me@hjkos.com>
Date: Mon, 27 Mar 2023 22:57:50 +0300
handle db config disabled case
Diffstat:
5 files changed, 93 insertions(+), 10 deletions(-)
diff --git a/src/components/settings_modal/settings_modal_admin_content.js b/src/components/settings_modal/settings_modal_admin_content.js
@@ -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: {
diff --git a/src/components/settings_modal/settings_modal_admin_content.vue b/src/components/settings_modal/settings_modal_admin_content.vue
@@ -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>
diff --git a/src/i18n/en.json b/src/i18n/en.json
@@ -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",
diff --git a/src/modules/adminSettings.js b/src/modules/adminSettings.js
@@ -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()
diff --git a/src/modules/users.js b/src/modules/users.js
@@ -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')