refactor(ui): drive sidebar and topbar breadcrumbs from file-based routes

This commit is contained in:
sam committed 2026-11-27 16:32:06 +11:00
1 parent 936c5267f0
commit ccb36a1ca9
7 files changed
+20 -22

No files matched your search

+12 -16
View File
@@ -37,12 +37,16 @@ const route = useRoute();
const router = useRouter();
const workflowsPage = computed(() => route.name === "workflow");
const hidden = computed(() => hiddenPaths(session.sections));
const sectionLink = computed(() => ({
workflow: "/workflows",
run: "/runs",
"controls-guard": "/controls/guards",
"controls-action-type": "/controls/action-types",
})[String(route.name)]);
const sectionLink = computed(() =>
route.meta.nav === false && typeof route.meta.navPath === "string"
? route.meta.navPath
: undefined,
);
const detailCrumb = computed(() => {
if (route.meta.nav !== false || !("id" in route.params) || !route.params.id) return "";
const id = String(route.params.id);
return route.name === "run" ? id.slice(0, 8) : id;
});
// The redirect below must not run during the router's first navigation: route
// is still the start location then, so a deep link would be replaced by the
// landing page before it resolves.
@@ -127,17 +131,9 @@ watch(() => accounts.status?.user, (user) => {
<BreadcrumbItem><OrgCrumb /></BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem><SectionCrumb :hidden="hidden" :link="sectionLink" /></BreadcrumbItem>
<template v-if="route.name === 'workflow'">
<template v-if="detailCrumb">
<BreadcrumbSeparator class="max-md:hidden" />
<BreadcrumbItem class="min-w-0 max-md:hidden"><BreadcrumbPage class="truncate">{{ route.params.id }}</BreadcrumbPage></BreadcrumbItem>
</template>
<template v-else-if="route.name === 'run'">
<BreadcrumbSeparator class="max-md:hidden" />
<BreadcrumbItem class="min-w-0 max-md:hidden"><BreadcrumbPage class="truncate font-mono">{{ String(route.params.id).slice(0, 8) }}</BreadcrumbPage></BreadcrumbItem>
</template>
<template v-else-if="route.name === 'controls-guard' || route.name === 'controls-action-type'">
<BreadcrumbSeparator class="max-md:hidden" />
<BreadcrumbItem class="min-w-0 max-md:hidden"><BreadcrumbPage class="truncate">{{ route.params.id }}</BreadcrumbPage></BreadcrumbItem>
<BreadcrumbItem class="min-w-0 max-md:hidden"><BreadcrumbPage class="truncate" :class="route.name === 'run' && 'font-mono'">{{ detailCrumb }}</BreadcrumbPage></BreadcrumbItem>
</template>
</BreadcrumbList>
</Breadcrumb>
+3 -1
View File
@@ -1,4 +1,4 @@
import { Building2, FileCheck2, LayoutDashboard, ListChecks, Play, Server, ShieldCheck, Workflow, Zap, type LucideIcon } from "@lucide/vue";
import { Building2, FileCheck2, LayoutDashboard, ListChecks, Play, Server, Shield, ShieldCheck, SlidersHorizontal, Workflow, Zap, type LucideIcon } from "@lucide/vue";
export const navIcons: Record<string, LucideIcon> = {
"/": LayoutDashboard,
@@ -8,6 +8,8 @@ export const navIcons: Record<string, LucideIcon> = {
"/workflows": Workflow,
"/events": Zap,
"/controls": ShieldCheck,
"/controls/guards": Shield,
"/controls/action-types": SlidersHorizontal,
"/org": Building2,
"/settings": Server,
};
+1 -1
View File
@@ -28,7 +28,7 @@ const specs: NavSpec[] = [
{
kind: "group",
label: "Governance",
sections: [{ paths: ["/controls"] }],
sections: [{ paths: ["/controls", "/controls/guards", "/controls/action-types"] }],
},
{
kind: "group",
+1 -1
View File
@@ -20,7 +20,7 @@ definePage({
meta: {
label: "Action type",
nav: false,
navPath: "/controls",
navPath: "/controls/action-types",
section: "controls",
},
});
+1 -1
View File
@@ -19,7 +19,7 @@ definePage({
meta: {
label: "Action types",
description: "Approval levels each action type has earned.",
navPath: "/controls",
navPath: "/controls/action-types",
section: "controls",
},
});
+1 -1
View File
@@ -20,7 +20,7 @@ definePage({
meta: {
label: "Guard",
nav: false,
navPath: "/controls",
navPath: "/controls/guards",
section: "controls",
},
});
+1 -1
View File
@@ -17,7 +17,7 @@ definePage({
meta: {
label: "Guards",
description: "Judges that inspect actions before they run.",
navPath: "/controls",
navPath: "/controls/guards",
section: "controls",
},
});