refactor(ui): split Events tabs into nested file-based routes
This commit is contained in:
15 files changed
+273
-54
No files matched your search
@@ -34,6 +34,31 @@
|
||||
"label": "Events",
|
||||
"description": "Received events, their sources, and the triggers that start workflows."
|
||||
},
|
||||
{
|
||||
"path": "/events/bindings",
|
||||
"label": "Bindings",
|
||||
"description": "Bindings that decide which workflow an event starts."
|
||||
},
|
||||
{
|
||||
"path": "/events/inspector",
|
||||
"label": "Inspector",
|
||||
"description": "Captured webhooks and the event types they match."
|
||||
},
|
||||
{
|
||||
"path": "/events/mappings",
|
||||
"label": "Mappings",
|
||||
"description": "Field mappings that name an event's fields."
|
||||
},
|
||||
{
|
||||
"path": "/events/sources",
|
||||
"label": "Sources",
|
||||
"description": "Webhook and connector sources that deliver events."
|
||||
},
|
||||
{
|
||||
"path": "/events/triggers",
|
||||
"label": "Triggers",
|
||||
"description": "Triggers that start workflows from events and schedules."
|
||||
},
|
||||
{
|
||||
"path": "/logs",
|
||||
"label": "Logs",
|
||||
|
||||
@@ -48,8 +48,8 @@ watch(
|
||||
);
|
||||
|
||||
const captureLink = (id: string) => ({
|
||||
path: "/events",
|
||||
query: { tab: "inspector", capture: id },
|
||||
path: "/events/inspector",
|
||||
query: { capture: id },
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -63,7 +63,7 @@ const captureLink = (id: string) => ({
|
||||
>
|
||||
<RouterLink
|
||||
v-if="props.kind !== 'bindings'"
|
||||
:to="{ path: '/events', query: { tab: 'bindings' } }"
|
||||
:to="'/events/bindings'"
|
||||
class="hover:text-foreground"
|
||||
>binding {{ d.binding_id.slice(0, 8) }} v{{ d.binding_version }}</RouterLink
|
||||
>
|
||||
|
||||
@@ -66,13 +66,13 @@ const noRunText = (reason?: NoRunReason) => {
|
||||
>
|
||||
<RouterLink
|
||||
v-if="props.kind === 'triggers'"
|
||||
:to="{ path: '/events', query: { tab: 'inspector', capture: r.event_id } }"
|
||||
:to="{ path: '/events/inspector', query: { capture: r.event_id } }"
|
||||
class="hover:text-foreground"
|
||||
>capture {{ r.event_id.slice(0, 8) }}</RouterLink
|
||||
>
|
||||
<RouterLink
|
||||
v-else
|
||||
:to="{ path: '/events', query: { tab: 'bindings' } }"
|
||||
:to="'/events/bindings'"
|
||||
class="hover:text-foreground"
|
||||
>{{ r.trigger }}</RouterLink
|
||||
>
|
||||
|
||||
@@ -73,7 +73,7 @@ onMounted(async () => {
|
||||
// which is what a page opened with nothing named starts on too.
|
||||
const named = String(route.query.capture ?? "");
|
||||
if (named && selectById(named)) return;
|
||||
if (route.query.tab === "inspector") selectNewest();
|
||||
selectNewest();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -83,7 +83,6 @@ onBeforeUnmount(() => {
|
||||
watch(stacked, measure);
|
||||
|
||||
watch(selected, (capture) => {
|
||||
if (route.query.tab !== "inspector") return;
|
||||
const query = { ...route.query };
|
||||
if (capture) query.capture = String(capture.id);
|
||||
else delete query.capture;
|
||||
|
||||
@@ -93,3 +93,8 @@ export function stepsFor(available: EventsTabSpec[]): EventsStep[] {
|
||||
hint: STEP_COPY[tab.id]?.hint ?? "",
|
||||
}));
|
||||
}
|
||||
|
||||
/** The route a step lives at: the list of events is the section's index. */
|
||||
export function tabPath(id: string): string {
|
||||
return id === "events" ? "/events" : `/events/${id}`;
|
||||
}
|
||||
+23
-44
@@ -1,31 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
definePage({
|
||||
name: "events",
|
||||
meta: {
|
||||
label: "Events",
|
||||
description: "Received events, their sources, and the triggers that start workflows.",
|
||||
navPath: "/events",
|
||||
section: "events",
|
||||
},
|
||||
});
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { enabled as captureEnabled, loading as captureLoading } from "@/captures/state";
|
||||
import { computed, onMounted, ref, watch, type Component } from "vue";
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { RouterLink, useRoute, useRouter } from "vue-router";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import BindingsPage from "@/bindings/BindingsPage.vue";
|
||||
import CapturesPage from "@/captures/CapturesPage.vue";
|
||||
import { api } from "@/lib/api";
|
||||
import { useLiveResource, useSessionStore } from "@/stores/session";
|
||||
import MappingsPage from "@/mappings/MappingsPage.vue";
|
||||
import EventList from "@/events/EventList.vue";
|
||||
import SourceList from "@/events/SourceList.vue";
|
||||
import TriggerList from "@/events/TriggerList.vue";
|
||||
import { activeTab, availableTabs, stepsFor } from "@/events/tab-selection";
|
||||
import { activeTab, availableTabs, stepsFor, tabPath } from "@/events/tab-selection";
|
||||
import { loadEventCounts, type EventsCounts } from "@/events/counts";
|
||||
|
||||
/**
|
||||
@@ -42,35 +36,35 @@ import { loadEventCounts, type EventsCounts } from "@/events/counts";
|
||||
*
|
||||
* Which steps exist, and which one is showing, is decided in tab-selection.ts.
|
||||
*/
|
||||
const PANELS: Record<string, Component> = {
|
||||
events: EventList,
|
||||
sources: SourceList,
|
||||
triggers: TriggerList,
|
||||
inspector: CapturesPage,
|
||||
bindings: BindingsPage,
|
||||
mappings: MappingsPage,
|
||||
};
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const session = useSessionStore();
|
||||
const tabs = computed(() => availableTabs(session.sections));
|
||||
const active = computed(() =>
|
||||
activeTab(String(route.query.tab ?? ""), tabs.value),
|
||||
);
|
||||
const requested = computed(() => {
|
||||
const segment = route.path.replace(/^\/events\/?/, "").split("/")[0];
|
||||
return segment || "events";
|
||||
});
|
||||
const active = computed(() => activeTab(requested.value, tabs.value));
|
||||
|
||||
// The strip is navigation, so a step is a push like any other page change.
|
||||
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 } });
|
||||
if (!next || next === requested.value) return;
|
||||
void router.push(tabPath(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
|
||||
// A URL naming a step this composition cannot back -- a bookmark from a fuller
|
||||
// deployment, or a capability that went away -- is replaced with the step that
|
||||
// is actually available, so the address bar never describes a panel that is not
|
||||
// there.
|
||||
watch(active, (tab) => show(tab), { immediate: true });
|
||||
watch(
|
||||
[active, requested],
|
||||
([tab, asked]) => {
|
||||
if (tab && tab !== asked) void router.replace(tabPath(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
|
||||
@@ -98,13 +92,6 @@ onMounted(() => void loadCounts());
|
||||
|
||||
const steps = computed(() => stepsFor(tabs.value));
|
||||
|
||||
/** The panels to draw: one per step this composition backs. */
|
||||
const panels = computed(() =>
|
||||
tabs.value.flatMap((tab) => {
|
||||
const component = PANELS[tab.id];
|
||||
return component ? [{ id: tab.id, component }] : [];
|
||||
}),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -114,7 +101,7 @@ const panels = computed(() =>
|
||||
<Badge v-if="!captureEnabled" variant="warn">Capture off</Badge>
|
||||
</template>
|
||||
<Button v-if="active === 'inspector' && tabs.some((tab) => tab.id === 'sources')" as-child size="sm" variant="outline">
|
||||
<RouterLink :to="{ query: { tab: 'sources' } }">Manage sources</RouterLink>
|
||||
<RouterLink :to="tabPath('sources')">Manage sources</RouterLink>
|
||||
</Button>
|
||||
</PageHeader>
|
||||
<Tabs :model-value="active" class="mb-4" @update:model-value="show">
|
||||
@@ -130,15 +117,7 @@ const panels = computed(() =>
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
|
||||
<!-- Every step stays mounted so a switch shows what it already read rather
|
||||
than its skeleton. Each panel reads on mount and again on a live event,
|
||||
and only the active one is on screen. The wrapper is a single element
|
||||
because v-show cannot hide a component whose template is a fragment. -->
|
||||
<template v-if="panels.length">
|
||||
<div v-for="item in panels" :key="item.id" v-show="item.id === active">
|
||||
<component :is="item.component" />
|
||||
</div>
|
||||
</template>
|
||||
<RouterView v-if="tabs.length" />
|
||||
<Empty v-else>
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>Event automation is not enabled</EmptyTitle>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import BindingsPage from "@/bindings/BindingsPage.vue";
|
||||
|
||||
definePage({
|
||||
name: "events-bindings",
|
||||
meta: {
|
||||
label: "Bindings",
|
||||
description: "Bindings that decide which workflow an event starts.",
|
||||
navPath: "/events",
|
||||
section: "bindings",
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BindingsPage />
|
||||
</template>
|
||||
@@ -0,0 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import EventList from "@/events/EventList.vue";
|
||||
|
||||
definePage({
|
||||
name: "events",
|
||||
// Links written as /events?tab=<step> open that step's page.
|
||||
beforeEnter: (to) => {
|
||||
const { tab, ...query } = to.query;
|
||||
if (typeof tab === "string" && tab && tab !== "events") {
|
||||
return { path: `/events/${tab}`, query, replace: true };
|
||||
}
|
||||
return true;
|
||||
},
|
||||
meta: {
|
||||
label: "Events",
|
||||
description: "Events received from sources, with the runs they started.",
|
||||
navPath: "/events",
|
||||
section: "events",
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<EventList />
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import CapturesPage from "@/captures/CapturesPage.vue";
|
||||
|
||||
definePage({
|
||||
name: "events-inspector",
|
||||
meta: {
|
||||
label: "Inspector",
|
||||
description: "Captured webhooks and the event types they match.",
|
||||
navPath: "/events",
|
||||
section: "captures",
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CapturesPage />
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import MappingsPage from "@/mappings/MappingsPage.vue";
|
||||
|
||||
definePage({
|
||||
name: "events-mappings",
|
||||
meta: {
|
||||
label: "Mappings",
|
||||
description: "Field mappings that name an event's fields.",
|
||||
navPath: "/events",
|
||||
section: "mappings",
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<MappingsPage />
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import SourceList from "@/events/SourceList.vue";
|
||||
|
||||
definePage({
|
||||
name: "events-sources",
|
||||
meta: {
|
||||
label: "Sources",
|
||||
description: "Webhook and connector sources that deliver events.",
|
||||
navPath: "/events",
|
||||
section: "events",
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SourceList />
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import TriggerList from "@/events/TriggerList.vue";
|
||||
|
||||
definePage({
|
||||
name: "events-triggers",
|
||||
meta: {
|
||||
label: "Triggers",
|
||||
description: "Triggers that start workflows from events and schedules.",
|
||||
navPath: "/events",
|
||||
section: "events",
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TriggerList />
|
||||
</template>
|
||||
@@ -47,7 +47,7 @@ const allAreas = [
|
||||
{ title: "Extensions", to: "/settings/extensions" },
|
||||
{ title: "Workspaces", to: "/org/workspaces" },
|
||||
{ title: "Models", to: "/settings/models" },
|
||||
{ title: "Triggers", to: "/events?tab=triggers" },
|
||||
{ title: "Triggers", to: "/events/triggers" },
|
||||
{ title: "Members and access", to: "/org/members" },
|
||||
];
|
||||
const orgStore = useOrgStore();
|
||||
|
||||
@@ -51,7 +51,7 @@ export const redirects: RouteRecordRaw[] = [
|
||||
{
|
||||
path: "/org/schedules",
|
||||
name: "org-schedules",
|
||||
redirect: { path: "/events", query: { tab: "triggers" } },
|
||||
redirect: "/events/triggers",
|
||||
meta: {
|
||||
section: "org_config",
|
||||
label: "Schedules",
|
||||
@@ -62,7 +62,7 @@ export const redirects: RouteRecordRaw[] = [
|
||||
{
|
||||
path: "/org/alerts",
|
||||
name: "org-alerts",
|
||||
redirect: { path: "/events", query: { tab: "sources" } },
|
||||
redirect: "/events/sources",
|
||||
meta: {
|
||||
section: "org_config",
|
||||
label: "Alert webhook",
|
||||
|
||||
Vendored
+101
@@ -105,6 +105,18 @@ declare module 'vue-router/auto-routes' {
|
||||
{ id: ParamValue<false> },
|
||||
| never
|
||||
>,
|
||||
'/events': RouteRecordInfo<
|
||||
'/events',
|
||||
'/events',
|
||||
Record<never, never>,
|
||||
Record<never, never>,
|
||||
| 'events'
|
||||
| 'events-bindings'
|
||||
| 'events-inspector'
|
||||
| 'events-mappings'
|
||||
| 'events-sources'
|
||||
| 'events-triggers'
|
||||
>,
|
||||
'events': RouteRecordInfo<
|
||||
'events',
|
||||
'/events',
|
||||
@@ -112,6 +124,41 @@ declare module 'vue-router/auto-routes' {
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'events-bindings': RouteRecordInfo<
|
||||
'events-bindings',
|
||||
'/events/bindings',
|
||||
Record<never, never>,
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'events-inspector': RouteRecordInfo<
|
||||
'events-inspector',
|
||||
'/events/inspector',
|
||||
Record<never, never>,
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'events-mappings': RouteRecordInfo<
|
||||
'events-mappings',
|
||||
'/events/mappings',
|
||||
Record<never, never>,
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'events-sources': RouteRecordInfo<
|
||||
'events-sources',
|
||||
'/events/sources',
|
||||
Record<never, never>,
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'events-triggers': RouteRecordInfo<
|
||||
'events-triggers',
|
||||
'/events/triggers',
|
||||
Record<never, never>,
|
||||
Record<never, never>,
|
||||
| never
|
||||
>,
|
||||
'logs': RouteRecordInfo<
|
||||
'logs',
|
||||
'/logs',
|
||||
@@ -512,7 +559,61 @@ declare module 'vue-router/auto-routes' {
|
||||
}
|
||||
'src/pages/events.vue': {
|
||||
routes:
|
||||
| '/events'
|
||||
| 'events'
|
||||
| 'events-bindings'
|
||||
| 'events-inspector'
|
||||
| 'events-mappings'
|
||||
| 'events-sources'
|
||||
| 'events-triggers'
|
||||
views:
|
||||
| 'default'
|
||||
pathParamNames:
|
||||
| never
|
||||
}
|
||||
'src/pages/events/index.vue': {
|
||||
routes:
|
||||
| 'events'
|
||||
views:
|
||||
| never
|
||||
pathParamNames:
|
||||
| never
|
||||
}
|
||||
'src/pages/events/bindings.vue': {
|
||||
routes:
|
||||
| 'events-bindings'
|
||||
views:
|
||||
| never
|
||||
pathParamNames:
|
||||
| never
|
||||
}
|
||||
'src/pages/events/inspector.vue': {
|
||||
routes:
|
||||
| 'events-inspector'
|
||||
views:
|
||||
| never
|
||||
pathParamNames:
|
||||
| never
|
||||
}
|
||||
'src/pages/events/mappings.vue': {
|
||||
routes:
|
||||
| 'events-mappings'
|
||||
views:
|
||||
| never
|
||||
pathParamNames:
|
||||
| never
|
||||
}
|
||||
'src/pages/events/sources.vue': {
|
||||
routes:
|
||||
| 'events-sources'
|
||||
views:
|
||||
| never
|
||||
pathParamNames:
|
||||
| never
|
||||
}
|
||||
'src/pages/events/triggers.vue': {
|
||||
routes:
|
||||
| 'events-triggers'
|
||||
views:
|
||||
| never
|
||||
pathParamNames:
|
||||
|
||||
Reference in new issue
Block a user