feat(ui): workflow header shows Publish only with a draft; enabling moves to the list (#1955)
This commit is contained in:
2 files changed
+6
-10
No files matched your search
@@ -10,7 +10,7 @@ import {
|
|||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
} from "@/components/ui/alert-dialog";
|
} from "@/components/ui/alert-dialog";
|
||||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||||
import { CircleAlert, RotateCcw, Trash2 } from "@lucide/vue";
|
import { CircleAlert, Copy, RotateCcw, Trash2 } from "@lucide/vue";
|
||||||
import { isSending, setTurnHooks } from "@/chat/state";
|
import { isSending, setTurnHooks } from "@/chat/state";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@@ -69,6 +69,7 @@ const modelAliases = computed(() =>
|
|||||||
const collection = computed(() => workflows.collection);
|
const collection = computed(() => workflows.collection);
|
||||||
// Which definition is open belongs to the page, which also lists them.
|
// Which definition is open belongs to the page, which also lists them.
|
||||||
const selected = defineModel<string>("selected", { required: true });
|
const selected = defineModel<string>("selected", { required: true });
|
||||||
|
const emit = defineEmits<{ duplicate: [id: string] }>();
|
||||||
// Stage statistics are read by the page with the rest of the workflow stats.
|
// Stage statistics are read by the page with the rest of the workflow stats.
|
||||||
defineProps<{ stageStats: StageStats[]; statsKnown: boolean; statsError: string }>();
|
defineProps<{ stageStats: StageStats[]; statsKnown: boolean; statsError: string }>();
|
||||||
const id = ref("");
|
const id = ref("");
|
||||||
@@ -503,7 +504,7 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
|
|||||||
</ul>
|
</ul>
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
<span v-if="view === 'canvas' || view === 'yaml'" class="shrink-0" :title="publishBlocked">
|
<span v-if="dirty && (view === 'canvas' || view === 'yaml')" class="shrink-0" :title="publishBlocked">
|
||||||
<Button type="button" size="sm" class="disabled:bg-muted disabled:text-fg-muted disabled:opacity-100" :disabled="state.saving || !!publishBlocked" @click="publish">
|
<Button type="button" size="sm" class="disabled:bg-muted disabled:text-fg-muted disabled:opacity-100" :disabled="state.saving || !!publishBlocked" @click="publish">
|
||||||
<Spinner v-if="state.saving" data-icon="inline-start" />Publish</Button>
|
<Spinner v-if="state.saving" data-icon="inline-start" />Publish</Button>
|
||||||
</span>
|
</span>
|
||||||
@@ -514,6 +515,7 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
|
|||||||
<DropdownMenuItem v-if="watchedRevision" @select="openRevision(watchedRevision.version)">Version {{ watchedRevision.version }}</DropdownMenuItem>
|
<DropdownMenuItem v-if="watchedRevision" @select="openRevision(watchedRevision.version)">Version {{ watchedRevision.version }}</DropdownMenuItem>
|
||||||
<DropdownMenuItem v-if="changes.length" @select="draftOpen = true">Draft changes <span class="ml-auto font-mono text-caption text-fg-subtle">{{ changes.length }}</span></DropdownMenuItem>
|
<DropdownMenuItem v-if="changes.length" @select="draftOpen = true">Draft changes <span class="ml-auto font-mono text-caption text-fg-subtle">{{ changes.length }}</span></DropdownMenuItem>
|
||||||
<DropdownMenuItem v-if="dirty" :disabled="archieWorking" @select="confirmDiscard = true"><RotateCcw />Discard changes</DropdownMenuItem>
|
<DropdownMenuItem v-if="dirty" :disabled="archieWorking" @select="confirmDiscard = true"><RotateCcw />Discard changes</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem v-if="stored !== undefined" @select="emit('duplicate', selected)"><Copy />Duplicate</DropdownMenuItem>
|
||||||
<DropdownMenuItem variant="destructive" @select="confirmDelete = true"><Trash2 />Delete workflow</DropdownMenuItem>
|
<DropdownMenuItem variant="destructive" @select="confirmDelete = true"><Trash2 />Delete workflow</DropdownMenuItem>
|
||||||
</MoreMenu>
|
</MoreMenu>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
|||||||
import { MoreMenu } from "@/components/ui/more-menu";
|
import { MoreMenu } from "@/components/ui/more-menu";
|
||||||
import { Section } from "@/components/ui/section";
|
import { Section } from "@/components/ui/section";
|
||||||
import { StatusDot } from "@/components/ui/status-dot";
|
import { StatusDot } from "@/components/ui/status-dot";
|
||||||
import { Switch } from "@/components/ui/switch";
|
|
||||||
import { api, describeError } from "@/lib/api";
|
import { api, describeError } from "@/lib/api";
|
||||||
import { errors } from "@/copy/errors";
|
import { errors } from "@/copy/errors";
|
||||||
import { keepValue } from "@/lib/keep-unchanged";
|
import { keepValue } from "@/lib/keep-unchanged";
|
||||||
@@ -121,9 +120,6 @@ const provenance = computed(() => {
|
|||||||
if (shippedYAML === undefined) return "Custom";
|
if (shippedYAML === undefined) return "Custom";
|
||||||
return shippedYAML === storedYAML ? "" : "Edited";
|
return shippedYAML === storedYAML ? "" : "Edited";
|
||||||
});
|
});
|
||||||
// A workflow the server does not list yet (a new, unsaved one) has no
|
|
||||||
// enabled state to show.
|
|
||||||
const enabled = computed(() => data.value.definitions?.find((d) => d.id === selected.value)?.enabled);
|
|
||||||
async function setEnabled(id: string, value: boolean) {
|
async function setEnabled(id: string, value: boolean) {
|
||||||
try {
|
try {
|
||||||
await api.workflowEnabled(id, value);
|
await api.workflowEnabled(id, value);
|
||||||
@@ -228,6 +224,7 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
|
|||||||
<span class="flex items-baseline gap-2">
|
<span class="flex items-baseline gap-2">
|
||||||
<span class="min-w-0 flex-1 truncate text-label" :class="row.id === selected && 'font-medium'">{{ row.id }}</span>
|
<span class="min-w-0 flex-1 truncate text-label" :class="row.id === selected && 'font-medium'">{{ row.id }}</span>
|
||||||
<Badge v-if="store.drafts.some((draft) => draft.id === row.id)" variant="outline">Draft</Badge>
|
<Badge v-if="store.drafts.some((draft) => draft.id === row.id)" variant="outline">Draft</Badge>
|
||||||
|
<Badge v-if="enabledOf(row.id) === false" variant="secondary">Disabled</Badge>
|
||||||
<span v-if="row.avg_tokens" class="font-mono text-caption text-fg-subtle" :title="`${row.avg_tokens.toLocaleString()} tokens per run on average`">{{ compact(row.avg_tokens) }} tok</span>
|
<span v-if="row.avg_tokens" class="font-mono text-caption text-fg-subtle" :title="`${row.avg_tokens.toLocaleString()} tokens per run on average`">{{ compact(row.avg_tokens) }} tok</span>
|
||||||
</span>
|
</span>
|
||||||
<span class="mt-1.5 flex items-center gap-2 text-caption text-fg-subtle">
|
<span class="mt-1.5 flex items-center gap-2 text-caption text-fg-subtle">
|
||||||
@@ -271,15 +268,12 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
|
|||||||
<Badge v-if="provenance" variant="outline" class="shrink-0">{{ provenance }}</Badge>
|
<Badge v-if="provenance" variant="outline" class="shrink-0">{{ provenance }}</Badge>
|
||||||
<ApplyStatusRows kind="workflow-definitions" compact />
|
<ApplyStatusRows kind="workflow-definitions" compact />
|
||||||
</header>
|
</header>
|
||||||
<WorkflowEditor v-model:selected="selected" v-model:view="view" v-model:run-open="runOpen" :stage-stats="stages" :stats-known="statsKnown" :stats-error="error ?? ''">
|
<WorkflowEditor v-model:selected="selected" v-model:view="view" v-model:run-open="runOpen" @duplicate="duplicate" :stage-stats="stages" :stats-known="statsKnown" :stats-error="error ?? ''">
|
||||||
<template #title>
|
<template #title>
|
||||||
<h2 class="min-w-0 truncate text-title font-medium">{{ selected }}</h2>
|
<h2 class="min-w-0 truncate text-title font-medium">{{ selected }}</h2>
|
||||||
<Badge v-if="provenance" variant="outline" class="shrink-0">{{ provenance }}</Badge>
|
<Badge v-if="provenance" variant="outline" class="shrink-0">{{ provenance }}</Badge>
|
||||||
<ApplyStatusRows kind="workflow-definitions" compact />
|
<ApplyStatusRows kind="workflow-definitions" compact />
|
||||||
</template>
|
</template>
|
||||||
<template v-if="enabled !== undefined" #toolbar>
|
|
||||||
<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>
|
|
||||||
</WorkflowEditor>
|
</WorkflowEditor>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user