fix(ui): plus-only new workflow; restore default workflows moves to task settings
This commit is contained in:
3 files changed
+113
-119
No files matched your search
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user