2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-04-04 10:31:03 +00:00

feat(frontend): disable_theme_storage (#11208)

* feat(frontend): disable_theme_storage

* bump API version

* fix access pattern
This commit is contained in:
Matthias Mair
2026-01-29 10:50:05 +01:00
committed by GitHub
parent 620e69be4d
commit e554cf2a58
5 changed files with 21 additions and 2 deletions

View File

@@ -270,7 +270,15 @@ function observeProfile() {
const user = useUserState.getState().getUser();
const { language, setLanguage, userTheme, setTheme, setWidgets, setLayouts } =
useLocalState.getState();
const { server } = useServerApiState.getState(); //(useShallow((state) => [state.server]));
// fast exit if loading is disabled for this server
if (server.customize?.disable_theme_storage) {
return;
}
if (user) {
// set profile language
if (user.profile?.language && language != user.profile.language) {
showNotification({
title: t`Language changed`,
@@ -281,6 +289,7 @@ function observeProfile() {
setLanguage(user.profile.language, true);
}
// set profile theme
if (user.profile?.theme) {
// extract keys of usertheme and set them to the values of user.profile.theme
const newTheme = Object.keys(userTheme).map((key) => {
@@ -302,6 +311,7 @@ function observeProfile() {
}
}
// set profile widgets/layouts
if (user.profile?.widgets) {
const data = user.profile.widgets;
// split data into widgets and layouts (either might be undefined)

View File

@@ -37,6 +37,7 @@ export interface ServerAPIProps {
splash: string;
login_message: string;
navbar_message: string;
disable_theme_storage: boolean;
};
}