Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/src/shell/LinksMenu.tsx
iris 464b52004b the hive dashboard uses the swarm UI's links menu, beside the profile avatar
The links menu moves into @hive/shared and takes its links as a prop. The swarm
UI feeds it /api/links as before; the dashboard feeds it stats, API docs and the
swarm, and mounts it next to the profile menu in place of its own hamburger on
the left. A link opens in a new tab unless its entry says it is a page of the
same site.
2026-11-01 12:57:32 +01:00

27 lines
884 B
TypeScript

// <LinksMenu> — the swarm UI's links menu: `@hive/shared`'s, fed the swarm's
// service list from `GET /api/links` (the services behind the swarm's vhosts,
// each with its glyph). A failed fetch leaves the list empty, and an empty
// menu draws nothing: no button beats a broken one.
import { useEffect, useState } from "preact/hooks";
import {
LinksMenu as SharedLinksMenu,
type MenuLink,
} from "@hive/shared/links-menu.js";
import "@hive/shared/links-menu.css";
export function LinksMenu() {
const [links, setLinks] = useState<MenuLink[]>([]);
useEffect(() => {
fetch("/api/links")
.then((r) =>
r.ok
? (r.json() as Promise<MenuLink[]>)
: Promise.reject(new Error(`http ${r.status}`)),
)
.then(setLinks)
.catch(() => setLinks([]));
}, []);
return <SharedLinksMenu links={links} label="swarm services" />;
}