// in the swarm UI's header: the shared profile menu // (`@hive/shared/user-menu.js`) with authelia's URL filled in from // `GET /api/links`, the same source `LinksMenu` shows its "Authelia" entry // from. The name comes from `/api/whoami`, which `swarm-ui.nix` proxies to // authelia's own user info. import { useEffect, useState } from "preact/hooks"; import { UserMenu as SharedUserMenu } from "@hive/shared/user-menu.js"; import "@hive/shared/user-menu.css"; import { clearAnswers } from "../ui/polled/answer-cache.js"; interface ServiceLink { label: string; icon: string; url: string; } export function UserMenu() { const [autheliaUrl, setAutheliaUrl] = useState(null); useEffect(() => { fetch("/api/links") .then((r) => r.ok ? (r.json() as Promise) : Promise.reject(new Error(`http ${r.status}`)), ) .then((links) => { const authelia = links.find((l) => l.label === "Authelia"); if (authelia) setAutheliaUrl(authelia.url); }) .catch(() => { /* cosmetic only: the menu then shows the name without the links */ }); }, []); return ( clearAnswers()} /> ); }