feat(ui): quieter workflows page: hover data edges, apply chip, restore behind confirm
This commit is contained in:
1 parent
5c9ac19882
commit
709ddbf019
13 files changed
+158
-96
No files matched your search
@@ -27,7 +27,7 @@ const path = computed(() =>
|
||||
</EdgeLabelRenderer>
|
||||
<EdgeLabelRenderer v-if="data?.editable && data.insertAfter !== undefined">
|
||||
<div
|
||||
class="workflow-insert absolute"
|
||||
class="workflow-insert absolute p-3 opacity-0 transition-opacity focus-within:opacity-100 hover:opacity-100 has-[[data-state=open]]:opacity-100"
|
||||
:style="{ transform: `translate(-50%, -50%) translate(${path[1]}px, ${path[2]}px)`, pointerEvents: 'all' }"
|
||||
>
|
||||
<AddStepMenu :types="data.types" :label="data.insertAfter.length > 2 ? `Add a step in ${data.insertAfter[3]}` : undefined" @pick="data.onInsert(data.insertAfter!, $event)" />
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Handle, Position } from "@vue-flow/core";
|
||||
import { Flag, Play, Repeat, SkipForward, Webhook, CircleDot, BookOpen, Workflow } from "@lucide/vue";
|
||||
|
||||
import { stepIcon } from "./step-icons";
|
||||
import type { StepNodeData } from "./workflow-graph";
|
||||
import { stepTitle, type StepNodeData } from "./workflow-graph";
|
||||
|
||||
const props = defineProps<{ data: StepNodeData }>();
|
||||
|
||||
@@ -58,7 +58,7 @@ function duration(ms?: number): string {
|
||||
<span v-if="data.step" class="font-mono text-[11px] text-fg-subtle">{{ data.step }}</span>
|
||||
<span class="truncate text-sm font-medium" :title="data.title">{{ data.title }}</span>
|
||||
</div>
|
||||
<div v-if="data.type && data.type !== data.title" class="truncate font-mono text-[11px] text-fg-subtle">{{ data.type }}</div>
|
||||
<div v-if="data.type && data.title !== stepTitle(data.type)" class="truncate font-mono text-[11px] text-fg-subtle">{{ data.type }}</div>
|
||||
<ul v-if="data.kind === 'start' && data.triggers?.length" class="mt-1 space-y-0.5">
|
||||
<li v-for="trigger in data.triggers" :key="trigger.kind + trigger.label" class="flex items-center gap-1.5 text-xs" :title="trigger.detail">
|
||||
<component :is="TRIGGER_ICONS[trigger.kind]" class="size-3 shrink-0 text-primary" aria-hidden="true" />
|
||||
|
||||
@@ -74,8 +74,15 @@ const nodes = computed(() =>
|
||||
// The run's trace: an edge lights once the run has reached its target, in the
|
||||
// colour of how that step went, and moves while the step is running.
|
||||
const runs = computed(() => new Map(graph.value.nodes.map((node) => [node.id, node.data.run?.status])));
|
||||
// Data edges bundle into noise, so only the hovered or selected step's show.
|
||||
const hovered = ref<string | null>(null);
|
||||
const focusId = computed(
|
||||
() => hovered.value ?? graph.value.nodes.find((node) => props.selected && JSON.stringify(node.data.path ?? null) === selectedKey.value)?.id,
|
||||
);
|
||||
const edges = computed(() =>
|
||||
graph.value.edges.map(({ label, offset, insertAfter, otherwise, ...edge }) =>
|
||||
graph.value.edges
|
||||
.filter((edge) => edge.kind === "flow" || edge.source === focusId.value || edge.target === focusId.value)
|
||||
.map(({ label, offset, insertAfter, otherwise, ...edge }) =>
|
||||
edge.kind === "flow"
|
||||
? {
|
||||
...edge,
|
||||
@@ -152,6 +159,8 @@ const beforePath = computed(() => menuPath.value ? [...menuPath.value.slice(0, -
|
||||
pan-on-scroll
|
||||
@pane-ready="place"
|
||||
@node-click="onNodeClick"
|
||||
@node-mouse-enter="hovered = $event.node.id"
|
||||
@node-mouse-leave="hovered = null"
|
||||
@node-context-menu="onNodeMenu"
|
||||
@pane-context-menu="openMenu($event as MouseEvent)"
|
||||
>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import ApplyStatusRows from "@/settings/ApplyStatusRows.vue";
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { Ellipsis, RotateCcw, Trash2, X } from "@lucide/vue";
|
||||
|
||||
@@ -198,7 +197,6 @@ function syncScroll(event: Event): void {
|
||||
|
||||
<template>
|
||||
<form class="space-y-4" @submit.prevent="saveDraft">
|
||||
<ApplyStatusRows kind="workflow-definitions" />
|
||||
<Tabs v-model="view" class="space-y-1.5">
|
||||
<div class="flex items-center gap-2">
|
||||
<TabsList>
|
||||
@@ -250,7 +248,7 @@ function syncScroll(event: Event): void {
|
||||
<TabsContent value="canvas" class="space-y-2">
|
||||
<!-- The canvas takes the height the viewport has left, so the page
|
||||
itself does not scroll; the canvas pans. -->
|
||||
<div class="relative h-[calc(100dvh-20.5rem)] min-h-[26rem]">
|
||||
<div class="relative h-[calc(100dvh-17rem)] min-h-[26rem]">
|
||||
<p v-if="restartError" role="alert" class="absolute bottom-3 left-14 z-10 max-w-xl rounded-md border border-danger/40 bg-card px-3 py-2 text-sm text-danger shadow-lg">{{ restartError }}</p>
|
||||
<WorkflowCanvas
|
||||
:yaml="yaml"
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watchEffect } from "vue";
|
||||
import { Plus, RotateCcw } from "@lucide/vue";
|
||||
import { Ellipsis, Plus, RotateCcw } 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";
|
||||
@@ -18,6 +30,7 @@ import { cn } from "@/lib/utils";
|
||||
import { statusLabel } from "@/lib/task-meta";
|
||||
import { cloneControlPlaneValue, restoreShippedDefinitions, useControlPlaneStore, type WorkflowDefinitionCollection } from "@/stores/control-plane";
|
||||
import { useLiveResource } from "@/stores/live-updates";
|
||||
import ApplyStatusRows from "@/settings/ApplyStatusRows.vue";
|
||||
import SlowestStagesCard from "./SlowestStagesCard.vue";
|
||||
import StageFailuresCard from "./StageFailuresCard.vue";
|
||||
import type { StageStats } from "./stages";
|
||||
@@ -105,6 +118,7 @@ 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.shippedWorkflows();
|
||||
const restored = restoreShippedDefinitions({ definitions: stored.value }, shipped);
|
||||
@@ -119,12 +133,32 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader title="Workflows">
|
||||
<Button variant="ghost" size="sm" :disabled="!store.shippedWorkflows().definitions.length" @click="restoreShipped">
|
||||
<RotateCcw data-icon="inline-start" /> Restore shipped
|
||||
</Button>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger as-child>
|
||||
<Button variant="ghost" size="icon-sm" aria-label="More"><Ellipsis /></Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem :disabled="!store.shippedWorkflows().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>
|
||||
</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. Your own workflows are kept.</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction @click="restoreShipped">Restore</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
<p v-if="error" class="mb-4 text-sm text-danger" role="alert">Cannot reach archied: {{ error }}</p>
|
||||
|
||||
<div class="grid items-start gap-6 lg:grid-cols-[24rem_minmax(0,1fr)]">
|
||||
@@ -162,10 +196,13 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
|
||||
<header class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<h2 class="font-mono text-[15px] font-medium">{{ selected }}</h2>
|
||||
<StatusPill v-if="provenance">{{ provenance }}</StatusPill>
|
||||
<label v-if="enabled !== undefined" class="ml-auto flex items-center gap-2 text-xs text-fg-muted">
|
||||
Enabled
|
||||
<Switch :model-value="enabled" aria-label="Workflow enabled" @update:model-value="setEnabled" />
|
||||
</label>
|
||||
<div class="ml-auto flex items-center gap-3">
|
||||
<ApplyStatusRows kind="workflow-definitions" compact />
|
||||
<label v-if="enabled !== undefined" class="flex items-center gap-2 text-xs text-fg-muted">
|
||||
Enabled
|
||||
<Switch :model-value="enabled" aria-label="Workflow enabled" @update:model-value="setEnabled" />
|
||||
</label>
|
||||
</div>
|
||||
</header>
|
||||
<WorkflowEditor v-model:selected="selected" :runs-count="workflowRuns.length">
|
||||
<template #performance>
|
||||
|
||||
@@ -219,7 +219,7 @@ function stepSummary(settings: Mapping): string | undefined {
|
||||
const value = settings[key];
|
||||
if (typeof value !== "string" || !value.trim()) continue;
|
||||
return value
|
||||
.replace(/\{\{\s*([^}]+?)\s*\}\}/g, "‹$1›")
|
||||
.replace(/\{\{\s*([^}]+?)\s*\}\}/g, (_, ref: string) => `‹${ref.replace(/^steps\./, "").replace(/\.result\b/, "")}›`)
|
||||
.split("\n")
|
||||
.find((line) => line.trim())
|
||||
?.trim();
|
||||
|
||||
Reference in new issue
Block a user