A test run pins a validated draft, runs with forge and push writes suppressed and recorded per step, and is excluded from workflow stats. The History tab lists revisions that changed a workflow, diffs them as YAML and on the canvas, restores into the editor, and ties runs to the revision they used.
27 lines
915 B
TypeScript
27 lines
915 B
TypeScript
import { computed, ref, watch, type Ref } from "vue";
|
|
|
|
import { useSettingsStore, type ResourceRevision } from "@/stores/settings";
|
|
import { workflowRevisions } from "./workflow-revisions";
|
|
|
|
const KIND = "workflow-definitions";
|
|
|
|
/** The history of workflow `id`, kept current as the definitions change. */
|
|
export function useWorkflowHistory(id: Ref<string>) {
|
|
const store = useSettingsStore();
|
|
const all = ref<ResourceRevision[]>([]);
|
|
const error = ref("");
|
|
|
|
async function reload(): Promise<void> {
|
|
try {
|
|
all.value = await store.history(KIND);
|
|
error.value = "";
|
|
} catch (err) {
|
|
error.value = err instanceof Error ? err.message : "Could not load history";
|
|
}
|
|
}
|
|
watch(() => store.stateFor(KIND).resource?.version, () => void reload(), { immediate: true });
|
|
|
|
const revisions = computed(() => workflowRevisions(id.value, all.value));
|
|
return { revisions, error, reload };
|
|
}
|