feat: implement force enable/disable functionality for plugins and themes

This commit is contained in:
Linus Rath
2026-03-26 18:59:30 +01:00
parent 7a191cf78b
commit 37bc88dbad
9 changed files with 301 additions and 21 deletions
+4 -2
View File
@@ -27,6 +27,7 @@ export interface ServerPlugin {
permissions: string[];
entrypoint: string;
enabled: boolean;
forceEnabled?: boolean;
installedAt: string;
updatedAt: string;
}
@@ -39,6 +40,7 @@ export interface ServerTheme {
description: string;
variants: string[];
enabled: boolean;
forceEnabled?: boolean;
installedAt: string;
updatedAt: string;
}
@@ -113,7 +115,7 @@ export async function savePlugin(
await writeJsonFile(pluginRegistryPath(), registry);
}
export async function updatePluginMeta(id: string, updates: Partial<Pick<ServerPlugin, 'enabled'>>): Promise<ServerPlugin | null> {
export async function updatePluginMeta(id: string, updates: Partial<Pick<ServerPlugin, 'enabled' | 'forceEnabled'>>): Promise<ServerPlugin | null> {
const registry = await getPluginRegistry();
const idx = registry.plugins.findIndex(p => p.id === id);
if (idx < 0) return null;
@@ -182,7 +184,7 @@ export async function saveTheme(
await writeJsonFile(themeRegistryPath(), registry);
}
export async function updateThemeMeta(id: string, updates: Partial<Pick<ServerTheme, 'enabled'>>): Promise<ServerTheme | null> {
export async function updateThemeMeta(id: string, updates: Partial<Pick<ServerTheme, 'enabled' | 'forceEnabled'>>): Promise<ServerTheme | null> {
const registry = await getThemeRegistry();
const idx = registry.themes.findIndex(t => t.id === id);
if (idx < 0) return null;
+6
View File
@@ -74,6 +74,10 @@ export interface SettingsPolicy {
features: FeatureGates;
defaults: Record<string, unknown>;
themePolicy: ThemePolicy;
/** Plugin IDs that are force-enabled (users cannot disable) */
forceEnabledPlugins: string[];
/** Theme IDs that are force-enabled (users cannot deactivate) */
forceEnabledThemes: string[];
}
export const DEFAULT_POLICY: SettingsPolicy = {
@@ -81,6 +85,8 @@ export const DEFAULT_POLICY: SettingsPolicy = {
features: { ...DEFAULT_FEATURE_GATES },
defaults: {},
themePolicy: { ...DEFAULT_THEME_POLICY },
forceEnabledPlugins: [],
forceEnabledThemes: [],
};
export interface AuditEntry {