refactor: use AppTheme type and handle empty admin_basepath

Replace literal theme union with AppTheme type in AdminController options and
make path helpers resilient when admin_basepath is empty.
This commit is contained in:
cameronapak
2025-07-22 08:57:06 -05:00
parent 12ef72d595
commit 9e316a92f6
2 changed files with 5 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ export type AdminControllerOptions = {
html?: string; html?: string;
forceDev?: boolean | { mainPath: string }; forceDev?: boolean | { mainPath: string };
debugRerenders?: boolean; debugRerenders?: boolean;
theme?: "dark" | "light" | "system"; theme?: AppTheme;
logoReturnPath?: string; logoReturnPath?: string;
}; };

View File

@@ -95,12 +95,14 @@ export class AppReduced {
} }
getSettingsPath(path: string[] = []): string { getSettingsPath(path: string[] = []): string {
const base = `~/${this.options.admin_basepath}/settings` const basePath = this.options.admin_basepath ? `~/${this.options.admin_basepath}` : '~';
const base = `${basePath}/settings`
return normalizeAdminPath([base, ...path].join("/")); return normalizeAdminPath([base, ...path].join("/"));
} }
getAbsolutePath(path?: string): string { getAbsolutePath(path?: string): string {
return normalizeAdminPath((path ? `~/${this.options.admin_basepath}/${path}` : `~/${this.options.admin_basepath}`)); const basePath = this.options.admin_basepath ? `~/${this.options.admin_basepath}` : '~';
return normalizeAdminPath(path ? `${basePath}/${path}` : basePath);
} }
getAuthConfig() { getAuthConfig() {