feat(ui,judgement,system): unify nav, surface built-in guards, readiness and decision reasoning
This commit is contained in:
34 files changed
+548
-103
No files matched your search
@@ -0,0 +1,88 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
import { PanelLeftClose, PanelLeftOpen } from "@lucide/vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { useSidebar } from "@/components/ui/sidebar/utils";
|
||||
import { activeNavPath, navTree } from "@/lib/nav";
|
||||
import { navIcons } from "@/lib/nav-icons";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const props = defineProps<{ hidden: string[] }>();
|
||||
|
||||
const route = useRoute();
|
||||
const { open, toggleSidebar, isMobile } = useSidebar();
|
||||
|
||||
const nodes = computed(() => navTree(props.hidden));
|
||||
const activePath = computed(() =>
|
||||
typeof route.meta.navPath === "string" ? route.meta.navPath : activeNavPath(route.path),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<aside
|
||||
v-if="!isMobile"
|
||||
aria-label="Primary navigation"
|
||||
:class="
|
||||
cn(
|
||||
'sticky top-0 flex h-dvh shrink-0 flex-col border-r border-border bg-card transition-[width] duration-150',
|
||||
open ? 'w-56' : 'w-14',
|
||||
)
|
||||
"
|
||||
>
|
||||
<div class="flex h-14 items-center border-b border-border px-2.5" :class="open ? 'justify-between' : 'justify-center'">
|
||||
<span v-if="open" class="px-1.5 text-caption font-semibold tracking-[0.06em] text-fg-subtle uppercase">Navigation</span>
|
||||
<Tooltip>
|
||||
<TooltipTrigger as-child>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
:aria-label="open ? 'Collapse navigation' : 'Expand navigation'"
|
||||
:aria-expanded="open"
|
||||
@click="toggleSidebar"
|
||||
>
|
||||
<PanelLeftClose v-if="open" class="size-4" aria-hidden="true" />
|
||||
<PanelLeftOpen v-else class="size-4" aria-hidden="true" />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">{{ open ? "Collapse navigation (⌘B)" : "Expand navigation (⌘B)" }}</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
<nav class="flex-1 overflow-y-auto px-2 py-3">
|
||||
<div v-for="node in nodes" :key="node.kind === 'link' ? node.entry.path : node.label" class="mb-4 last:mb-0">
|
||||
<template v-if="node.kind === 'group'">
|
||||
<p v-if="open" class="mb-1 px-2.5 text-caption font-medium tracking-[0.06em] text-fg-subtle uppercase">
|
||||
{{ node.label }}
|
||||
</p>
|
||||
<ul class="flex flex-col gap-0.5">
|
||||
<li v-for="entry in node.items" :key="entry.path">
|
||||
<Tooltip :disabled="open">
|
||||
<TooltipTrigger as-child>
|
||||
<RouterLink
|
||||
:to="entry.path"
|
||||
:aria-current="entry.path === activePath ? 'page' : undefined"
|
||||
:aria-label="open ? undefined : entry.label"
|
||||
:class="
|
||||
cn(
|
||||
'flex h-8 items-center gap-2.5 rounded-md px-2.5 text-label transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring',
|
||||
!open && 'justify-center px-0',
|
||||
entry.path === activePath && 'bg-secondary font-medium text-foreground',
|
||||
)
|
||||
"
|
||||
>
|
||||
<component :is="navIcons[entry.path]" v-if="navIcons[entry.path]" class="size-4 shrink-0" aria-hidden="true" />
|
||||
<span v-if="open" class="truncate">{{ entry.label }}</span>
|
||||
</RouterLink>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">{{ entry.label }}</TooltipContent>
|
||||
</Tooltip>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
</div>
|
||||
</nav>
|
||||
</aside>
|
||||
</template>
|
||||
@@ -17,6 +17,7 @@ import { api } from "@/lib/api";
|
||||
import { errors } from "@/copy/errors";
|
||||
import { navEntries } from "@/lib/nav";
|
||||
import { statusLabel } from "@/lib/task-meta";
|
||||
import { useSessionStore } from "@/stores/session";
|
||||
|
||||
/**
|
||||
* Jump to a page, a task or a workflow by name. Opened from the top bar, with
|
||||
@@ -45,8 +46,10 @@ const pages = computed(() => navEntries(props.hidden));
|
||||
const tasks = ref<TaskEntry[]>([]);
|
||||
const workflows = ref<{ id: string; name: string }[]>([]);
|
||||
const shortcut = navigator.platform.startsWith("Mac") ? "⌘K" : "Ctrl K";
|
||||
const session = useSessionStore();
|
||||
const showWorkflows = computed(() => !props.hidden.includes("/workflows"));
|
||||
const showTasks = computed(() => !props.hidden.includes("/tasks"));
|
||||
const showNewTask = computed(() => session.sections?.work_requests !== false);
|
||||
|
||||
// A failed read shows as an error item with Retry in that group, not as a
|
||||
// missing group: the pages still work either way.
|
||||
@@ -107,7 +110,7 @@ onUnmounted(() => document.removeEventListener("keydown", onGlobalKeydown));
|
||||
<CommandInput placeholder="Find a page, task or workflow" />
|
||||
<CommandList>
|
||||
<CommandEmpty>No matches.</CommandEmpty>
|
||||
<CommandGroup v-if="showWorkflows" heading="Actions">
|
||||
<CommandGroup v-if="showNewTask" heading="Actions">
|
||||
<CommandItem value="New task" @select="newTask">New task</CommandItem>
|
||||
</CommandGroup>
|
||||
<CommandGroup heading="Views">
|
||||
|
||||
@@ -27,7 +27,7 @@ const { summary } = storeToRefs(store);
|
||||
// The attention count has to stay current on every page, not only the dashboard.
|
||||
useLiveResource("tasks", () => void store.load(), 5000);
|
||||
const links = computed(() =>
|
||||
navTree(props.hidden).flatMap((node): NavEntry[] => (node.kind === "link" ? [node.entry] : [])),
|
||||
navTree(props.hidden).flatMap((node): NavEntry[] => (node.kind === "link" ? [node.entry] : node.items)),
|
||||
);
|
||||
// Detail routes carry the primary destination they belong to in meta.navPath.
|
||||
const activePath = computed(() => (typeof route.meta.navPath === "string" ? route.meta.navPath : activeNavPath(route.path)));
|
||||
|
||||
Reference in new issue
Block a user