// 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, ); }