mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-15 23:31:29 +00:00
fix(ui): resolve nested tab routes to their sidebar item
legacyKeyForPathname matched the full relative path against a single route segment, so a nested tab route like /caching/health resolved to no key and the shell fell back to the default page, leaving the Caching nav item unhighlighted. Match on the first path segment instead, which fixes every migrated page with nested tab routes (models-and-endpoints too), not just Caching.
This commit is contained in:
parent
8d80f8cba9
commit
6a69d20b5d
2 changed files with 13 additions and 1 deletions
|
|
@ -221,12 +221,22 @@ describe("legacyKeyForPathname", () => {
|
|||
expect(legacyKeyForPathname("/ui/skills")).toBe("skills");
|
||||
});
|
||||
|
||||
it("maps a nested tab route back to its sidebar key via the first path segment", async () => {
|
||||
vi.doMock("@/components/networking", () => ({ serverRootPath: "/" }));
|
||||
const { legacyKeyForPathname } = await import("./migratedPages");
|
||||
|
||||
expect(legacyKeyForPathname("/ui/caching/health")).toBe("caching");
|
||||
expect(legacyKeyForPathname("/ui/caching/coordination-redis/")).toBe("caching");
|
||||
expect(legacyKeyForPathname("/ui/models-and-endpoints/add")).toBe("models");
|
||||
});
|
||||
|
||||
it("returns null for a not-yet-migrated path", async () => {
|
||||
vi.doMock("@/components/networking", () => ({ serverRootPath: "/" }));
|
||||
const { legacyKeyForPathname } = await import("./migratedPages");
|
||||
|
||||
expect(legacyKeyForPathname("/ui/")).toBeNull();
|
||||
expect(legacyKeyForPathname("/ui/some-legacy-page")).toBeNull();
|
||||
expect(legacyKeyForPathname("/ui/some-legacy-page/nested")).toBeNull();
|
||||
});
|
||||
|
||||
it("strips a non-root serverRootPath prefix before matching", async () => {
|
||||
|
|
|
|||
|
|
@ -76,8 +76,10 @@ export function legacyPageHref(pageKey: string): string {
|
|||
export function legacyKeyForPathname(pathname: string): string | null {
|
||||
const base = uiBase();
|
||||
const rel = (pathname.startsWith(base) ? pathname.slice(base.length) : pathname).replace(/^\/+|\/+$/g, "");
|
||||
const firstSegment = rel.split("/")[0] ?? "";
|
||||
if (!firstSegment) return null;
|
||||
for (const [key, segment] of Object.entries(MIGRATED_PAGES)) {
|
||||
if (rel === segment) return key;
|
||||
if (firstSegment === segment) return key;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue