mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
ui: fix review follow-ups for dashboard tabs
This commit is contained in:
@@ -36,7 +36,7 @@ import {
|
||||
} from "./navigation.ts";
|
||||
import { saveSettings, type UiSettings } from "./storage.ts";
|
||||
import { startThemeTransition, type ThemeTransitionContext } from "./theme-transition.ts";
|
||||
import { resolveTheme, type ResolvedTheme, type ThemeMode } from "./theme.ts";
|
||||
import { colorSchemeForTheme, resolveTheme, type ResolvedTheme, type ThemeMode } from "./theme.ts";
|
||||
import type { AgentsListResult } from "./types.ts";
|
||||
|
||||
type SettingsHost = {
|
||||
@@ -273,7 +273,7 @@ export function applyResolvedTheme(host: SettingsHost, resolved: ResolvedTheme)
|
||||
}
|
||||
const root = document.documentElement;
|
||||
root.dataset.theme = resolved;
|
||||
root.style.colorScheme = resolved;
|
||||
root.style.colorScheme = colorSchemeForTheme(resolved);
|
||||
}
|
||||
|
||||
export function attachThemeListener(host: SettingsHost) {
|
||||
|
||||
9
ui/src/ui/navigation-groups.test.ts
Normal file
9
ui/src/ui/navigation-groups.test.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { TAB_GROUPS } from "./navigation.ts";
|
||||
|
||||
describe("TAB_GROUPS", () => {
|
||||
it("does not expose unfinished settings slices in the sidebar", () => {
|
||||
const settings = TAB_GROUPS.find((group) => group.label === "settings");
|
||||
expect(settings?.tabs).toEqual(["config", "debug", "logs"]);
|
||||
});
|
||||
});
|
||||
@@ -10,16 +10,7 @@ export const TAB_GROUPS = [
|
||||
{ label: "agent", tabs: ["agents", "skills", "nodes"] },
|
||||
{
|
||||
label: "settings",
|
||||
tabs: [
|
||||
"config",
|
||||
"communications",
|
||||
"appearance",
|
||||
"automation",
|
||||
"infrastructure",
|
||||
"aiAgents",
|
||||
"debug",
|
||||
"logs",
|
||||
],
|
||||
tabs: ["config", "debug", "logs"],
|
||||
},
|
||||
] as const;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { parseThemeSelection, resolveTheme } from "./theme.ts";
|
||||
import { colorSchemeForTheme, parseThemeSelection, resolveTheme } from "./theme.ts";
|
||||
|
||||
describe("resolveTheme", () => {
|
||||
it("keeps the legacy mode-only signature working for existing callers", () => {
|
||||
@@ -17,6 +17,11 @@ describe("resolveTheme", () => {
|
||||
expect(resolveTheme("knot")).toBe("openknot-light");
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it("maps resolved theme families back to valid CSS color-scheme values", () => {
|
||||
expect(colorSchemeForTheme("openknot")).toBe("dark");
|
||||
expect(colorSchemeForTheme("dash-light")).toBe("light");
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseThemeSelection", () => {
|
||||
|
||||
@@ -91,3 +91,9 @@ export function resolveTheme(themeOrMode: ThemeName | ThemeMode, mode?: ThemeMod
|
||||
}
|
||||
return resolvedMode === "light" ? "dash-light" : "dash";
|
||||
}
|
||||
|
||||
export function colorSchemeForTheme(theme: ResolvedTheme): "light" | "dark" {
|
||||
return theme === "light" || theme === "openknot-light" || theme === "dash-light"
|
||||
? "light"
|
||||
: "dark";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user