feat: add plugin/theme disable gates and move policy controls to their admin pages
- Add `pluginsEnabled` and `themesEnabled` master feature gates to FeatureGates - Move theme policy UI (default theme, built-in/admin theme toggles, user uploads toggle) from policy page to themes admin page - Add plugin policy UI (plugins enabled toggle) to plugins admin page - Remove theme policy section and plugin/theme gates from policy page (with note directing to respective pages) - Hide Themes and Plugins settings tabs when their feature gate is disabled - Fix dark mode visibility of all admin toggle switches (bg-white → bg-background, increase off-state track opacity)
This commit is contained in:
+16
-2
@@ -1,6 +1,6 @@
|
||||
import { create } from 'zustand';
|
||||
import type { SettingsPolicy, FeatureGates, SettingRestriction } from '@/lib/admin/types';
|
||||
import { DEFAULT_POLICY } from '@/lib/admin/types';
|
||||
import type { SettingsPolicy, FeatureGates, SettingRestriction, ThemePolicy } from '@/lib/admin/types';
|
||||
import { DEFAULT_POLICY, DEFAULT_THEME_POLICY } from '@/lib/admin/types';
|
||||
|
||||
interface PolicyState {
|
||||
policy: SettingsPolicy;
|
||||
@@ -11,6 +11,8 @@ interface PolicyState {
|
||||
isFeatureEnabled: (feature: keyof FeatureGates) => boolean;
|
||||
getRestriction: (key: string) => SettingRestriction | undefined;
|
||||
getEffectiveDefault: (key: string) => unknown;
|
||||
getThemePolicy: () => ThemePolicy;
|
||||
isThemeDisabled: (themeId: string, isBuiltIn: boolean) => boolean;
|
||||
}
|
||||
|
||||
export const usePolicyStore = create<PolicyState>()((set, get) => ({
|
||||
@@ -52,4 +54,16 @@ export const usePolicyStore = create<PolicyState>()((set, get) => ({
|
||||
getEffectiveDefault: (key) => {
|
||||
return get().policy.defaults[key];
|
||||
},
|
||||
|
||||
getThemePolicy: () => {
|
||||
return get().policy.themePolicy || { ...DEFAULT_THEME_POLICY };
|
||||
},
|
||||
|
||||
isThemeDisabled: (themeId, isBuiltIn) => {
|
||||
const tp = get().policy.themePolicy || DEFAULT_THEME_POLICY;
|
||||
if (isBuiltIn) {
|
||||
return (tp.disabledBuiltinThemes || []).includes(themeId);
|
||||
}
|
||||
return (tp.disabledThemes || []).includes(themeId);
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user