49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
export interface NavItem {
|
|
// Lit only on its own path, not on its children (an index page).
|
|
exact?: boolean;
|
|
href: string;
|
|
key: string;
|
|
label: string;
|
|
}
|
|
|
|
export const SECTIONS: NavItem[] = [
|
|
{ href: "/", key: "1", label: "Now" },
|
|
{ href: "/conversations", key: "2", label: "Conversations" },
|
|
{ href: "/memory", key: "3", label: "Memory" },
|
|
{ href: "/usage", key: "4", label: "Usage" },
|
|
];
|
|
|
|
export const SYSTEM: NavItem = { href: "/system", key: "5", label: "System" };
|
|
|
|
export const SYSTEM_PAGES: NavItem[] = [
|
|
{ exact: true, href: "/system", key: "", label: "Sessions" },
|
|
{ href: "/system/agents", key: "", label: "Agents & endpoints" },
|
|
{ href: "/system/jobs", key: "", label: "Jobs" },
|
|
{ href: "/system/tokens", key: "", label: "Tokens" },
|
|
{ href: "/system/audit", key: "", label: "Audit" },
|
|
];
|
|
|
|
export function isActive(
|
|
pathname: string,
|
|
base: string,
|
|
href: string,
|
|
exact = false
|
|
) {
|
|
const path = pathname.startsWith(base)
|
|
? pathname.slice(base.length)
|
|
: pathname;
|
|
const current = path || "/";
|
|
if (href === "/" || exact) {
|
|
return current === href;
|
|
}
|
|
return current === href || current.startsWith(`${href}/`);
|
|
}
|
|
|
|
export function isSectionActive(pathname: string, base: string, href: string) {
|
|
const path = pathname.startsWith(base)
|
|
? pathname.slice(base.length)
|
|
: pathname;
|
|
const current = path || "/";
|
|
return href === "/" ? current === "/" : current.startsWith(href);
|
|
}
|