fix(webui): navigate the Events chain once, not twice
The page drew the same three panels twice: a numbered Capture/Map/Bind strip and, directly under it, a tab list naming Inspector/Mappings/ Bindings. Both drove the same `?tab=` through the same handler, so the page read as one wizard drawn twice and named the same three panels with two different vocabularies in a single view. The strip survives. It names each step for what the operator does to it rather than for what the panel holds, and it is the one that reads as a chain. The step words move to tab-selection.ts as stepsFor(), beside the rules they belong to; the URL keeps its ids. Making the strip the only navigation also fixes a latent fault. It listed all three steps unconditionally, so a composition the server refuses `mappings` still drew a Map step with no panel behind it, and clicking it fell back to the first available tab, which did nothing. stepsFor() returns exactly the tabs this composition can back, and the page renders an empty state when that is none of them. ui/dist rebuilt in the same commit: the Go build embeds it.
This commit is contained in:
1 parent
8ae3a445a7
commit
a63b650b94
6 files changed
+163
-92
No files matched your search
@@ -6,28 +6,33 @@ import { ArrowRight } from "@lucide/vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import BindingsPage from "@/bindings/BindingsPage.vue";
|
||||
import CapturesPage from "@/captures/CapturesPage.vue";
|
||||
import { sections } from "@/lib/capabilities";
|
||||
import { api } from "@/lib/api";
|
||||
import { useLiveResource } from "@/stores/live-updates";
|
||||
import MappingsPage from "@/mappings/MappingsPage.vue";
|
||||
import { activeTab, availableTabs } from "./tab-selection";
|
||||
import { activeTab, availableTabs, stepsFor } from "./tab-selection";
|
||||
import { loadEventCounts, type EventsCounts } from "./counts";
|
||||
|
||||
/**
|
||||
* The Events surfaces: what arrived, how its fields are read, and which workflow
|
||||
* it starts. Three tabs on one page rather than three sibling destinations,
|
||||
* it starts. Three steps on one page rather than three sibling destinations,
|
||||
* because they are one chain read in order -- an event, the mapping that names
|
||||
* its fields, the binding that decides what runs.
|
||||
*
|
||||
* The open tab is the query string's (`?tab=`), so a tab is a link and survives
|
||||
* a reload, and switching is a `replace`: walking the tabs adds no history to
|
||||
* back out through. A capture's own selection rides alongside it (`?capture=`),
|
||||
* so returning to the Inspector tab lands on the record that was open.
|
||||
* The numbered strip is the page's ONLY navigation. It used to be joined by a
|
||||
* tab list naming the same three panels a second time ("Inspector | Mappings |
|
||||
* Bindings" under "Capture | Map | Bind"), which read as one wizard drawn
|
||||
* twice. The strip keeps the verbs; the URL keeps the ids.
|
||||
*
|
||||
* Which tabs exist, and which one is showing, is decided in tab-selection.ts --
|
||||
* The open step is the query string's (`?tab=`), so a step is a link and
|
||||
* survives a reload, and switching is a `replace`: walking the chain adds no
|
||||
* history to back out through. A capture's own selection rides alongside it
|
||||
* (`?capture=`), so returning to Capture lands on the record that was open.
|
||||
*
|
||||
* Which steps exist, and which one is showing, is decided in tab-selection.ts --
|
||||
* this file owns the components and the address bar, that file owns the rule,
|
||||
* and the rule is unit-tested without a browser.
|
||||
*/
|
||||
@@ -67,11 +72,11 @@ async function loadCounts() {
|
||||
onMounted(() => void loadCounts());
|
||||
useLiveResource(null, () => void loadCounts(), 1000);
|
||||
|
||||
const steps = [
|
||||
{ tab: "inspector", label: "Capture", hint: "webhooks received" },
|
||||
{ tab: "mappings", label: "Map", hint: "field mappings" },
|
||||
{ tab: "bindings", label: "Bind", hint: "bindings to workflows" },
|
||||
];
|
||||
const steps = computed(() => stepsFor(tabs.value));
|
||||
|
||||
/** The panel the active step shows. Undefined when this composition backs none
|
||||
* of them, which the template renders as an empty state. */
|
||||
const panel = computed(() => PANELS[active.value]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -83,18 +88,19 @@ const steps = [
|
||||
</template>
|
||||
</PageHeader>
|
||||
<ol class="mb-6 grid grid-cols-1 overflow-hidden rounded-lg border border-border bg-card sm:grid-cols-3" aria-label="How events become work">
|
||||
<li v-for="(step, i) in steps" :key="step.tab" class="relative border-border not-last:border-b sm:not-last:border-r sm:not-last:border-b-0">
|
||||
<li v-for="(step, i) in steps" :key="step.id" class="relative border-border not-last:border-b sm:not-last:border-r sm:not-last:border-b-0">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full items-center gap-3 px-5 py-4 text-left transition-colors hover:bg-secondary"
|
||||
:class="active === step.tab && 'bg-secondary'"
|
||||
@click="show(step.tab)"
|
||||
:class="active === step.id && 'bg-secondary'"
|
||||
:aria-current="active === step.id ? 'step' : undefined"
|
||||
@click="show(step.id)"
|
||||
>
|
||||
<span class="grid size-7 shrink-0 place-items-center rounded-full border border-border-strong font-mono text-xs text-fg-muted">{{ i + 1 }}</span>
|
||||
<span class="min-w-0 flex-1">
|
||||
<span class="block text-sm font-medium">{{ step.label }}</span>
|
||||
<span class="block text-xs text-fg-subtle">
|
||||
<span class="font-mono">{{ counts[step.tab] ?? "–" }}</span> {{ step.hint }}
|
||||
<span class="font-mono">{{ counts[step.id] ?? "–" }}</span> {{ step.hint }}
|
||||
</span>
|
||||
</span>
|
||||
<ArrowRight v-if="i < steps.length - 1" class="size-4 text-fg-subtle max-sm:hidden" aria-hidden="true" />
|
||||
@@ -102,18 +108,11 @@ const steps = [
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<Tabs class="gap-4" :model-value="active" @update:model-value="show">
|
||||
<TabsList variant="line" class="justify-start">
|
||||
<TabsTrigger v-for="tab in tabs" :key="tab.id" :value="tab.id" class="flex-none px-3">
|
||||
{{ tab.label }}
|
||||
<span v-if="counts[tab.id] !== undefined" class="ml-1.5 rounded bg-secondary px-1.5 font-mono text-[11px] text-fg-muted">{{
|
||||
counts[tab.id]
|
||||
}}</span>
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent v-for="tab in tabs" :key="tab.id" :value="tab.id">
|
||||
<component :is="PANELS[tab.id]" />
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
<component :is="panel" v-if="panel" :key="active" />
|
||||
<Empty v-else>
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>Event automation is not enabled</EmptyTitle>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* The Events chain's counts.
|
||||
*
|
||||
* The three-step strip and the tab chips both show one number per step, and
|
||||
* both read this. The three lists arrive from three separate loaded stores, so
|
||||
* counting them inside the page would put a second, quietly divergent answer
|
||||
* next to the first. A count that could not be read at all is `undefined` --
|
||||
* The three-step strip shows one number per step, and reads this. The three
|
||||
* lists arrive from three separate loaded stores, so counting them inside the
|
||||
* page would put a second, quietly divergent answer next to the first. A count
|
||||
* that could not be read at all is `undefined` --
|
||||
* blank, never zero -- because "nothing arrived" and "the read failed" are
|
||||
* different facts about a deployment, and only the first one is about the
|
||||
* operator's events.
|
||||
|
||||
@@ -47,3 +47,43 @@ export function activeTab(
|
||||
if (available.some((tab) => tab.id === requested)) return requested;
|
||||
return available[0]?.id ?? "";
|
||||
}
|
||||
|
||||
/** One step of the chain strip. */
|
||||
export interface EventsStep {
|
||||
/** The tab this step shows. The strip and the URL agree on it. */
|
||||
id: string;
|
||||
/** The strip's word for the step. */
|
||||
label: string;
|
||||
/** What the count beside the label counts. */
|
||||
hint: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The strip's own words for each surface. The URL names a panel for what it
|
||||
* holds -- inspector, mappings, bindings; the strip names the same three panels
|
||||
* for what the operator does to them. Only one vocabulary is on screen at a
|
||||
* time now, so the two can differ without the operator reading both.
|
||||
*/
|
||||
const STEP_COPY: Record<string, { label: string; hint: string }> = {
|
||||
inspector: { label: "Capture", hint: "webhooks received" },
|
||||
mappings: { label: "Map", hint: "field mappings" },
|
||||
bindings: { label: "Bind", hint: "bindings to workflows" },
|
||||
};
|
||||
|
||||
/**
|
||||
* stepsFor is the strip the page draws: exactly the tabs this composition can
|
||||
* back, in reading order, wearing the strip's words.
|
||||
*
|
||||
* It is the page's ONLY navigation. Drawing the same three panels a second time
|
||||
* as a tab list beneath it put two controls on one chain, which read as a
|
||||
* duplicated wizard. Because there is no second control set to fall back on, a
|
||||
* surface this composition cannot back is left out rather than drawn dead: a
|
||||
* step that navigates nowhere is worse than an absent one.
|
||||
*/
|
||||
export function stepsFor(available: EventsTabSpec[]): EventsStep[] {
|
||||
return available.map((tab) => ({
|
||||
id: tab.id,
|
||||
label: STEP_COPY[tab.id]?.label ?? tab.label,
|
||||
hint: STEP_COPY[tab.id]?.hint ?? "",
|
||||
}));
|
||||
}
|
||||
Reference in new issue
Block a user