fix(ui): failed workflow reads no longer look like empty data (#1948)
This commit is contained in:
6 files changed
+34
-9
No files matched your search
@@ -7,6 +7,7 @@ export const workflows = {
|
|||||||
},
|
},
|
||||||
bindEvent: {
|
bindEvent: {
|
||||||
formNotLoaded: "Couldn't load the bind form",
|
formNotLoaded: "Couldn't load the bind form",
|
||||||
|
eventsNotLoaded: "Couldn't load recent events",
|
||||||
bindingsNotLoaded: "The bindings list did not load, so this edit cannot tell whether the mapping is shared. Retry the load first.",
|
bindingsNotLoaded: "The bindings list did not load, so this edit cannot tell whether the mapping is shared. Retry the load first.",
|
||||||
blocker: {
|
blocker: {
|
||||||
pickSource: "pick a source",
|
pickSource: "pick a source",
|
||||||
@@ -37,6 +38,7 @@ export const workflows = {
|
|||||||
restartFailed: "Restart failed",
|
restartFailed: "Restart failed",
|
||||||
draftNotSaved: "Draft not saved. Your edit is still in the editor.",
|
draftNotSaved: "Draft not saved. Your edit is still in the editor.",
|
||||||
stepIdTaken: (id: string) => `Another step is already called ${id}.`,
|
stepIdTaken: (id: string) => `Another step is already called ${id}.`,
|
||||||
|
stepTypesUnavailable: "Step types didn't load, so steps can't be opened or checked.",
|
||||||
draftChangedElsewhere: "This draft changed in another tab or by Archie. Your edit is still in the editor.",
|
draftChangedElsewhere: "This draft changed in another tab or by Archie. Your edit is still in the editor.",
|
||||||
draftNotRemoved: "Published, but the old draft wasn't removed. Discard it from the menu.",
|
draftNotRemoved: "Published, but the old draft wasn't removed. Discard it from the menu.",
|
||||||
recentRunsNotLoaded: (detail: string) => `Could not load recent runs: ${detail}`,
|
recentRunsNotLoaded: (detail: string) => `Could not load recent runs: ${detail}`,
|
||||||
|
|||||||
@@ -82,9 +82,17 @@ const revealed = ref<Source | null>(null);
|
|||||||
const error = ref("");
|
const error = ref("");
|
||||||
const status = ref(props.binding?.status ?? "");
|
const status = ref(props.binding?.status ?? "");
|
||||||
|
|
||||||
|
// A failed read keeps the events already shown and says so, rather than
|
||||||
|
// emptying the list into "No events".
|
||||||
|
const capturesError = ref("");
|
||||||
async function loadCaptures(): Promise<void> {
|
async function loadCaptures(): Promise<void> {
|
||||||
const listed = await api.captures<{ captures?: Capture[] }>(100).catch(() => null);
|
try {
|
||||||
captures.value = keepRows(captures.value, listed?.captures ?? []);
|
const listed = await api.captures<{ captures?: Capture[] }>(100);
|
||||||
|
captures.value = keepRows(captures.value, listed?.captures ?? []);
|
||||||
|
capturesError.value = "";
|
||||||
|
} catch {
|
||||||
|
capturesError.value = errors.workflows.bindEvent.eventsNotLoaded;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadAll(): Promise<void> {
|
async function loadAll(): Promise<void> {
|
||||||
@@ -307,6 +315,7 @@ const resume = () => transition(api.bindingResume, "pending_approval");
|
|||||||
<SelectItem v-for="c in sourceCaptures" :key="c.id" :value="String(c.id)">#{{ c.id }} · <Timestamp :at="c.received_at" absolute />{{ c.event_type ? "" : " · unidentified" }}</SelectItem>
|
<SelectItem v-for="c in sourceCaptures" :key="c.id" :value="String(c.id)">#{{ c.id }} · <Timestamp :at="c.received_at" absolute />{{ c.event_type ? "" : " · unidentified" }}</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
<p v-else-if="capturesError" class="text-caption text-danger" role="alert">{{ capturesError }}</p>
|
||||||
<p v-else class="text-caption text-fg-subtle" :title="`Send an event to ${hookURL} and it appears here`">No events</p>
|
<p v-else class="text-caption text-fg-subtle" :title="`Send an event to ${hookURL} and it appears here`">No events</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ async function restartFrom(from: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
const { triggers, reload: reloadTriggers, error: triggersError } = useWorkflowTriggers(selected);
|
const { triggers, reload: reloadTriggers, error: triggersError } = useWorkflowTriggers(selected);
|
||||||
|
|
||||||
const { revisions, error: historyError, reload: reloadHistory } = useWorkflowHistory(selected);
|
const { revisions, error: historyError, loaded: historyLoaded, reload: reloadHistory } = useWorkflowHistory(selected);
|
||||||
const historyRevision = ref(0);
|
const historyRevision = ref(0);
|
||||||
const historyMode = ref("yaml");
|
const historyMode = ref("yaml");
|
||||||
// The revision a run used, matched by the definition it pinned.
|
// The revision a run used, matched by the definition it pinned.
|
||||||
@@ -360,6 +360,9 @@ async function remove(): Promise<void> {
|
|||||||
// of one parse, so they cannot disagree about the same text. Step settings are
|
// of one parse, so they cannot disagree about the same text. Step settings are
|
||||||
// not served, so a save the server refuses still reports its own reason below.
|
// not served, so a save the server refuses still reports its own reason below.
|
||||||
const vocabulary = computed(() => workflows.stepTypes);
|
const vocabulary = computed(() => workflows.stepTypes);
|
||||||
|
// The definitions loaded but carried no step types: cards can't open and YAML
|
||||||
|
// can't be checked, which must not look like an empty, valid workflow.
|
||||||
|
const stepTypesMissing = computed(() => !!workflows.state.resource && !vocabulary.value.length);
|
||||||
const parsed = computed(() => parseWorkflowYaml(yaml.value, vocabulary.value));
|
const parsed = computed(() => parseWorkflowYaml(yaml.value, vocabulary.value));
|
||||||
const stored = computed(() => collection.value.definitions.find((entry) => entry.id === selected.value)?.yaml);
|
const stored = computed(() => collection.value.definitions.find((entry) => entry.id === selected.value)?.yaml);
|
||||||
const dirty = computed(() => yaml.value !== (stored.value ?? ""));
|
const dirty = computed(() => yaml.value !== (stored.value ?? ""));
|
||||||
@@ -576,7 +579,7 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
|
|||||||
</div>
|
</div>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
<TabsContent value="history" class="max-md:min-h-0 max-md:overflow-y-auto">
|
<TabsContent value="history" class="max-md:min-h-0 max-md:overflow-y-auto">
|
||||||
<WorkflowHistory v-model:selected="historyRevision" v-model:mode="historyMode" :revisions="revisions" :current="yaml" :error="historyError" :locked="archieWorking" @restore="restoreRevision" @retry="reloadHistory" />
|
<WorkflowHistory v-model:selected="historyRevision" v-model:mode="historyMode" :revisions="revisions" :current="yaml" :error="historyError" :loaded="historyLoaded" :locked="archieWorking" @restore="restoreRevision" @retry="reloadHistory" />
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
<TabsContent value="performance" class="grid gap-4 max-md:min-h-0 max-md:overflow-y-auto"><slot name="performance" /></TabsContent>
|
<TabsContent value="performance" class="grid gap-4 max-md:min-h-0 max-md:overflow-y-auto"><slot name="performance" /></TabsContent>
|
||||||
<TabsContent value="runs" class="max-md:min-h-0 max-md:overflow-y-auto"><slot name="runs" /></TabsContent>
|
<TabsContent value="runs" class="max-md:min-h-0 max-md:overflow-y-auto"><slot name="runs" /></TabsContent>
|
||||||
@@ -639,6 +642,7 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
|
|||||||
</div>
|
</div>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
<Alert v-if="stepTypesMissing" variant="destructive"><AlertDescription>{{ errors.workflows.editor.stepTypesUnavailable }}</AlertDescription></Alert>
|
||||||
<Alert v-if="draftConflict" variant="destructive">
|
<Alert v-if="draftConflict" variant="destructive">
|
||||||
<AlertDescription class="flex flex-wrap items-center justify-between gap-2">
|
<AlertDescription class="flex flex-wrap items-center justify-between gap-2">
|
||||||
{{ errors.workflows.editor.draftChangedElsewhere }}
|
{{ errors.workflows.editor.draftChangedElsewhere }}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { cn } from "@/lib/utils";
|
|||||||
import WorkflowCanvas from "./WorkflowCanvas.vue";
|
import WorkflowCanvas from "./WorkflowCanvas.vue";
|
||||||
import { lineDiff, stepMarks, type WorkflowRevision } from "./workflow-revisions";
|
import { lineDiff, stepMarks, type WorkflowRevision } from "./workflow-revisions";
|
||||||
|
|
||||||
const props = defineProps<{ revisions: WorkflowRevision[]; current: string; error?: string; locked?: boolean }>();
|
const props = defineProps<{ revisions: WorkflowRevision[]; current: string; error?: string; loaded?: boolean; locked?: boolean }>();
|
||||||
const emit = defineEmits<{ restore: [yaml: string]; retry: [] }>();
|
const emit = defineEmits<{ restore: [yaml: string]; retry: [] }>();
|
||||||
const selected = defineModel<number>("selected", { default: 0 });
|
const selected = defineModel<number>("selected", { default: 0 });
|
||||||
const mode = defineModel<string>("mode", { default: "yaml" });
|
const mode = defineModel<string>("mode", { default: "yaml" });
|
||||||
@@ -55,9 +55,11 @@ const CHANGE_VARIANTS = { added: "default", edited: "secondary", removed: "destr
|
|||||||
<span class="mt-0.5 block truncate text-caption text-fg-muted" :title="item.at">{{ item.actor || "unknown" }} · {{ item.source || "unknown" }} · <Timestamp :at="item.at" /></span>
|
<span class="mt-0.5 block truncate text-caption text-fg-muted" :title="item.at">{{ item.actor || "unknown" }} · {{ item.source || "unknown" }} · <Timestamp :at="item.at" /></span>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
<li v-if="!revisions.length && error" class="px-3 py-2 text-label text-danger">
|
<!-- A failed reload says so even over an older list, which may be stale. -->
|
||||||
|
<li v-if="error" class="px-3 py-2 text-label text-danger" role="alert">
|
||||||
{{ error }} <Button variant="link" size="xs" class="px-0" @click="emit('retry')">Retry</Button>
|
{{ error }} <Button variant="link" size="xs" class="px-0" @click="emit('retry')">Retry</Button>
|
||||||
</li>
|
</li>
|
||||||
|
<li v-else-if="!revisions.length && !loaded" class="px-3 py-2 text-label text-fg-muted">Loading…</li>
|
||||||
<li v-else-if="!revisions.length" class="px-3 py-2 text-label text-fg-muted">No recorded changes</li>
|
<li v-else-if="!revisions.length" class="px-3 py-2 text-label text-fg-muted">No recorded changes</li>
|
||||||
</ol>
|
</ol>
|
||||||
<!-- Below md the list above is hidden: one select picks the revision. -->
|
<!-- Below md the list above is hidden: one select picks the revision. -->
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ const data = shallowRef<WorkflowsResponse>({});
|
|||||||
const error = ref<string | null>(null);
|
const error = ref<string | null>(null);
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
|
|
||||||
|
// Statistics are known once a read has returned them; until then, or after a
|
||||||
|
// failed read, a row says nothing about its runs rather than "Never run".
|
||||||
|
const statsKnown = ref(false);
|
||||||
const statsOf = (id: string) => JSON.stringify(data.value.workflows?.find((w) => w.workflow === id) ?? null);
|
const statsOf = (id: string) => JSON.stringify(data.value.workflows?.find((w) => w.workflow === id) ?? null);
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
@@ -72,6 +75,7 @@ async function load() {
|
|||||||
const before = statsOf(selected.value);
|
const before = statsOf(selected.value);
|
||||||
data.value = keepValue(data.value, (await api.workflows<WorkflowsResponse>()) ?? {});
|
data.value = keepValue(data.value, (await api.workflows<WorkflowsResponse>()) ?? {});
|
||||||
error.value = null;
|
error.value = null;
|
||||||
|
statsKnown.value = true;
|
||||||
// The runs page only changes when the workflow's own statistics do.
|
// The runs page only changes when the workflow's own statistics do.
|
||||||
if (runsFor !== selected.value || statsOf(selected.value) !== before) void loadWorkflowRuns();
|
if (runsFor !== selected.value || statsOf(selected.value) !== before) void loadWorkflowRuns();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -268,7 +272,7 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
|
|||||||
<StatusDot tone="info" live />{{ row.running }} running
|
<StatusDot tone="info" live />{{ row.running }} running
|
||||||
</span>
|
</span>
|
||||||
<span v-else-if="row.last_status" class="w-20 shrink-0 truncate" :title="`Latest run: ${statusLabel(row.last_status)}`">{{ statusLabel(row.last_status) }}</span>
|
<span v-else-if="row.last_status" class="w-20 shrink-0 truncate" :title="`Latest run: ${statusLabel(row.last_status)}`">{{ statusLabel(row.last_status) }}</span>
|
||||||
<span v-else class="shrink-0">Never run</span>
|
<span v-else-if="statsKnown" class="shrink-0">Never run</span>
|
||||||
<span v-if="row.runs" class="h-1 flex-1 overflow-hidden rounded-full bg-border" role="img" :aria-label="`${delivered(row)} of ${row.runs ?? 0} runs delivered`" :title="`${delivered(row)} of ${row.runs ?? 0} runs delivered`">
|
<span v-if="row.runs" class="h-1 flex-1 overflow-hidden rounded-full bg-border" role="img" :aria-label="`${delivered(row)} of ${row.runs ?? 0} runs delivered`" :title="`${delivered(row)} of ${row.runs ?? 0} runs delivered`">
|
||||||
<span class="block h-full rounded-full bg-primary" :style="{ width: `${rate(delivered(row), row.runs) * 100}%` }" />
|
<span class="block h-full rounded-full bg-primary" :style="{ width: `${rate(delivered(row), row.runs) * 100}%` }" />
|
||||||
</span>
|
</span>
|
||||||
@@ -311,7 +315,9 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
|
|||||||
<Switch :model-value="enabled" :title="enabled ? 'Published version runs on events' : 'Published version ignores events'" aria-label="Published version enabled" @update:model-value="setEnabled(selected, $event)" />
|
<Switch :model-value="enabled" :title="enabled ? 'Published version runs on events' : 'Published version ignores events'" aria-label="Published version enabled" @update:model-value="setEnabled(selected, $event)" />
|
||||||
</template>
|
</template>
|
||||||
<template #performance>
|
<template #performance>
|
||||||
<Empty v-if="!stages.length">
|
<p v-if="!statsKnown && error" class="text-label text-danger" role="alert">{{ error }}</p>
|
||||||
|
<p v-else-if="!statsKnown" class="flex items-center gap-2 text-label text-fg-muted"><Spinner />Loading…</p>
|
||||||
|
<Empty v-else-if="!stages.length">
|
||||||
<EmptyHeader>
|
<EmptyHeader>
|
||||||
<EmptyTitle>No stage timings yet</EmptyTitle>
|
<EmptyTitle>No stage timings yet</EmptyTitle>
|
||||||
</EmptyHeader>
|
</EmptyHeader>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export function useWorkflowHistory(id: Ref<string>) {
|
|||||||
const store = useSettingsStore();
|
const store = useSettingsStore();
|
||||||
const all = ref<ResourceRevision[]>([]);
|
const all = ref<ResourceRevision[]>([]);
|
||||||
const error = ref("");
|
const error = ref("");
|
||||||
|
const loaded = ref(false);
|
||||||
|
|
||||||
let generation = 0;
|
let generation = 0;
|
||||||
async function reload(): Promise<void> {
|
async function reload(): Promise<void> {
|
||||||
@@ -20,6 +21,7 @@ export function useWorkflowHistory(id: Ref<string>) {
|
|||||||
all.value = await store.history(KIND);
|
all.value = await store.history(KIND);
|
||||||
if (current !== generation) return;
|
if (current !== generation) return;
|
||||||
error.value = "";
|
error.value = "";
|
||||||
|
loaded.value = true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (current !== generation) return;
|
if (current !== generation) return;
|
||||||
error.value = describeError(err, errors.workflows.history.notLoaded);
|
error.value = describeError(err, errors.workflows.history.notLoaded);
|
||||||
@@ -28,5 +30,5 @@ export function useWorkflowHistory(id: Ref<string>) {
|
|||||||
watch(() => store.stateFor(KIND).resource?.version, () => void reload(), { immediate: true });
|
watch(() => store.stateFor(KIND).resource?.version, () => void reload(), { immediate: true });
|
||||||
|
|
||||||
const revisions = computed(() => workflowRevisions(id.value, all.value));
|
const revisions = computed(() => workflowRevisions(id.value, all.value));
|
||||||
return { revisions, error, reload };
|
return { revisions, error, loaded, reload };
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user