fix(ui): plus-only new workflow; restore default workflows moves to task settings

This commit is contained in:
sam committed 2026-10-18 13:18:21 +11:00
1 parent e3147801b0
commit a9cc2c07de
3 files changed
+113 -119

No files matched your search

+36 -2
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import ApplyStatusRows from "./ApplyStatusRows.vue";
import { computed, onMounted } from "vue";
import { computed, onMounted, ref } from "vue";
import { RotateCcw } from "@lucide/vue";
import { storeToRefs } from "pinia";
import { Button } from "@/components/ui/button";
@@ -16,7 +17,18 @@ import {
NumberFieldInput,
} from "@/components/ui/number-field";
import { SettingRow } from "@/components/ui/setting-row";
import { resourcesForPage, useSettingsStore } from "@/stores/settings";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { cloneControlPlaneValue, resourcesForPage, useSettingsStore } from "@/stores/settings";
import { restoreShippedDefinitions, useWorkflowsStore } from "@/stores/workflows";
import DraftHint from "./DraftHint.vue";
import HistoryLink from "./HistoryLink.vue";
import SecretRefField from "./SecretRefField.vue";
@@ -52,6 +64,12 @@ function seconds(key: "max_runtime_seconds" | "max_task_runtime_seconds") {
}
const callRuntime = seconds("max_runtime_seconds");
const taskRuntime = seconds("max_task_runtime_seconds");
const workflows = useWorkflowsStore();
const confirmRestore = ref(false);
async function restoreWorkflows(): Promise<void> {
await workflows.save(cloneControlPlaneValue(restoreShippedDefinitions(workflows.collection, workflows.shipped)));
}
</script>
<template>
@@ -127,5 +145,21 @@ const taskRuntime = seconds("max_task_runtime_seconds");
</div>
</SettingRow>
</template>
<SettingRow v-if="workflows.shipped.definitions.length" label="Workflows" hint="Resets every shipped workflow. Custom workflows are kept.">
<Button variant="outline" size="sm" :disabled="workflows.state.saving" @click="confirmRestore = true"><RotateCcw data-icon="inline-start" />Restore default</Button>
</SettingRow>
<AlertDialog v-model:open="confirmRestore">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Restore default workflows?</AlertDialogTitle>
<AlertDialogDescription>Edits to shipped workflows are discarded.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction @click="restoreWorkflows">Restore</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
<p v-if="workflows.state.error" class="text-sm text-danger" role="alert">{{ workflows.state.error }}</p>
</div>
</template>
+3 -43
View File
@@ -1,19 +1,8 @@
<script setup lang="ts">
import { computed, onMounted, ref, watch } from "vue";
import { useRoute } from "vue-router";
import { Ellipsis, Plus, RotateCcw } from "@lucide/vue";
import { Plus } from "@lucide/vue";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import PageHeader from "@/base/PageHeader.vue";
import { Button } from "@/components/ui/button";
@@ -29,8 +18,7 @@ import { delivered } from "@/lib/delivered";
import { compact } from "@/lib/format";
import { cn } from "@/lib/utils";
import { statusKind, statusLabel } from "@/lib/task-meta";
import { cloneControlPlaneValue } from "@/stores/settings";
import { restoreShippedDefinitions, useWorkflowsStore } from "@/stores/workflows";
import { useWorkflowsStore } from "@/stores/workflows";
import { useLiveResource } from "@/stores/session";
import ApplyStatusRows from "@/settings/ApplyStatusRows.vue";
import SlowestStagesCard from "./SlowestStagesCard.vue";
@@ -170,13 +158,6 @@ function create() {
while (stored.value.some((d) => d.id === `workflow-${n}`)) n++;
selected.value = `workflow-${n}`;
}
const confirmRestore = ref(false);
async function restoreShipped() {
const shipped = store.shipped;
const restored = restoreShippedDefinitions({ definitions: stored.value }, shipped);
if (await store.save(cloneControlPlaneValue(restored)))
selected.value = shipped.definitions[0]?.id ?? "";
}
// The share of a workflow's runs whose work is finished: merged, or ended
// with nothing to merge (a no-change build, a no-code triage -- `completed`).
const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total : 0);
@@ -185,30 +166,9 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
<template>
<div>
<PageHeader title="Workflows">
<DropdownMenu>
<DropdownMenuTrigger as-child>
<Button variant="ghost" size="icon-sm" aria-label="More"><Ellipsis /></Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem :disabled="!store.shipped.definitions.length" @select="confirmRestore = true">
<RotateCcw />Restore shipped workflows</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<Button size="sm" @click="create"><Plus data-icon="inline-start" />New workflow</Button>
<Button size="icon-sm" aria-label="New workflow" title="New workflow" @click="create"><Plus /></Button>
</PageHeader>
<AlertDialog v-model:open="confirmRestore">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Restore shipped workflows?</AlertDialogTitle>
<AlertDialogDescription>Every shipped workflow is reset to its default, discarding edits to it. Custom workflows are kept.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction @click="restoreShipped">Restore</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
<div v-if="error || store.error" class="mb-4 text-sm text-danger" role="alert">
<p>{{ error || store.error }}</p>