Watch
0
0
Fork
You've already forked hyperhive
0

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.
This commit is contained in:
iris 2026-11-21 10:21:21 +01:00
commit 7707a257e9
12 changed files with 250 additions and 367 deletions

View file

@ -5,7 +5,8 @@
"description": "hive-c0re dashboard SPA. Bundled by esbuild into a static dist; served by the hive-c0re Rust binary at runtime via tower_http::ServeDir.",
"type": "module",
"scripts": {
"build": "node ./build.mjs"
"build": "node ./build.mjs",
"test": "node --test test/*.test.mjs"
},
"dependencies": {
"@hive/shared": "*",

View file

@ -128,23 +128,3 @@ code {
color: var(--amber);
border-color: var(--amber);
}
/* ─── page-content gutter ─────────────────────────────────────────────
Inverted-gutter layout: the dashboard keeps `<body>` full-bleed
and wraps their padded content in a single `.page-content` div that
carries the horizontal gutter. Full-width chrome (the tab strip, the
footer) then spans edge-to-edge for free,
with no negative-margin breakout hacks. Only matches on pages that opt
in by adding the wrapper (index.html). */
.page-content {
padding: 0 1.5em;
}
/* ─── sticky top region ───────────────────────────────────────────────
One sticky container per page holding the page chrome (tab bar / page
header). common.js (initStickyTop) wraps the chrome in this on load. */
.sticky-top {
position: sticky;
top: 0;
z-index: 50;
}

View file

@ -282,23 +282,3 @@ export function openStream(url) {
noteWorkerActivity();
return target;
}
// ─── sticky top region ───────────────────────────────────────────────
// One sticky container wrapping the page's chrome (tab bar / page
// header), built once by wrapping the existing chrome element. A page
// without a chrome (none today) gets an empty sticky region at the top of
// <body>.
export function initStickyTop() {
let top = document.querySelector(".sticky-top");
if (top) return top;
top = document.createElement("div");
top.className = "sticky-top";
const chrome = document.querySelector(".dashboard-chrome, .page-header");
if (chrome && chrome.parentNode) {
chrome.parentNode.insertBefore(top, chrome);
top.append(chrome);
} else {
document.body.prepend(top);
}
return top;
}

View file

@ -9,17 +9,20 @@
@import "@hive/shared/jobq-graph.css";
@import "@hive/shared/user-menu.css";
@import "@hive/shared/links-menu.css";
@import "@hive/shared/app-shell.css";
@import "@hive/shared/icon-button.css";
@import "@hive/shared/settings-menu.css";
@import "@hive/shared/solid-backgrounds.css";
/* ─── tabbed dashboard chrome ──────────────────────────────────────
Top-of-page sticky header with banner + tab strip. SSE stays
alive across tab switches. See docs/4-implementation/web-ui/dashboard.md::Chrome header + Tab strip for the
routing model. */
/* ─── the dashboard page ───────────────────────────────────────────
The chrome (header, nav, settings) is `@hive/shared`'s AppShell, drawn by
shell.js; SSE stays alive across tab switches. See
docs/4-implementation/web-ui/dashboard.md::Chrome header + Tab strip. */
body.dashboard-shell {
/* Full-bleed body (no horizontal gutter). The 1.5em side gutter lives
on the inner `.page-content` wrapper (see common.css), so the sticky
chrome bar and the footer span the full
width edge-to-edge with no negative-margin breakout. `padding-bottom`
in the shell's content column, so the footer spans the full width
edge-to-edge with no negative-margin breakout. `padding-bottom`
keeps a little breathing room above the viewport edge (overridden to
clear the selection bar via `.has-selection` below). No max-width cap
— wide screens use the full width rather than empty side margins. */
@ -27,40 +30,6 @@ body.dashboard-shell {
padding-bottom: 1.5em;
}
.dashboard-chrome {
/* Pages menu + tab strip share one row (flex). The chrome owns the
horizontal gutter and the single full-width bottom divider; its
children drop their own side padding / border so they sit inline. */
display: flex;
align-items: center;
gap: 0.75em;
/* Stickiness lives on the `.sticky-top` wrapper (common.css) that
common.js wraps this chrome in. */
background: color-mix(
in srgb,
var(--bg) calc(100% - 14% * var(--glass-clear)),
transparent
);
-webkit-backdrop-filter: var(--glass-filter);
backdrop-filter: var(--glass-filter);
border-bottom: 1px solid var(--purple-dim);
padding: 0.3em 1em;
margin: 0 0 1em;
}
/* The pages menu and the profile menu, together at the right end of the
chrome. Their own looks are `@hive/shared/links-menu.css`'s and
`@hive/shared/user-menu.css`'s. */
.dashboard-chrome-actions {
display: flex;
align-items: center;
gap: 0.25em;
flex: none;
margin-left: auto;
}
.links-menu-slot,
.user-menu-slot {
flex: none;
}
.banner-thin {
text-align: center;
margin: 0;
@ -73,52 +42,8 @@ body.dashboard-shell {
text-overflow: ellipsis;
}
.tabbar {
display: flex;
flex-wrap: nowrap;
align-items: center;
gap: 0.2em;
/* On one row with the chrome's menus; the chrome owns the gutter +
the bottom divider, so no outer padding / border here. */
}
/* Shares the flat-pill aesthetic of the shared `.hive-tab` (sub-tabs on
the standalone pages) so the chrome reads as one family. Kept a touch
weightier than bare `.hive-tab` — larger font, bold labels, count
pills — since this is the dashboard's primary nav, not a sub-strip. */
.tabbar .tab {
display: inline-flex;
align-items: center;
gap: 0.5em;
flex-shrink: 0;
padding: 0.4em 0.95em;
color: var(--muted);
font-family: inherit;
font-size: 0.92em;
letter-spacing: 0.06em;
text-decoration: none;
border: 0;
border-radius: 4px;
cursor: pointer;
transition:
color 0.15s ease,
background 0.15s ease;
}
.tabbar .tab:hover {
color: var(--fg);
background: var(--border);
}
.tabbar .tab.hive-tab--active {
color: var(--purple);
background: var(--border);
}
.tab-label {
font-weight: bold;
white-space: nowrap;
}
/* Tab pane visibility — createTabStrip (@hive/shared/tabs.js) sets the
`hidden` attribute on every inactive pane (resolved from the URL hash;
default — no hash — is 4G3NTS). Only the active pane stays visible. */
/* Tab pane visibility: shell.js sets the `hidden` attribute on every pane but
the one the URL hash names. */
.tab-pane[hidden] {
display: none;
}

View file

@ -11,141 +11,78 @@
<link rel="stylesheet" href="/static/dashboard.css" />
</head>
<body class="dashboard-shell">
<!-- Sticky chrome — just the tab strip. The "WE ARE THE WIRED"
slug lives at the page footer below `<main>`; chrome is
navigation only. Tabs route via the URL hash so F5 / back-
button / shared links keep you on the same view. JS owns
the show/hide. -->
<header class="dashboard-chrome">
<nav class="tabbar" id="tabbar" role="tablist">
<a
class="tab"
id="tab-agents"
href="#agents"
role="tab"
aria-controls="tab-pane-agents"
data-tab="agents"
>
<span class="tab-label">◆ 4G3NTS ◆</span>
</a>
<!-- The build lifecycle is two tabs here (builds.js): the rebuild
queue with its live log, and the build log history. Kept state
(kept.js) is the third. -->
<a
class="tab"
id="tab-rebuild"
href="#rebuild"
role="tab"
aria-controls="tab-pane-rebuild"
data-tab="rebuild"
>
<span class="tab-label">◆ R3BU1LD QU3U3 ◆</span>
</a>
<!-- The page chrome: the header, the nav and the settings menu, drawn by
shell.js (@hive/shared's AppShell, the swarm UI's chrome). Tabs route
via the URL hash so F5 / back-button / shared links keep you on the
same view. -->
<div id="app-shell"></div>
<a
class="tab"
id="tab-kept"
href="#kept"
role="tab"
aria-controls="tab-pane-kept"
data-tab="kept"
>
<span class="tab-label">◆ K3PT ST4T3 ◆</span>
</a>
<!-- (Peer hives are no longer a tab — they render as a headline
under 4G3NTS. See tab-pane-agents.) -->
</nav>
<!-- The pages menu and the profile menu, together at the right.
Pages menu: the API docs and the swarm UI, filled by links-menu.js
from /api/state. Profile menu: the signed-in user, filled by
user-menu.js. -->
<div class="dashboard-chrome-actions">
<div class="links-menu-slot" id="links-menu"></div>
<div class="user-menu-slot" id="user-menu"></div>
</div>
</header>
<!-- Tab panes. createTabStrip (@hive/shared/tabs.js) keeps exactly one
visible by toggling the `hidden` attribute, resolved from the URL
hash (default 4G3NTS). Panes start `hidden` to avoid a flash before
the script runs. -->
<!-- Padded content wrapper: carries the 1.5em side gutter
(.page-content, common.css) while <body> stays full-bleed so the
sticky chrome above + the footer below span the full width. -->
<div class="page-content">
<main class="dashboard-main">
<!-- 4G3NTS: the agents. Container cards (the central thing
the operator looks at) and rebuild queue / cascade visualisation
that drives them. No inline `C0NTAINERS` h2 heading + divider
— the tab label 4G3NTS already says it. -->
<section
class="tab-pane"
id="tab-pane-agents"
data-tab-pane="agents"
hidden
role="tabpanel"
aria-labelledby="tab-agents"
>
<!-- Swarm / hive identity headline. Populated by refreshState from
hive_name + swarm_name; stays hidden when neither is set. -->
<h2 id="swarm-identity" hidden></h2>
<!-- JobqRollup mount point, kept outside #containers-section
<!-- The tab panes, kept here hidden until shell.js moves them into the
shell's content column and shows the one the hash names. -->
<div id="pane-store" hidden>
<!-- agents: the containers. Container cards (the central thing the
operator looks at) and the rebuild queue / cascade visualisation
that drives them. -->
<section
class="tab-pane"
id="tab-pane-agents"
data-tab-pane="agents"
hidden
role="tabpanel"
>
<!-- JobqRollup mount point, kept outside #containers-section
deliberately — that section is wiped + rebuilt on every
container-list render (see agents.js::renderContainers), which
would tear down and remount the Preact tree on every
container-state tick. Mounted once by agents.js::initJobqRollup,
refreshed via its own handle rather than by re-rendering. -->
<div id="jobq-rollup-section"></div>
<div id="containers-section">
<p class="meta">loading…</p>
</div>
</section>
<div id="jobq-rollup-section"></div>
<div id="containers-section">
<p class="meta">loading…</p>
</div>
</section>
<!-- R3BU1LD QU3U3: pending + running rebuilds and first-spawns. Rendered from GET /api/jobq/graph by the
<!-- R3BU1LD QU3U3: pending + running rebuilds and first-spawns. Rendered from GET /api/jobq/graph by the
`JobqGraph` Preact component (@hive/shared/jobq-graph.js);
`rebuild_queue_changed` over /api/dashboard/stream is the
refresh trigger and carries no payload of its own. -->
<section
class="tab-pane"
id="tab-pane-rebuild"
data-tab-pane="rebuild"
hidden
role="tabpanel"
aria-labelledby="tab-rebuild"
>
<p class="meta">
pending + running rebuilds and first-spawns. one runs at a time.
dedup: re-enqueueing a still-queued op collapses into the existing
entry.
</p>
<div id="rebuild-queue-section">
<p class="meta">loading…</p>
</div>
</section>
<section
class="tab-pane"
id="tab-pane-rebuild"
data-tab-pane="rebuild"
hidden
role="tabpanel"
>
<p class="meta">
pending + running rebuilds and first-spawns. one runs at a time.
dedup: re-enqueueing a still-queued op collapses into the existing
entry.
</p>
<div id="rebuild-queue-section">
<p class="meta">loading…</p>
</div>
</section>
<!-- K3PT ST4T3: kept state from agents whose container is absent,
<!-- K3PT ST4T3: kept state from agents whose container is absent,
with a purge button per row. Rendered by kept.js; refreshed by the
`tombstones_changed` stream event. -->
<section
class="tab-pane"
id="tab-pane-kept"
data-tab-pane="kept"
hidden
role="tabpanel"
aria-labelledby="tab-kept"
>
<p class="meta">
kept state from previously tombstoned agents — recreating an agent
with the same name reuses it.
</p>
<div id="tombstones-section">
<p class="meta">loading…</p>
</div>
</section>
</main>
<section
class="tab-pane"
id="tab-pane-kept"
data-tab-pane="kept"
hidden
role="tabpanel"
>
<p class="meta">
kept state from previously tombstoned agents — recreating an agent
with the same name reuses it.
</p>
<div id="tombstones-section">
<p class="meta">loading…</p>
</div>
</section>
</div>
<!-- /.page-content -->
<!-- /#pane-store -->
<footer>
<pre class="banner banner-thin">

View file

@ -1,35 +0,0 @@
// Pages menu in the dashboard chrome: one icon button, beside the profile
// avatar at the right, that opens a popover linking the standalone pages
// (API docs) and the swarm UI. It is `@hive/shared`'s `LinksMenu`, the
// same component the swarm UI mounts for its service links, rendered with
// Preact like the profile menu. The swarm entry only exists when `/api/state`
// carries `swarm_public_url`, so a hive without a configured swarm domain
// shows no dead link.
import { h, render } from "preact";
import { LinksMenu } from "@hive/shared/links-menu.js";
import { $ } from "./common.js";
/** 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. */
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;
}
/** (Re)render the menu into `#links-menu`. Safe to call on every state
* refresh: Preact diffs the same component, so an open popover stays open. */
export function renderLinksMenu(state) {
const root = $("links-menu");
if (!root) return;
render(h(LinksMenu, { links: menuLinks(state), label: "pages" }), root);
}

View file

@ -0,0 +1,29 @@
// 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;
}

View file

@ -0,0 +1,88 @@
// The hive UI's page chrome: `@hive/shared`'s `AppShell`, the same header, nav
// row and settings menu the swarm UI has, with the hive's name for a brand and
// the dashboard's three tabs. Routes are the URL hash (`#agents`, `#rebuild`,
// `#kept`), so the gateway needs nothing beyond serving `index.html`.
//
// The tab panes stay plain DOM, built by `agents.js`, `builds.js` and
// `kept.js`: `index.html` keeps them in a hidden store, and `Panes` moves them
// into the shell's content column and shows the one the hash names.
import { h, render } from "preact";
import { useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
import { AppShell } from "@hive/shared/app-shell.js";
import { LinksMenu } from "@hive/shared/links-menu.js";
import { UserMenu } from "@hive/shared/user-menu.js";
import { TABS, menuLinks, tabOfHash } from "./shell-routes.js";
// Storage keys of the shared settings, this page's own: the swarm UI is
// another origin, so a choice made there is not seen here.
const THEME_KEY = "hive-ui:theme-override";
const MOTION_KEY = "hive-ui:motion-override";
const SOLID_KEY = "hive-ui:solid-backgrounds";
function useHashTab() {
const [tab, setTab] = useState(() => tabOfHash(location.hash));
useEffect(() => {
const onHash = () => setTab(tabOfHash(location.hash));
window.addEventListener("hashchange", onHash);
return () => window.removeEventListener("hashchange", onHash);
}, []);
return tab;
}
// A nav link for a hash route.
function HashLink({ href, className, children, ...rest }) {
return h("a", { href: "#" + href, class: className, ...rest }, children);
}
// The tab panes, moved out of the store into the content column. The shell
// remounts its content on every navigation, which moves them in again.
function Panes({ tab, panes, onShow }) {
const box = useRef(null);
useLayoutEffect(() => {
box.current.append(...panes);
for (const pane of panes) pane.hidden = pane.dataset.tabPane !== tab;
onShow(tab);
}, [tab]);
return h("div", { ref: box });
}
function Hive({ state, panes, onShow }) {
const tab = useHashTab();
return h(
AppShell,
{
brand: (state && state.hive_name) || "hive",
brandHref: TABS[0].href,
items: TABS,
location: tab,
LinkComponent: HashLink,
themeKey: THEME_KEY,
motionKey: MOTION_KEY,
solidKey: SOLID_KEY,
menus: [
h(LinksMenu, { links: menuLinks(state), label: "pages", key: "links" }),
h(UserMenu, {
whoamiUrl: "/api/whoami",
autheliaUrl: (state && state.authelia_public_url) || null,
key: "user",
}),
],
},
h(Panes, { tab, panes, onShow }),
);
}
/** (Re)render the shell into `#app-shell` for a state snapshot (`null` before
* the first one). Safe to call on every refresh: Preact diffs the same tree,
* so an open menu stays open. `onShow(tabId)` runs whenever a tab is shown. */
export function renderShell(state, onShow) {
const root = document.getElementById("app-shell");
if (!root) return;
if (!renderShell.panes) {
renderShell.panes = Array.from(
document.querySelectorAll("[data-tab-pane]"),
);
}
render(h(Hive, { state, panes: renderShell.panes, onShow }), root);
}

View file

@ -8,10 +8,9 @@
// live in `./common.js`.
// 4G3NTS (containers) domain lives in `./agents.js`.
import { $, openStream, initStickyTop } from "./common.js";
import { $, openStream } from "./common.js";
import { el } from "@hive/shared/dom.js";
import { bindAsyncForms } from "@hive/shared/forms.js";
import { createTabStrip } from "@hive/shared/tabs.js";
import { containersState, syncContainersFromSnapshot } from "./state.js";
import {
initJobqRollup,
@ -30,12 +29,9 @@ import {
renderKept,
syncKeptFromSnapshot,
} from "./kept.js";
import { renderLinksMenu } from "./links-menu.js";
import { renderUserMenu } from "./user-menu.js";
import { renderShell } from "./shell.js";
(() => {
initStickyTop();
// ─── async forms ────────────────────────────────────────────────────────
// Shared `data-async` submit interceptor (in common.js, shared with the other
// pages' bundles). On success it re-runs refreshState unless the form
@ -121,23 +117,6 @@ import { renderUserMenu } from "./user-menu.js";
// synchronous read (e.g. the compose autocomplete pulls agent
// names from here instead of refetching on every keystroke).
window.__hyperhive_state = s;
// Hive identity: render the swarm/hive name as a headline at the
// top of the 4G3NTS pane + update the page title once the
// server-side display names are known. `hive_name` / `swarm_name`
// come from HYPERHIVE_HIVE_NAME / HYPERHIVE_SWARM_NAME env vars
// (set by services.hyperhive.{hiveName,swarmName} nix options).
// When unset we fall back gracefully — the headline stays hidden.
const hiveId = $("swarm-identity");
if (hiveId) {
const hive = s.hive_name;
const swarm = s.swarm_name;
if (hive || swarm) {
const label = swarm && hive ? `${swarm} / ${hive}` : hive || swarm;
hiveId.textContent = label;
hiveId.hidden = false;
document.title = label + " // h1ve-c0re";
}
}
const openDetails = snapshotOpenDetails();
// Sync transients + containers first so renderContainers below
// sees the current derived maps (it reads from
@ -155,8 +134,7 @@ import { renderUserMenu } from "./user-menu.js";
syncKeptFromSnapshot(s);
renderContainers(s);
renderKept();
renderLinksMenu(s);
renderUserMenu(s);
renderShell(s, activateTab);
renderHiveRev(s.hyperhive_rev);
restoreOpenDetails(openDetails);
// No periodic refresh timer. Phase 6 covers every container
@ -256,16 +234,8 @@ import { renderUserMenu } from "./user-menu.js";
})();
// ─── tab routing ───────────────────────────────────────────────────────
// Hash-based: `#agents` / `#rebuild` / `#kept`
// activate the matching pane on the dashboard. Empty
// hash defaults to 4G3NTS. Tab routing only applies when the tab DOM is
// present.
// The shared hash-routed tab strip (@hive/shared/tabs.js) owns the
// tab/pane toggle + aria-selected + routing; `activateTab` runs the
// per-tab side-effects via the strip's onShow. Constructed below (after
// the lazy-load fns it calls are defined). The responsive overflow menu
// was dropped — if the strip ever runs out of room we move panes
// to their own pages rather than hide them in a dropdown.
// The shell (`shell.js`) routes by the URL hash (`#agents`, `#rebuild`,
// `#kept`; none means agents) and calls this each time a tab is shown.
function activateTab(target) {
// Track active tab on the body so renderSelectionBar can gate
// visibility (bar only belongs on 4G3NTS where agent cards live).
@ -273,11 +243,8 @@ import { renderUserMenu } from "./user-menu.js";
renderSelectionBar(Array.from(containersState.values()));
}
// Wire the shared tab strip now that activateTab + the lazy-load fns it
// calls are defined. The strip resolves the active tab from the hash
// (default 4G3NTS), toggles the active tab/pane + aria-selected, and
// fires activateTab for the per-tab side-effects on every change.
createTabStrip($("tabbar"), { defaultId: "agents", onShow: activateTab });
// Draw the shell before the first state arrives, so the page has its frame.
renderShell(null, activateTab);
// The rebuild queue mounts now, not on first show.
initBuilds();
})();

View file

@ -1,24 +0,0 @@
// Profile menu in the dashboard chrome, at the right of the tab strip: the
// signed-in user's avatar, name, and links to authelia's settings and
// sign-out. It is `@hive/shared`'s `UserMenu`, the same component the swarm UI
// and the per-agent page mount, rendered with Preact like the job-queue
// graph. `/api/whoami` is proxied to authelia by this dashboard's own nginx
// vhost, so it needs no CORS; authelia's URL comes from `/api/state`.
import { h, render } from "preact";
import { UserMenu } from "@hive/shared/user-menu.js";
import { $ } from "./common.js";
/** (Re)render the menu into `#user-menu`. Safe to call on every state
* refresh: Preact diffs the same component, so an open popover stays open. */
export function renderUserMenu(state) {
const root = $("user-menu");
if (!root) return;
render(
h(UserMenu, {
whoamiUrl: "/api/whoami",
autheliaUrl: (state && state.authelia_public_url) || null,
}),
root,
);
}

View file

@ -0,0 +1,29 @@
// The hive UI's tab routing and menu entries. Run by `npm test`.
import assert from "node:assert/strict";
import { test } from "node:test";
import { TABS, menuLinks, tabOfHash } from "../src/shell-routes.js";
test("a hash that names a tab shows that tab, with or without the #", () => {
assert.equal(tabOfHash("#rebuild"), "rebuild");
assert.equal(tabOfHash("kept"), "kept");
assert.equal(tabOfHash("#agents"), "agents");
});
test("no hash, or one that names no tab, shows the first tab", () => {
assert.equal(tabOfHash(""), TABS[0].href);
assert.equal(tabOfHash("#"), TABS[0].href);
assert.equal(tabOfHash("#nope"), TABS[0].href);
});
test("the API docs are always linked and open in place", () => {
assert.deepEqual(menuLinks(null), [
{ icon: "🧬", label: "api docs", url: "/api/docs/", external: false },
]);
});
test("the swarm is linked only when the state names its address", () => {
assert.equal(menuLinks({}).length, 1);
const links = menuLinks({ swarm_public_url: "https://swarm.example" });
assert.equal(links.length, 2);
assert.equal(links[1].url, "https://swarm.example");
});

View file

@ -59,6 +59,7 @@
"./show-thinking-setting.js": "./src/settings/ShowThinkingSetting.tsx",
"./expand-details-setting.js": "./src/settings/ExpandDetailsSetting.tsx",
"./settings-menu.css": "./src/settings/SettingsMenu.css",
"./solid-backgrounds.css": "./src/settings/solid-backgrounds.css",
"./solid-backgrounds.js": "./src/settings/solid-backgrounds.tsx",
"./user-menu.js": "./src/user-menu/UserMenu.tsx",
"./user-menu.css": "./src/user-menu/UserMenu.css",