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: {
|
||||
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.",
|
||||
blocker: {
|
||||
pickSource: "pick a source",
|
||||
@@ -37,6 +38,7 @@ export const workflows = {
|
||||
restartFailed: "Restart failed",
|
||||
draftNotSaved: "Draft not saved. Your edit is still in the editor.",
|
||||
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.",
|
||||
draftNotRemoved: "Published, but the old draft wasn't removed. Discard it from the menu.",
|
||||
recentRunsNotLoaded: (detail: string) => `Could not load recent runs: ${detail}`,
|
||||
|
||||
@@ -82,9 +82,17 @@ const revealed = ref<Source | null>(null);
|
||||
const error = ref("");
|
||||
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> {
|
||||
const listed = await api.captures<{ captures?: Capture[] }>(100).catch(() => null);
|
||||
captures.value = keepRows(captures.value, listed?.captures ?? []);
|
||||
try {
|
||||
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> {
|
||||
@@ -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>
|
||||
</SelectContent>
|
||||
</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>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ async function restartFrom(from: string): Promise<void> {
|
||||
}
|
||||
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 historyMode = ref("yaml");
|
||||
// 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
|
||||
// not served, so a save the server refuses still reports its own reason below.
|
||||
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 stored = computed(() => collection.value.definitions.find((entry) => entry.id === selected.value)?.yaml);
|
||||
const dirty = computed(() => yaml.value !== (stored.value ?? ""));
|
||||
@@ -576,7 +579,7 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
|
||||
</div>
|
||||
</TabsContent>
|
||||
<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 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>
|
||||
@@ -639,6 +642,7 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
|
||||
</div>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
<Alert v-if="stepTypesMissing" variant="destructive"><AlertDescription>{{ errors.workflows.editor.stepTypesUnavailable }}</AlertDescription></Alert>
|
||||
<Alert v-if="draftConflict" variant="destructive">
|
||||
<AlertDescription class="flex flex-wrap items-center justify-between gap-2">
|
||||
{{ errors.workflows.editor.draftChangedElsewhere }}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { cn } from "@/lib/utils";
|
||||
import WorkflowCanvas from "./WorkflowCanvas.vue";
|
||||
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 selected = defineModel<number>("selected", { default: 0 });
|
||||
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>
|
||||
</button>
|
||||
</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>
|
||||
</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>
|
||||
</ol>
|
||||
<!-- 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 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);
|
||||
|
||||
async function load() {
|
||||
@@ -72,6 +75,7 @@ async function load() {
|
||||
const before = statsOf(selected.value);
|
||||
data.value = keepValue(data.value, (await api.workflows<WorkflowsResponse>()) ?? {});
|
||||
error.value = null;
|
||||
statsKnown.value = true;
|
||||
// The runs page only changes when the workflow's own statistics do.
|
||||
if (runsFor !== selected.value || statsOf(selected.value) !== before) void loadWorkflowRuns();
|
||||
} catch (err) {
|
||||
@@ -268,7 +272,7 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
|
||||
<StatusDot tone="info" live />{{ row.running }} running
|
||||
</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 class="block h-full rounded-full bg-primary" :style="{ width: `${rate(delivered(row), row.runs) * 100}%` }" />
|
||||
</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)" />
|
||||
</template>
|
||||
<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>
|
||||
<EmptyTitle>No stage timings yet</EmptyTitle>
|
||||
</EmptyHeader>
|
||||
|
||||
@@ -12,6 +12,7 @@ export function useWorkflowHistory(id: Ref<string>) {
|
||||
const store = useSettingsStore();
|
||||
const all = ref<ResourceRevision[]>([]);
|
||||
const error = ref("");
|
||||
const loaded = ref(false);
|
||||
|
||||
let generation = 0;
|
||||
async function reload(): Promise<void> {
|
||||
@@ -20,6 +21,7 @@ export function useWorkflowHistory(id: Ref<string>) {
|
||||
all.value = await store.history(KIND);
|
||||
if (current !== generation) return;
|
||||
error.value = "";
|
||||
loaded.value = true;
|
||||
} catch (err) {
|
||||
if (current !== generation) return;
|
||||
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 });
|
||||
|
||||
const revisions = computed(() => workflowRevisions(id.value, all.value));
|
||||
return { revisions, error, reload };
|
||||
return { revisions, error, loaded, reload };
|
||||
}
|
||||
Reference in new issue
Block a user