fix(ui): discarding or restoring over unpublished workflow changes asks first (#1945)
This commit is contained in:
2 files changed
+37
-5
No files matched your search
@@ -129,8 +129,17 @@ function openRevision(version: number): void {
|
||||
historyRevision.value = version;
|
||||
view.value = "history";
|
||||
}
|
||||
// A restored version becomes the draft: nothing runs it until Publish.
|
||||
// A restored version becomes the draft: nothing runs it until Publish. It
|
||||
// replaces unpublished edits, so with any it asks first; while Archie works it
|
||||
// is refused, as Archie's proposal would replace it when the turn ends.
|
||||
const pendingRestore = ref<string | null>(null);
|
||||
function restoreRevision(restored: string): void {
|
||||
if (archieWorking.value) return;
|
||||
if (dirty.value) pendingRestore.value = restored;
|
||||
else applyRestore(restored);
|
||||
}
|
||||
function applyRestore(restored: string): void {
|
||||
pendingRestore.value = null;
|
||||
yaml.value = restored;
|
||||
open.value = null;
|
||||
view.value = "canvas";
|
||||
@@ -328,6 +337,7 @@ async function publish(): Promise<void> {
|
||||
const runOpen = ref(false);
|
||||
const draftOpen = ref(false);
|
||||
const confirmDelete = ref(false);
|
||||
const confirmDiscard = ref(false);
|
||||
async function remove(): Promise<void> {
|
||||
if (!selected.value) return;
|
||||
if (
|
||||
@@ -493,7 +503,7 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
|
||||
<DropdownMenuItem v-if="watchedRun" as-child><RouterLink :to="`/tasks/${watchedRun.id}`">Open run</RouterLink></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="dirty" :disabled="archieWorking" @select="restorePublished"><RotateCcw />Restore</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="dirty" :disabled="archieWorking" @select="confirmDiscard = true"><RotateCcw />Discard changes</DropdownMenuItem>
|
||||
<DropdownMenuItem variant="destructive" @select="confirmDelete = true"><Trash2 />Delete workflow</DropdownMenuItem>
|
||||
</MoreMenu>
|
||||
</div>
|
||||
@@ -561,7 +571,7 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
|
||||
</div>
|
||||
</TabsContent>
|
||||
<TabsContent value="history" class="max-md:min-h-0 max-md:overflow-y-auto">
|
||||
<WorkflowHistory v-model:selected="historyRevision" v-model:mode="historyMode" :revisions="revisions" :current="yaml" :error="historyError" @restore="restoreRevision" @retry="reloadHistory" />
|
||||
<WorkflowHistory v-model:selected="historyRevision" v-model:mode="historyMode" :revisions="revisions" :current="yaml" :error="historyError" :locked="archieWorking" @restore="restoreRevision" @retry="reloadHistory" />
|
||||
</TabsContent>
|
||||
<TabsContent value="performance" class="grid gap-4 max-md:min-h-0 max-md:overflow-y-auto"><slot name="performance" /></TabsContent>
|
||||
<TabsContent value="runs" class="max-md:min-h-0 max-md:overflow-y-auto"><slot name="runs" /></TabsContent>
|
||||
@@ -646,6 +656,28 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<AlertDialog v-model:open="confirmDiscard">
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Discard the unpublished changes to {{ selected }}?</AlertDialogTitle>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction variant="destructive" :disabled="archieWorking" @click="restorePublished">Discard</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<AlertDialog :open="pendingRestore !== null" @update:open="(value: boolean) => { if (!value) pendingRestore = null; }">
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Replace the unpublished changes with this version?</AlertDialogTitle>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction :disabled="archieWorking" @click="applyRestore(pendingRestore!)">Replace</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<AlertDialog v-model:open="confirmDelete">
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
|
||||
@@ -13,7 +13,7 @@ import { cn } from "@/lib/utils";
|
||||
import WorkflowCanvas from "./WorkflowCanvas.vue";
|
||||
import { lineDiff, stepMarks, type WorkflowRevision } from "./workflow-revisions";
|
||||
|
||||
const props = defineProps<{ revisions: WorkflowRevision[]; current: string; error?: string }>();
|
||||
const props = defineProps<{ revisions: WorkflowRevision[]; current: string; error?: string; locked?: boolean }>();
|
||||
const emit = defineEmits<{ restore: [yaml: string]; retry: [] }>();
|
||||
const selected = defineModel<number>("selected", { default: 0 });
|
||||
const mode = defineModel<string>("mode", { default: "yaml" });
|
||||
@@ -70,7 +70,7 @@ const CHANGE_VARIANTS = { added: "default", edited: "secondary", removed: "destr
|
||||
<div v-if="revision" class="flex min-h-0 flex-col gap-2">
|
||||
<div class="flex items-center gap-2 max-md:flex-wrap">
|
||||
<Tabs v-model="mode"><TabsList><TabsTrigger value="yaml">YAML</TabsTrigger><TabsTrigger value="canvas">Canvas</TabsTrigger></TabsList></Tabs>
|
||||
<Button type="button" size="sm" variant="outline" class="ml-auto" :disabled="then === null || identical" :title="then === null ? 'Workflow removed' : undefined" @click="emit('restore', then!)">
|
||||
<Button type="button" size="sm" variant="outline" class="ml-auto" :disabled="then === null || identical || locked" :title="then === null ? 'Workflow removed' : undefined" @click="emit('restore', then!)">
|
||||
<RotateCcw data-icon="inline-start" /> Restore this version</Button>
|
||||
</div>
|
||||
<Empty v-if="then === null"><EmptyHeader><EmptyTitle>Workflow removed in this revision.</EmptyTitle></EmptyHeader></Empty>
|
||||
|
||||
Reference in new issue
Block a user