From 9e316a92f63ed6990ffdff62c8347bbdf95e8d66 Mon Sep 17 00:00:00 2001 From: cameronapak Date: Tue, 22 Jul 2025 08:57:06 -0500 Subject: [PATCH] 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. --- app/src/modules/server/AdminController.tsx | 2 +- app/src/ui/client/utils/AppReduced.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/modules/server/AdminController.tsx b/app/src/modules/server/AdminController.tsx index 59fcda3..2583a76 100644 --- a/app/src/modules/server/AdminController.tsx +++ b/app/src/modules/server/AdminController.tsx @@ -30,7 +30,7 @@ export type AdminControllerOptions = { html?: string; forceDev?: boolean | { mainPath: string }; debugRerenders?: boolean; - theme?: "dark" | "light" | "system"; + theme?: AppTheme; logoReturnPath?: string; }; diff --git a/app/src/ui/client/utils/AppReduced.ts b/app/src/ui/client/utils/AppReduced.ts index e69f542..2b703d2 100644 --- a/app/src/ui/client/utils/AppReduced.ts +++ b/app/src/ui/client/utils/AppReduced.ts @@ -95,12 +95,14 @@ export class AppReduced { } 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("/")); } 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() {