A download row keeps play (pause / resume / retry in the queue) and the save link; the editors, sharing, re-download, the copies and cancel / delete / remove moved into its "…" (useDownloadActions). A link inside the row keeps the browser's own right-click menu. A notification row keeps its link and its unread mark and shows its dismiss on hover; an activity notice's Find in feed and Undo are in its "…". The inbox band keeps Mark all read and puts Clear everything, now behind a confirm, in its "…". The Scheduler strip keeps Run all and Pause and puts Purge discovery in its "…". Polled lists key their menus by id (keyOf). ui/menuGroups draws a rule only between two non-empty groups. Find in feed also drops the tag, search and age filters that could hide the video it looks for.
13 lines
618 B
TypeScript
13 lines
618 B
TypeScript
import { type ActionMenuItem } from "./ActionMenu";
|
|
|
|
/** One menu from its groups, a rule between each two that are not empty: the first row of every
|
|
* group but the first carries `separatorBefore`. An empty group leaves no rule behind, so a row
|
|
* that a job's kind or state takes out cannot strand a divider at the top or doubled in the middle. */
|
|
export function menuGroups(...groups: readonly (readonly ActionMenuItem[])[]): ActionMenuItem[] {
|
|
return groups
|
|
.filter((g) => g.length > 0)
|
|
.flatMap((g, gi) =>
|
|
g.map((it, i) => (i === 0 && gi > 0 ? { ...it, separatorBefore: true } : it)),
|
|
);
|
|
}
|