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.
This commit is contained in:
parent
b2e3b05198
commit
464b52004b
1 changed files with 192 additions and 239 deletions
25
frontend/packages/shared/src/links-menu/links.ts
Normal file
25
frontend/packages/shared/src/links-menu/links.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// What the links menu shows for one link, without a DOM: where it opens and
|
||||
// what it is called. Shared by the swarm UI (its `/api/links`) and the hive
|
||||
// dashboard (its stats and API docs pages, and the swarm UI).
|
||||
|
||||
/** One entry of the links menu. */
|
||||
export interface MenuLink {
|
||||
label: string;
|
||||
/** A glyph before the label; none leaves the label alone. */
|
||||
icon?: string;
|
||||
url: string;
|
||||
/**
|
||||
* Opens in a new tab. Defaults to true: a link the menu was handed from
|
||||
* elsewhere (the swarm's service list) leaves the page. A page of the
|
||||
* same site says `false` and opens in place.
|
||||
*/
|
||||
external?: boolean;
|
||||
}
|
||||
|
||||
/** The anchor attributes that make a link open where its entry says. */
|
||||
export function linkAttrs(link: MenuLink): {
|
||||
target?: string;
|
||||
rel?: string;
|
||||
} {
|
||||
return link.external === false ? {} : { target: "_blank", rel: "noreferrer" };
|
||||
}
|
||||
Loading…
Reference in a new issue