mirror of
https://github.com/inventree/InvenTree.git
synced 2026-02-02 03:14:56 +00:00
feat(frontend): disable_theme_storage (#11208)
* feat(frontend): disable_theme_storage * bump API version * fix access pattern
This commit is contained in:
@@ -34,7 +34,7 @@ from plugin.serializers import MetadataSerializer
|
|||||||
from users.models import ApiToken
|
from users.models import ApiToken
|
||||||
from users.permissions import check_user_permission, prefetch_rule_sets
|
from users.permissions import check_user_permission, prefetch_rule_sets
|
||||||
|
|
||||||
from .helpers import plugins_info
|
from .helpers import plugins_info, str2bool
|
||||||
from .helpers_email import is_email_configured
|
from .helpers_email import is_email_configured
|
||||||
from .mixins import ListAPI, RetrieveUpdateAPI
|
from .mixins import ListAPI, RetrieveUpdateAPI
|
||||||
from .status import check_system_health, is_worker_running
|
from .status import check_system_health, is_worker_running
|
||||||
@@ -238,6 +238,7 @@ class InfoApiSerializer(serializers.Serializer):
|
|||||||
splash = serializers.CharField()
|
splash = serializers.CharField()
|
||||||
login_message = serializers.CharField(allow_null=True)
|
login_message = serializers.CharField(allow_null=True)
|
||||||
navbar_message = serializers.CharField(allow_null=True)
|
navbar_message = serializers.CharField(allow_null=True)
|
||||||
|
disable_theme_storage = serializers.BooleanField(default=False)
|
||||||
|
|
||||||
server = serializers.CharField(read_only=True)
|
server = serializers.CharField(read_only=True)
|
||||||
id = serializers.CharField(read_only=True, allow_null=True)
|
id = serializers.CharField(read_only=True, allow_null=True)
|
||||||
@@ -310,6 +311,9 @@ class InfoView(APIView):
|
|||||||
'splash': helpers.getSplashScreen(),
|
'splash': helpers.getSplashScreen(),
|
||||||
'login_message': helpers.getCustomOption('login_message'),
|
'login_message': helpers.getCustomOption('login_message'),
|
||||||
'navbar_message': helpers.getCustomOption('navbar_message'),
|
'navbar_message': helpers.getCustomOption('navbar_message'),
|
||||||
|
'disable_theme_storage': str2bool(
|
||||||
|
helpers.getCustomOption('disable_theme_storage')
|
||||||
|
),
|
||||||
},
|
},
|
||||||
'active_plugins': plugins_info(),
|
'active_plugins': plugins_info(),
|
||||||
# Following fields are only available to staff users
|
# Following fields are only available to staff users
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
"""InvenTree API version information."""
|
"""InvenTree API version information."""
|
||||||
|
|
||||||
# InvenTree API version
|
# InvenTree API version
|
||||||
INVENTREE_API_VERSION = 443
|
INVENTREE_API_VERSION = 444
|
||||||
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
||||||
|
|
||||||
INVENTREE_API_TEXT = """
|
INVENTREE_API_TEXT = """
|
||||||
|
|
||||||
|
v444 -> 2026-01-27 : https://github.com/inventree/InvenTree/pull/11208
|
||||||
|
- Add customize option to disable theme loading from user profile (mainly for demo site use)
|
||||||
|
|
||||||
v443 -> 2026-01-21 : https://github.com/inventree/InvenTree/pull/11177
|
v443 -> 2026-01-21 : https://github.com/inventree/InvenTree/pull/11177
|
||||||
- Adds IPN ordering option for BomItem API endpoint
|
- Adds IPN ordering option for BomItem API endpoint
|
||||||
- Adds IPN ordering option for BuildLine API endpoint
|
- Adds IPN ordering option for BuildLine API endpoint
|
||||||
|
|||||||
@@ -227,6 +227,7 @@ ldap:
|
|||||||
# navbar_message: <h6>InvenTree demo mode <a href='https://inventree.org/demo.html'><span class='fas fa-info-circle'></span></a></h6>
|
# navbar_message: <h6>InvenTree demo mode <a href='https://inventree.org/demo.html'><span class='fas fa-info-circle'></span></a></h6>
|
||||||
# hide_admin_link: true
|
# hide_admin_link: true
|
||||||
# hide_password_reset: true
|
# hide_password_reset: true
|
||||||
|
# disable_theme_storage: true
|
||||||
# logo: img/custom_logo.png
|
# logo: img/custom_logo.png
|
||||||
# splash: img/custom_splash.jpg
|
# splash: img/custom_splash.jpg
|
||||||
|
|
||||||
|
|||||||
@@ -270,7 +270,15 @@ function observeProfile() {
|
|||||||
const user = useUserState.getState().getUser();
|
const user = useUserState.getState().getUser();
|
||||||
const { language, setLanguage, userTheme, setTheme, setWidgets, setLayouts } =
|
const { language, setLanguage, userTheme, setTheme, setWidgets, setLayouts } =
|
||||||
useLocalState.getState();
|
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) {
|
if (user) {
|
||||||
|
// set profile language
|
||||||
if (user.profile?.language && language != user.profile.language) {
|
if (user.profile?.language && language != user.profile.language) {
|
||||||
showNotification({
|
showNotification({
|
||||||
title: t`Language changed`,
|
title: t`Language changed`,
|
||||||
@@ -281,6 +289,7 @@ function observeProfile() {
|
|||||||
setLanguage(user.profile.language, true);
|
setLanguage(user.profile.language, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set profile theme
|
||||||
if (user.profile?.theme) {
|
if (user.profile?.theme) {
|
||||||
// extract keys of usertheme and set them to the values of user.profile.theme
|
// extract keys of usertheme and set them to the values of user.profile.theme
|
||||||
const newTheme = Object.keys(userTheme).map((key) => {
|
const newTheme = Object.keys(userTheme).map((key) => {
|
||||||
@@ -302,6 +311,7 @@ function observeProfile() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set profile widgets/layouts
|
||||||
if (user.profile?.widgets) {
|
if (user.profile?.widgets) {
|
||||||
const data = user.profile.widgets;
|
const data = user.profile.widgets;
|
||||||
// split data into widgets and layouts (either might be undefined)
|
// split data into widgets and layouts (either might be undefined)
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export interface ServerAPIProps {
|
|||||||
splash: string;
|
splash: string;
|
||||||
login_message: string;
|
login_message: string;
|
||||||
navbar_message: string;
|
navbar_message: string;
|
||||||
|
disable_theme_storage: boolean;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user