feat(ui/runs): compose the runs list and run page from the workflow list patterns (#2023)
The list has a filter and a right-click menu, an error column and fixed widths. The run page merges its details and where the run came from, and leaves out sections that have nothing in them.
This commit is contained in:
3 files changed
+36
-35
No files matched your search
@@ -11,6 +11,7 @@ import { errors } from "@/copy/errors";
|
||||
import { api, describeError } from "@/lib/api";
|
||||
import { usePoll, useRead } from "@/lib/use-read";
|
||||
import { answerApproval } from "@/runs/answer";
|
||||
import { stateLabel } from "./state";
|
||||
import { useLiveResource } from "@/stores/session";
|
||||
|
||||
/** Waiting approvals are a filter on runs: each asks a person to allow one
|
||||
@@ -58,7 +59,7 @@ async function answer(id: string, approved: boolean): Promise<void> {
|
||||
<template v-if="approval.deadline"> · due <Timestamp :at="approval.deadline" /></template>
|
||||
</p>
|
||||
</div>
|
||||
<Badge variant="outline">{{ approval.level }}</Badge>
|
||||
<Badge variant="outline">{{ stateLabel(approval.level) }}</Badge>
|
||||
<Button size="sm" variant="outline" :disabled="busy === approval.id" @click="answer(approval.id, false)">Deny</Button>
|
||||
<Button size="sm" :disabled="busy === approval.id" @click="answer(approval.id, true)">Approve</Button>
|
||||
</li>
|
||||
|
||||
+31
-33
@@ -17,7 +17,7 @@ import { api, describeError, type RunAction } from "@/lib/api";
|
||||
import { usePoll, useRead } from "@/lib/use-read";
|
||||
import { useLiveResource } from "@/stores/session";
|
||||
import ApprovalsSection from "./ApprovalsSection.vue";
|
||||
import { ended, stateTone } from "./state";
|
||||
import { ended, stateLabel, stateTone } from "./state";
|
||||
|
||||
/** A run's decision trail: where it came from, each action it asked to take
|
||||
* and how that was judged, and the steps it recorded. */
|
||||
@@ -32,15 +32,27 @@ usePoll(() => {
|
||||
if (!finished.value) void reload();
|
||||
});
|
||||
|
||||
const origin = computed(() => {
|
||||
const o = data.value?.origin;
|
||||
if (!o) return [];
|
||||
return [
|
||||
...(o.source ? [{ label: "Source", value: o.source }] : []),
|
||||
...(o.type ? [{ label: "Event type", value: o.type }] : []),
|
||||
...(o.trigger ? [{ label: "Trigger", value: o.trigger }] : []),
|
||||
...(o.event_id ? [{ label: "Event", value: o.event_id, mono: true }] : []),
|
||||
];
|
||||
});
|
||||
|
||||
const details = computed(() => {
|
||||
const run = data.value?.run;
|
||||
if (!run) return [];
|
||||
return [
|
||||
{ label: "Workflow", value: `${run.workflow} v${run.workflow_version}` },
|
||||
{ label: "Attempts", value: String(run.attempts) },
|
||||
{ label: "Run", value: run.id, mono: true },
|
||||
...origin.value,
|
||||
...(run.attempts > 1 ? [{ label: "Attempts", value: String(run.attempts) }] : []),
|
||||
...(run.error ? [{ label: "Error", value: run.error }] : []),
|
||||
...(run.detail ? [{ label: "Detail", value: run.detail }] : []),
|
||||
{ label: "Run", value: run.id, mono: true },
|
||||
];
|
||||
});
|
||||
const retrying = ref(false);
|
||||
@@ -71,17 +83,6 @@ async function cancel(): Promise<void> {
|
||||
cancelling.value = false;
|
||||
}
|
||||
}
|
||||
const origin = computed(() => {
|
||||
const o = data.value?.origin;
|
||||
if (!o) return [];
|
||||
return [
|
||||
...(o.source ? [{ label: "Source", value: o.source }] : []),
|
||||
...(o.type ? [{ label: "Event type", value: o.type }] : []),
|
||||
...(o.trigger ? [{ label: "Trigger", value: o.trigger }] : []),
|
||||
...(o.event_id ? [{ label: "Event", value: o.event_id, mono: true }] : []),
|
||||
];
|
||||
});
|
||||
|
||||
function target(action: RunAction): string {
|
||||
const t = action.decision.action.target;
|
||||
return t?.ID ? `${t.Kind ? `${t.Kind} ` : ""}${t.ID}` : "";
|
||||
@@ -94,7 +95,7 @@ const result = computed(() =>
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader :title="data ? data.run.workflow : 'Run'">
|
||||
<Badge v-if="data" :variant="stateTone(data.run.state)">{{ data.run.state }}</Badge>
|
||||
<Badge v-if="data" :variant="stateTone(data.run.state)">{{ stateLabel(data.run.state) }}</Badge>
|
||||
<span v-if="data" class="text-caption text-fg-muted">Started <Timestamp :at="data.run.created_at" /></span>
|
||||
<Button v-if="data?.run.state === 'parked'" size="sm" :disabled="retrying" @click="retry">Retry</Button>
|
||||
<Button v-if="cancellable" variant="destructive" size="sm" :disabled="cancelling" @click="cancel">Cancel</Button>
|
||||
@@ -105,25 +106,23 @@ const result = computed(() =>
|
||||
<p v-if="retryError" role="alert" class="mb-2 text-caption text-danger">{{ retryError }}</p>
|
||||
<p v-if="cancelError" role="alert" class="mb-2 text-caption text-danger">{{ cancelError }}</p>
|
||||
<ApprovalsSection :run="id" @answered="reload" />
|
||||
<div class="grid gap-x-4 lg:grid-cols-2">
|
||||
<Section title="Run"><MetadataList :rows="details" /></Section>
|
||||
<Section v-if="origin.length" title="Started by">
|
||||
<MetadataList :rows="origin">
|
||||
<template #value="{ row }">
|
||||
<RouterLink v-if="row.label === 'Event'" class="underline" :to="{ path: '/events', query: { event: row.value } }">{{ row.value }}</RouterLink>
|
||||
<template v-else>{{ row.value }}</template>
|
||||
</template>
|
||||
</MetadataList>
|
||||
</Section>
|
||||
</div>
|
||||
<Section title="Actions">
|
||||
<Empty v-if="!data.actions?.length"><EmptyHeader><EmptyTitle>No actions</EmptyTitle></EmptyHeader></Empty>
|
||||
<ul v-else class="divide-y divide-border">
|
||||
<Section title="Details">
|
||||
<MetadataList :rows="details">
|
||||
<template #value="{ row }">
|
||||
<RouterLink v-if="row.label === 'Workflow'" class="underline" :to="`/workflows/${data.run.workflow}`">{{ row.value }}</RouterLink>
|
||||
<RouterLink v-else-if="row.label === 'Event'" class="underline" :to="{ path: '/events', query: { event: row.value } }">{{ row.value }}</RouterLink>
|
||||
<template v-else>{{ row.value }}</template>
|
||||
</template>
|
||||
</MetadataList>
|
||||
</Section>
|
||||
<Empty v-if="!data.actions?.length && !data.entries?.length"><EmptyHeader><EmptyTitle>Nothing recorded yet</EmptyTitle></EmptyHeader></Empty>
|
||||
<Section v-if="data.actions?.length" title="Actions">
|
||||
<ul class="divide-y divide-border">
|
||||
<li v-for="action in data.actions" :key="action.decision.id" class="space-y-1 py-3">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="font-mono text-label">{{ action.decision.action.connector }}.{{ action.decision.action.name }}</span>
|
||||
<span v-if="target(action)" class="text-caption text-fg-muted">{{ target(action) }}</span>
|
||||
<Badge variant="outline">{{ action.decision.level }}</Badge>
|
||||
<Badge variant="outline">{{ stateLabel(action.decision.level) }}</Badge>
|
||||
<Badge v-if="action.decision.dry" variant="secondary">Dry run</Badge>
|
||||
<Badge v-if="action.decision.refused_by" variant="danger">Refused by {{ action.decision.refused_by }}</Badge>
|
||||
<Badge v-if="action.approval" :variant="stateTone(action.approval.state)">Approval {{ action.approval.state }}</Badge>
|
||||
@@ -140,9 +139,8 @@ const result = computed(() =>
|
||||
</li>
|
||||
</ul>
|
||||
</Section>
|
||||
<Section title="Steps">
|
||||
<Empty v-if="!data.entries?.length"><EmptyHeader><EmptyTitle>No steps recorded</EmptyTitle></EmptyHeader></Empty>
|
||||
<ol v-else class="divide-y divide-border">
|
||||
<Section v-if="data.entries?.length" title="Steps">
|
||||
<ol class="divide-y divide-border">
|
||||
<li v-for="entry in data.entries" :key="entry.seq" class="space-y-1 py-2">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<Badge variant="secondary">{{ entry.kind }}</Badge>
|
||||
|
||||
@@ -17,10 +17,11 @@ const router = useRouter();
|
||||
const time = (at?: string) => (at ? Date.parse(at) : 0);
|
||||
const took = (run: Run) => (run.finished_at ? time(run.finished_at) - time(run.created_at) : -1);
|
||||
const columns: DataTableColumn<Run>[] = [
|
||||
...(props.withWorkflow ? [{ id: "workflow", label: "Workflow", fixed: true, sort: (r: Run) => r.workflow }] : []),
|
||||
...(props.withWorkflow ? [{ id: "workflow", label: "Workflow", fixed: true, width: "18rem", sort: (r: Run) => r.workflow }] : []),
|
||||
{ id: "state", label: "State", fixed: true, width: "11rem", sort: (r) => r.state },
|
||||
{ id: "created", label: "Started", width: "9rem", sort: (r) => time(r.created_at) },
|
||||
{ id: "duration", label: "Took", width: "8rem", sort: took },
|
||||
{ id: "error", label: "Error", width: "auto", hide: "md" },
|
||||
{ id: "attempts", label: "Attempts", hidden: true, width: "7rem", sort: (r) => r.attempts },
|
||||
{ id: "id", label: "Run", hidden: true, width: "14rem" },
|
||||
];
|
||||
@@ -42,6 +43,7 @@ const columns: DataTableColumn<Run>[] = [
|
||||
<template #cell-state="{ row }"><Badge :variant="stateTone(row.state)" :title="row.error || undefined">{{ stateLabel(row.state) }}</Badge></template>
|
||||
<template #cell-created="{ row }"><Timestamp :at="row.created_at" /></template>
|
||||
<template #cell-duration="{ row }"><span class="text-caption text-fg-muted">{{ took(row) >= 0 ? duration(took(row)) : "" }}</span></template>
|
||||
<template #cell-error="{ row }"><span class="text-caption text-danger" :title="row.error">{{ row.error }}</span></template>
|
||||
<template #cell-attempts="{ row }">{{ row.attempts }}</template>
|
||||
<template #cell-id="{ row }"><span class="font-mono text-caption text-fg-muted">{{ row.id.slice(0, 8) }}</span></template>
|
||||
<template #menu="{ row }">
|
||||
|
||||
Reference in new issue
Block a user