Files
archie/ui/src/events/EventsPage.vue
T
sam 5e1e365c05 feat(webui): events counts, YAML reading, log rows and dashboard filters
Four findings from the ui-redesign verification pass, each with the module that
owns the rule and the test that pins it.

- events: the three-step strip's and the tab chips' counts move out of the SFC
  into events/counts.ts -- one read per step, an unreadable count stays blank
  rather than reading as zero (events-counts.test.ts).
- workflows: workflows/workflow-yaml.ts reads the editor's YAML with a real
  parser (the yaml package, not a line scanner) to drive the read-only Steps
  preview and a live validity indicator; the editor gains a line-number gutter
  and light syntax colouring behind the textarea. Step types and their settings
  are not served to the dashboard, so those remain the server's to check on
  save, and a save it refuses still reports its own reason.
- tasks: an ERROR log row is a block rather than only red text (lib/log.ts), the
  log pane ends with "End of attempt N - M lines", and the task head offers
  Archive when the server's own action list offers it (task-actions.ts, and
  TaskRowActions' new `only` narrows the list without inventing a control).
- dashboard: the live activity feed gains the All/Tasks/System filter
  (activity-filter.ts) and every quality-gate row gains a pass bar
  (pass-bar.ts) that is red when the gate is failing.

ui/dist regenerated; ui/package.json carries yaml ^2.9.1.
2026-09-30 11:41:33 +10:00

120 lines
5.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { StatusPill } from "@/components/ui/status-pill";
import { enabled as captureEnabled, loading as captureLoading } from "@/captures/state";
import { computed, onMounted, ref, watch, type Component } from "vue";
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 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 { 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,
* 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.
*
* Which tabs 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.
*/
const PANELS: Record<string, Component> = {
inspector: CapturesPage,
bindings: BindingsPage,
mappings: MappingsPage,
};
const route = useRoute();
const router = useRouter();
const tabs = computed(() => availableTabs(sections.value));
const active = computed(() =>
activeTab(String(route.query.tab ?? ""), tabs.value),
);
function show(id: unknown): void {
const next = String(id);
if (!next || next === String(route.query.tab ?? "")) return;
void router.replace({ query: { ...route.query, tab: next } });
}
// A URL naming a tab this composition cannot back -- a bookmark from a fuller
// deployment, or a capability that went away -- is written back to the tab that
// is actually showing, so the address bar never describes a panel that is not
// there.
watch(active, (tab) => show(tab), { immediate: true });
// One count per step of the chain, for the strip and the tab chips. The reads
// and the counting live in counts.ts, so the strip, the chips and the test all
// read one source rather than three.
const counts = ref<EventsCounts>({});
async function loadCounts() {
counts.value = await loadEventCounts(api);
}
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" },
];
</script>
<template>
<div>
<PageHeader title="Events">
<template v-if="!captureLoading">
<StatusPill v-if="captureEnabled" dot="live">Listening</StatusPill>
<StatusPill v-else>Capture off</StatusPill>
</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">
<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)"
>
<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>
</span>
<ArrowRight v-if="i < steps.length - 1" class="size-4 text-fg-subtle max-sm:hidden" aria-hidden="true" />
</button>
</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>
</div>
</template>