fix(ui): show workflow validation errors on the failing step and link to it
This commit is contained in:
3 files changed
+29
-32
No files matched your search
@@ -315,20 +315,15 @@ const problems = computed(() =>
|
||||
}),
|
||||
),
|
||||
);
|
||||
// The parse stops at the first failing step; its node carries that failure too.
|
||||
const nodeProblems = computed(() => {
|
||||
const result = parsed.value;
|
||||
const failed = result.ok ? null : /^workflow \S+ step (\d+)\b/.exec(result.message);
|
||||
if (result.ok || !failed) return problems.value;
|
||||
return { [JSON.stringify(["steps", Number(failed[1]) - 1])]: result.message, ...problems.value };
|
||||
});
|
||||
// A parse failure on a step shows on that node too.
|
||||
const failedPath = computed(() => (parsed.value.ok ? undefined : (parsed.value.path as StepPath | undefined)));
|
||||
const nodeProblems = computed(() =>
|
||||
failedPath.value && !parsed.value.ok ? { ...problems.value, [JSON.stringify(failedPath.value)]: parsed.value.message } : problems.value,
|
||||
);
|
||||
// Every error the editor knows, each linked to its step when it has one.
|
||||
const errors = computed(() => {
|
||||
const list: { text: string; path?: StepPath }[] = [];
|
||||
if (!parsed.value.ok) {
|
||||
const step = /^workflow \S+ step (\d+)\b/.exec(parsed.value.message)?.[1];
|
||||
list.push({ text: validationLabel(parsed.value), path: step ? ["steps", Number(step) - 1] : undefined });
|
||||
}
|
||||
if (!parsed.value.ok) list.push({ text: validationLabel(parsed.value), path: failedPath.value });
|
||||
for (const [key, text] of Object.entries(problems.value)) list.push({ text, path: JSON.parse(key) as StepPath });
|
||||
return list;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user