Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/dashboard/src/shell-routes.js
iris 7707a257e9 hive ui: the dashboard wears the swarm UI's chrome, and its own header, tab strip and menu mounts go
The dashboard mounts @hive/shared's AppShell, the header, nav and settings menu the swarm UI has, from a new shell.js: the hive's name for the brand, the tabs agents, rebuild queue and kept state routed by the URL hash, the theme, motion and solid-background settings in this page's own browser storage, and the shared links and user menus. The three tab panes stay plain DOM, kept hidden in index.html and moved into the shell's content column by shell.js. The tabs, the hash-to-tab parse and the menu entries sit in shell-routes.js, which npm test covers (the dashboard package gets a test script). The old header, the createTabStrip tabbar, the leet tab names, the identity headline and title code, the sticky-top wrapper, the links-menu.js and user-menu.js mounts and their CSS are removed. The docs say the plain tab names and the new chrome.
2026-11-21 10:47:37 +01:00

29 lines
1.1 KiB
JavaScript

// The hive UI's tabs and the pure parts of its routing, kept apart from
// `shell.js` (which needs Preact and the shared shell) so `npm test` can run
// them. Routes are the URL hash.
export const TABS = [
{ href: "agents", label: "agents", accent: "var(--green)" },
{ href: "rebuild", label: "rebuild queue", accent: "var(--yellow)" },
{ href: "kept", label: "kept state", accent: "var(--red)" },
];
/** The tab the URL hash names; the first tab for none or an unknown one. */
export function tabOfHash(hash) {
const id = hash.replace(/^#/, "");
return TABS.some((t) => t.href === id) ? id : TABS[0].href;
}
/** Menu entries for a state snapshot. The API docs open in place; the swarm
* UI is another site, so it opens in a new tab. The swarm entry only exists
* when `/api/state` carries `swarm_public_url`, so a hive without a
* configured swarm domain shows no dead link. */
export function menuLinks(state) {
const links = [
{ icon: "🧬", label: "api docs", url: "/api/docs/", external: false },
];
if (state && state.swarm_public_url) {
links.push({ icon: "🐝", label: "swarm", url: state.swarm_public_url });
}
return links;
}