fix(ui): one run dialog for a workflow; a disabled Run says why (#1953, #1952)

This commit is contained in:
sam committed 2026-11-13 14:30:25 +11:00
1 parent a5ba2c994f
commit 0cfa701f5c
3 files changed
+15 -21

No files matched your search

+3 -1
View File
@@ -8,6 +8,8 @@ import NewTaskForm from "@/tasks/NewTaskForm.vue";
defineProps<{
workflow: string;
disabled?: boolean;
/** Why it is disabled, shown on the button. */
disabledReason?: string;
/** The unsaved definition to test-run; absent runs the stored one. */
draft?: string;
}>();
@@ -31,7 +33,7 @@ function started(taskId: number): void {
variant="outline"
:aria-label="`${draft !== undefined ? 'Test' : 'Run'} ${workflow}`"
:disabled="disabled"
:title="draft !== undefined ? 'Runs this draft once. Every delivery is recorded as what it would have sent and none is sent, including in called workflows; reads, model calls and commands still run' : disabled ? 'Save first' : undefined"
:title="disabled ? disabledReason : draft !== undefined ? 'Runs this draft once; deliveries are recorded, not sent' : undefined"
>
<component :is="draft !== undefined ? FlaskConical : Play" data-icon="inline-start" /> <span>{{ draft !== undefined ? "Test" : "Run" }}</span></Button>
</DialogTrigger>
+3 -1
View File
@@ -341,7 +341,8 @@ async function publish(): Promise<void> {
}
// The run button and draft menu item each control their dialog.
const runOpen = ref(false);
// The page opens this too, from a list row's Run, so there is one run dialog.
const runOpen = defineModel<boolean>("runOpen", { default: false });
const draftOpen = ref(false);
const confirmDelete = ref(false);
const confirmDiscard = ref(false);
@@ -469,6 +470,7 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
:workflow="selected"
:draft="dirty ? yaml : undefined"
:disabled="!parsed.ok"
:disabled-reason="parsed.ok ? undefined : validationLabel(parsed)"
@started="(id) => { view = 'canvas'; void follow(id); }"
/>
</div>
+9 -19
View File
@@ -15,10 +15,8 @@ import {
import { Badge } from "@/components/ui/badge";
import { Card } from "@/components/ui/card";
import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from "@/components/ui/context-menu";
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
import { MoreMenu } from "@/components/ui/more-menu";
import NewTaskForm from "@/tasks/NewTaskForm.vue";
import { Section } from "@/components/ui/section";
import { StatusDot } from "@/components/ui/status-dot";
import { Switch } from "@/components/ui/switch";
@@ -140,13 +138,13 @@ const enabledOf = (id: string) => data.value.definitions?.find((d) => d.id === i
// The editor's tab, so a row can open straight onto its runs.
const view = ref("canvas");
const router = useRouter();
const runTarget = ref("");
const runOpen = computed({
get: () => runTarget.value !== "",
set: (open) => {
if (!open) runTarget.value = "";
},
});
// A row's Run opens the editor's run dialog on that workflow.
const runOpen = ref(false);
function runWorkflow(id: string): void {
selected.value = id;
view.value = "canvas";
runOpen.value = true;
}
async function duplicate(id: string) {
const source = stored.value.find((d) => d.id === id);
@@ -171,7 +169,7 @@ function rowActions(id: string): RowAction[] {
if (enabled !== undefined) actions.push({ label: enabled ? "Disable" : "Enable", icon: Power, run: () => void setEnabled(id, !enabled) });
if (saved) {
actions.push(
{ label: "Run", icon: Play, run: () => (runTarget.value = id) },
{ label: "Run", icon: Play, run: () => runWorkflow(id) },
{
label: "Open runs",
icon: ListChecks,
@@ -265,7 +263,7 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
<Badge v-if="provenance" variant="outline" class="shrink-0">{{ provenance }}</Badge>
<ApplyStatusRows kind="workflow-definitions" compact />
</header>
<WorkflowEditor v-model:selected="selected" v-model:view="view" :stage-stats="stages" :stats-known="statsKnown" :stats-error="error ?? ''">
<WorkflowEditor v-model:selected="selected" v-model:view="view" v-model:run-open="runOpen" :stage-stats="stages" :stats-known="statsKnown" :stats-error="error ?? ''">
<template #title>
<h2 class="min-w-0 truncate text-title font-medium">{{ selected }}</h2>
<Badge v-if="provenance" variant="outline" class="shrink-0">{{ provenance }}</Badge>
@@ -277,13 +275,5 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
</WorkflowEditor>
</Card>
</div>
<Dialog v-model:open="runOpen">
<DialogContent class="sm:max-w-[640px]">
<DialogHeader>
<DialogTitle>Run {{ runTarget }}</DialogTitle>
</DialogHeader>
<NewTaskForm v-if="runTarget" :workflow="runTarget" @started="(taskId) => { runTarget = ''; void router.push(`/tasks/${taskId}`); }" @cancel="runTarget = ''" />
</DialogContent>
</Dialog>
</div>
</template>