fix(ui): open validation errors from the indicator and link each to its step

This commit is contained in:
sam committed 2026-10-18 23:47:14 +11:00
1 parent 744b7c75d9
commit 3873a8d9ce
1 file changed
+30 -4
+30 -4
View File
@@ -18,6 +18,7 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { Spinner } from "@/components/ui/spinner";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Textarea } from "@/components/ui/textarea";
@@ -316,6 +317,21 @@ const nodeProblems = computed(() => {
if (result.ok || !failed) return problems.value;
return { [JSON.stringify(["steps", Number(failed[1]) - 1])]: result.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 });
}
for (const [key, text] of Object.entries(problems.value)) list.push({ text, path: JSON.parse(key) as StepPath });
return list;
});
function showError(path?: StepPath): void {
if (!path) return;
view.value = "canvas";
openStepAt(path);
}
const WORKS_ON: Record<string, string> = { optional: "Repository if given", none: "No repository" };
const REQUIRED = "Works on a repository";
const workflowSummary = computed(() =>
@@ -385,10 +401,20 @@ function syncScroll(event: Event): void {
</div>
</div>
<div role="group" aria-label="Edit" class="flex min-w-0 items-center gap-1 border-l pl-2">
<span v-if="!parsed.ok" class="hidden max-w-md truncate text-xs text-danger sm:block" role="status" :title="validationLabel(parsed)">{{ validationLabel(parsed) }}</span>
<span v-if="!parsed.ok" class="sm:hidden" role="status" :title="validationLabel(parsed)">
<CircleAlert class="size-4 text-danger" aria-hidden="true" /><span class="sr-only">{{ validationLabel(parsed) }}</span>
</span>
<Popover v-if="!parsed.ok">
<PopoverTrigger as-child>
<Button type="button" variant="ghost" size="sm" class="min-w-0 max-w-md text-xs text-danger" role="status" :aria-label="validationLabel(parsed)" :title="validationLabel(parsed)">
<CircleAlert /><span class="truncate max-sm:hidden">{{ validationLabel(parsed) }}</span></Button>
</PopoverTrigger>
<PopoverContent align="end" class="max-h-96 w-80 overflow-y-auto p-1">
<ul class="text-xs text-danger">
<li v-for="(error, i) in errors" :key="i">
<button v-if="error.path" type="button" class="w-full rounded px-2 py-1.5 text-left hover:bg-muted hover:underline" @click="showError(error.path)">{{ error.text }}</button>
<p v-else class="px-2 py-1.5">{{ error.text }}</p>
</li>
</ul>
</PopoverContent>
</Popover>
<DropdownMenu>
<DropdownMenuTrigger as-child>
<Button type="button" variant="outline" size="icon-sm" aria-label="More"><Ellipsis /></Button>