feat: fix: enforce admin theme locks and repair theme ZIP bundles

This commit is contained in:
Linus Rath
2026-03-27 19:42:30 +01:00
parent f084b484b7
commit b5d471e9c8
9 changed files with 328 additions and 55 deletions
+11
View File
@@ -12,6 +12,7 @@ interface PolicyState {
getRestriction: (key: string) => SettingRestriction | undefined;
getEffectiveDefault: (key: string) => unknown;
getThemePolicy: () => ThemePolicy;
getForcedThemeId: (availableThemeIds?: string[]) => string | null;
isThemeDisabled: (themeId: string, isBuiltIn: boolean) => boolean;
isPluginForceEnabled: (pluginId: string) => boolean;
isThemeForceEnabled: (themeId: string) => boolean;
@@ -61,6 +62,16 @@ export const usePolicyStore = create<PolicyState>()((set, get) => ({
return get().policy.themePolicy || { ...DEFAULT_THEME_POLICY };
},
getForcedThemeId: (availableThemeIds) => {
const forceEnabledThemes = get().policy.forceEnabledThemes || [];
if (!availableThemeIds || availableThemeIds.length === 0) {
return forceEnabledThemes[0] || null;
}
const available = new Set(availableThemeIds);
return forceEnabledThemes.find((themeId) => available.has(themeId)) || null;
},
isThemeDisabled: (themeId, isBuiltIn) => {
const tp = get().policy.themePolicy || DEFAULT_THEME_POLICY;
if (isBuiltIn) {