44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { Bot, FileSearch, GitBranch, MessageSquare, ShieldCheck, Split, Terminal, Workflow } from "@lucide/vue";
|
|
import type { Component } from "vue";
|
|
|
|
const GROUP_ICONS: Record<string, Component> = {
|
|
agent: Bot,
|
|
command: Terminal,
|
|
repo: GitBranch,
|
|
gate: ShieldCheck,
|
|
forge: MessageSquare,
|
|
review: FileSearch,
|
|
workflow: Workflow,
|
|
};
|
|
|
|
const GROUP_TITLES: Record<string, string> = {
|
|
agent: "Agents",
|
|
command: "Commands",
|
|
repo: "Repository",
|
|
gate: "Checks",
|
|
forge: "Issues and PRs",
|
|
review: "Review",
|
|
workflow: "Flow",
|
|
};
|
|
|
|
/** The icon for a step type, by the area its name starts with. */
|
|
export function stepIcon(type: string): Component {
|
|
if (type === "parallel") return GitBranch;
|
|
if (type === "switch") return Split;
|
|
return GROUP_ICONS[type.split(".")[0]] ?? Workflow;
|
|
}
|
|
|
|
/** Step type names grouped by area, in a fixed reading order. A type from an
|
|
* area not listed here still appears, under Other, so a new server step type
|
|
* is never missing from the menu. */
|
|
export function stepGroups(types: string[]): { title: string; icon: Component; types: string[] }[] {
|
|
const known = Object.keys(GROUP_TITLES);
|
|
const groups = known.map((group) => ({
|
|
title: GROUP_TITLES[group],
|
|
icon: GROUP_ICONS[group],
|
|
types: types.filter((type) => type.split(".")[0] === group),
|
|
}));
|
|
groups.push({ title: "Other", icon: Workflow, types: types.filter((type) => !known.includes(type.split(".")[0]) && type !== "parallel" && type !== "switch") });
|
|
return groups.filter((group) => group.types.length);
|
|
}
|