Let an installation look different via ENVIRONMENT_NAME and ENVIRONMENT_COLOR

Setting ENVIRONMENT_NAME (and optionally ENVIRONMENT_COLOR, a name or hex
value) gives the sidebar that colour, adds a name badge next to the title and
on the sign-in page, and prefixes the browser tab title, so a dev copy can't
be taken for production. Unset, nothing changes. The colour is validated to a
plain #rrggbb before it reaches the page's styles. A public
GET /api/environment lets the sign-in page use it too.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-13 20:59:25 +02:00
1 parent 44cc9d1cf2
commit 7e196be56d
11 files changed
+253 -3

No files matched your search

+4 -1
View File
@@ -38,6 +38,7 @@ import { api, type CurrentUser, type MaintenanceWindow } from "../api/client";
import { formatRemaining } from "../utils/duration";
import { getTheme, setTheme, type Theme } from "../utils/theme";
import CommandPalette from "../components/CommandPalette";
import { isLightColor, useEnvironment } from "../utils/environment";
type Role = "operator" | "admin";
@@ -163,6 +164,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
const [sidebarOpen, setSidebarOpen] = useState(false);
const [theme, setThemeState] = useState<Theme>(() => getTheme());
const [maintenance, setMaintenance] = useState<MaintenanceWindow[]>([]);
const environment = useEnvironment();
// Everyone sees what's currently silenced, so nobody is left wondering why an alert never came.
useEffect(() => {
@@ -220,7 +222,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
return (
<div className="page">
<aside className="navbar navbar-vertical navbar-expand-lg" data-bs-theme="dark">
<aside className="navbar navbar-vertical navbar-expand-lg" data-bs-theme={environment && isLightColor(environment.color) ? "light" : "dark"}>
<div className="container-fluid">
<button
type="button"
@@ -232,6 +234,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
</button>
<h1 className="navbar-brand navbar-brand-autodark">
<NavLink to="/">Homelab Manager</NavLink>
{environment?.name && <span className="badge ms-2 env-badge">{environment.name}</span>}
</h1>
<div className={`navbar-collapse collapse ${sidebarOpen ? "show" : ""}`}>
<div className="px-3 pt-3 pt-lg-0">