feat(eda): link binding dispatches to the captures and tasks they started
This commit is contained in:
24 files changed
+1315
-518
No files matched your search
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import DispatchLinks from "./DispatchLinks.vue";
|
||||
import { computed, ref, watch } from "vue";
|
||||
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
@@ -313,6 +314,11 @@ const title = computed(() => (props.binding ? "Edit binding" : "New binding"));
|
||||
</Field>
|
||||
</FieldGroup>
|
||||
|
||||
<section v-if="props.binding" class="mt-4 flex flex-col gap-2">
|
||||
<h3 class="text-sm font-medium">Recent dispatches</h3>
|
||||
<DispatchLinks kind="bindings" :id="props.binding.id" />
|
||||
</section>
|
||||
|
||||
<!-- Beside the buttons, not at the top: the dialog scrolls, and Save is
|
||||
clicked at the bottom, where a refusal must be seen. -->
|
||||
<Alert v-if="props.error" variant="destructive" class="mt-4">
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from "vue";
|
||||
|
||||
import { api } from "@/lib/api";
|
||||
import { ago } from "@/lib/format";
|
||||
|
||||
/**
|
||||
* The dispatch ledger rows for one binding, capture or task, each linking the
|
||||
* other two ends: which binding evaluated which capture, and the task it
|
||||
* started or the reason it started none. `omit` drops the column the page
|
||||
* already is.
|
||||
*/
|
||||
export interface Dispatch {
|
||||
binding_id: string;
|
||||
binding_version: number;
|
||||
capture_id: string;
|
||||
task_id?: number;
|
||||
reason?: string;
|
||||
dispatched_at: string;
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
kind: "bindings" | "captures" | "tasks";
|
||||
id: string;
|
||||
}>();
|
||||
|
||||
const dispatches = ref<Dispatch[]>([]);
|
||||
const failed = ref(false);
|
||||
|
||||
watch(
|
||||
() => [props.kind, props.id],
|
||||
async () => {
|
||||
failed.value = false;
|
||||
try {
|
||||
dispatches.value = await api.dispatches<Dispatch[]>(props.kind, props.id);
|
||||
} catch {
|
||||
dispatches.value = [];
|
||||
failed.value = true;
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
const captureLink = (id: string) => ({
|
||||
path: "/events",
|
||||
query: { tab: "inspector", capture: id },
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<p v-if="failed" class="text-xs text-fg-muted">Dispatches unavailable.</p>
|
||||
<ul v-else-if="dispatches.length" class="flex flex-col gap-1 text-xs">
|
||||
<li
|
||||
v-for="d in dispatches"
|
||||
:key="d.binding_id + d.capture_id"
|
||||
class="flex flex-wrap items-center gap-x-2 font-mono text-fg-muted"
|
||||
>
|
||||
<RouterLink
|
||||
v-if="props.kind !== 'bindings'"
|
||||
:to="{ path: '/events', query: { tab: 'bindings' } }"
|
||||
class="hover:text-foreground"
|
||||
>binding {{ d.binding_id.slice(0, 8) }} v{{ d.binding_version }}</RouterLink
|
||||
>
|
||||
<RouterLink
|
||||
v-if="props.kind !== 'captures'"
|
||||
:to="captureLink(d.capture_id)"
|
||||
class="hover:text-foreground"
|
||||
>capture {{ d.capture_id.slice(0, 8) }}</RouterLink
|
||||
>
|
||||
<template v-if="props.kind !== 'tasks'">
|
||||
<RouterLink
|
||||
v-if="d.task_id"
|
||||
:to="`/tasks/${d.task_id}`"
|
||||
class="text-foreground hover:underline"
|
||||
>task #{{ d.task_id }}</RouterLink
|
||||
>
|
||||
<span v-else>{{ d.reason || "claimed, no task recorded" }}</span>
|
||||
</template>
|
||||
<span>{{ ago(d.dispatched_at) }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-else-if="props.kind !== 'tasks'" class="text-xs text-fg-muted">
|
||||
No dispatches yet.
|
||||
</p>
|
||||
</template>
|
||||
Reference in new issue
Block a user