refactor(ui): Empty, Spinner and Label replace hand-built equivalents

This commit is contained in:
sam committed 2026-10-26 22:11:39 +11:00
1 parent 17c07a31fe
commit a203cbc03b
37 files changed
+215 -193

No files matched your search

+3 -2
View File
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
import { SuggestInput } from "@/components/ui/suggest-input";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
@@ -261,7 +262,7 @@ const resume = () => transition(api.bindingResume, "pending_approval");
<div v-if="loading" class="flex flex-1 items-center justify-center"><Spinner /></div>
<form v-else class="flex-1 space-y-5 overflow-y-auto px-4 py-4" @submit.prevent="save">
<section class="space-y-1.5">
<label for="bind-source" class="text-xs font-medium text-fg-muted">Source</label>
<Label for="bind-source" class="text-xs font-medium text-fg-muted">Source</Label>
<OptionSelect id="bind-source" aria-label="Source" :model-value="source" :options="sourceOptions" class="w-full" :disabled="!!binding" @update:model-value="source = $event" />
<Input
v-if="source === NEW_SOURCE"
@@ -276,7 +277,7 @@ const resume = () => transition(api.bindingResume, "pending_approval");
<SourceSecret v-if="revealed" :source="revealed" @dismiss="revealed = null" />
<section v-if="sourcePath" class="space-y-1.5">
<label for="bind-capture" class="text-xs font-medium text-fg-muted">Example event</label>
<Label for="bind-capture" class="text-xs font-medium text-fg-muted">Example event</Label>
<Select v-if="sourceCaptures.length" :model-value="captureId ?? undefined" @update:model-value="captureId = String($event)">
<SelectTrigger id="bind-capture" size="sm" class="w-full" aria-label="Example event"><SelectValue placeholder="Pick an event" /></SelectTrigger>
<SelectContent>
+2 -1
View File
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { Label } from "@/components/ui/label";
import { computed, onMounted, ref } from "vue";
import { ArrowLeft } from "@lucide/vue";
@@ -189,7 +190,7 @@ async function remove(): Promise<void> {
<div v-if="loading" class="flex flex-1 items-center justify-center"><Spinner /></div>
<form v-else class="flex-1 space-y-5 overflow-y-auto px-4 py-4" @submit.prevent="save">
<section class="space-y-1.5">
<label for="schedule-trigger" class="text-xs font-medium text-fg-muted">Schedule</label>
<Label for="schedule-trigger" class="text-xs font-medium text-fg-muted">Schedule</Label>
<p v-if="loadError" class="text-xs text-danger" role="alert">{{ loadError }}</p>
<OptionSelect v-else id="schedule-trigger" aria-label="Schedule" :model-value="scheduleId" :options="scheduleOptions" class="w-full" @update:model-value="pickSchedule" />
</section>
+10 -9
View File
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { Label } from "@/components/ui/label";
import { computed, ref, useId } from "vue";
import { ChevronDown, CircleHelp, Plus, Trash2 } from "@lucide/vue";
import { parse, stringify } from "yaml";
@@ -158,10 +159,10 @@ const ON_FAILURE = [{ value: "", label: "Park the task" }, { value: "continue",
<p v-if="problem" class="rounded-md bg-danger/10 px-2.5 py-1.5 text-xs text-danger" role="alert">{{ problem }}</p>
<section v-if="branching" class="space-y-3">
<label v-if="type === 'switch'" class="block space-y-1.5">
<Label v-if="type === 'switch'" class="block space-y-1.5">
<span class="text-xs font-medium text-fg-muted" title="The value whose case runs; a case named default runs when none matches">Switch on</span>
<SuggestInput :model-value="branching.on" class="font-mono" placeholder="steps.assess.result.fit" :options="earlier.map((id) => `steps.${id}.result.`)" @change="setOn(($event.target as HTMLInputElement).value.trim())" />
</label>
</Label>
<div class="text-xs font-medium text-fg-muted">{{ type === "switch" ? "Cases" : "Branches" }}</div>
<div v-for="name in branches" :key="name" class="flex items-center gap-2">
<Input :model-value="name" :class="type === 'switch' && 'font-mono'" :aria-label="`${type === 'switch' ? 'Case' : 'Branch'} ${name}`" @change="changeBranch('rename', name, ($event.target as HTMLInputElement).value.trim())" />
@@ -276,7 +277,7 @@ const ON_FAILURE = [{ value: "", label: "Park the task" }, { value: "continue",
<section class="space-y-1.5">
<p v-if="flowProblem" role="alert" class="text-xs text-danger">{{ flowProblem }}</p>
<div class="divide-y divide-border rounded-md border border-border">
<label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
<Label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
<span class="flex-1 text-label" title="Empty always runs. A field such as inputs.enabled, !inputs.skip, or steps.plan.result.ready == true">Run only when</span>
<Input
class="h-8 w-48 font-mono text-xs"
@@ -285,12 +286,12 @@ const ON_FAILURE = [{ value: "", label: "Park the task" }, { value: "continue",
:model-value="(step.when as string) ?? ''"
@update:model-value="(value) => setField('when', String(value))"
/>
</label>
<label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
</Label>
<Label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
<span class="flex-1 text-label">If it fails</span>
<OptionSelect class="w-36" aria-label="If it fails" :model-value="(step.on_failure as string) ?? ''" :options="ON_FAILURE" @update:model-value="setField('on_failure', $event || undefined)" />
</label>
<label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
</Label>
<Label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
<span class="flex-1 text-label">Attempts</span>
<Input
type="number"
@@ -301,9 +302,9 @@ const ON_FAILURE = [{ value: "", label: "Park the task" }, { value: "continue",
:model-value="(step.retry as { attempts?: number } | undefined)?.attempts ?? ''"
@update:model-value="(value) => setRetry({ attempts: String(value) === '' ? undefined : Number(String(value)) })"
/>
</label>
</Label>
<div class="flex min-h-10 items-center gap-3 px-3 py-1.5">
<label :for="`${uid}-backoff`" class="flex-1 text-label">Retry backoff</label>
<Label :for="`${uid}-backoff`" class="flex-1 text-label">Retry backoff</Label>
<DurationInput
:id="`${uid}-backoff`"
:model-value="(step.retry as { backoff?: string } | undefined)?.backoff ?? ''"
+1 -1
View File
@@ -449,7 +449,7 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
</MoreMenu>
</div>
</div>
<p v-if="runsLoading && !runs.length" class="text-xs text-fg-muted" role="status">Loading recent runs…</p>
<p v-if="runsLoading && !runs.length" class="flex items-center gap-2 text-xs text-fg-muted"><Spinner />Loading recent runs…</p>
<div v-else-if="runsError" class="text-sm text-danger" role="alert">
<p>Could not load recent runs: {{ runsError }}</p>
<Button type="button" variant="outline" size="sm" @click="refresh">Retry runs</Button>
+10 -9
View File
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { Label } from "@/components/ui/label";
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
@@ -80,7 +81,7 @@ const needs = computed<{ captures?: boolean; gate_retries?: number }>(() => {
<template>
<div class="space-y-4 px-3 py-3">
<div class="divide-y divide-border rounded-md border border-border">
<label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
<Label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
<span class="flex-1 text-label">Runs as</span>
<OptionSelect
:key="String(identitiesLoading)"
@@ -92,13 +93,13 @@ const needs = computed<{ captures?: boolean; gate_retries?: number }>(() => {
class="w-44"
@update:model-value="set('identity', $event)"
/>
</label>
</Label>
<p v-if="identitiesError" role="alert" class="px-3 py-2 text-xs text-danger">{{ identitiesError }} <Button variant="link" size="xs" @click="loadAgents">Retry</Button></p>
<p v-else-if="!identitiesLoading && !agents.length" class="px-3 py-2 text-xs text-fg-subtle">No active agents in your organisation.</p>
<label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
<Label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
<span class="flex-1 text-label">Container profile</span>
<OptionSelect :model-value="text('profile')" :options="profileOptions" aria-label="Container profile" class="w-44" @update:model-value="set('profile', $event || undefined)" />
</label>
</Label>
<div class="flex min-h-10 items-center gap-3 px-3 py-1.5">
<span class="flex-1 text-label">Works on</span>
<ToggleGroup
@@ -112,11 +113,11 @@ const needs = computed<{ captures?: boolean; gate_retries?: number }>(() => {
<ToggleGroupItem v-for="mode in MODES" :key="mode.value" :value="mode.value" :title="mode.hint">{{ mode.label }}</ToggleGroupItem>
</ToggleGroup>
</div>
<label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
<Label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
<span class="flex-1 text-label" title="Stages return structured output through capture tools">Captures</span>
<Switch :model-value="needs.captures === true" @update:model-value="set('needs', { ...needs, captures: $event || undefined })" />
</label>
<label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
</Label>
<Label class="flex min-h-10 items-center gap-3 px-3 py-1.5">
<span class="flex-1 text-label">Gate retries</span>
<Input
type="number"
@@ -126,11 +127,11 @@ const needs = computed<{ captures?: boolean; gate_retries?: number }>(() => {
:model-value="needs.gate_retries ?? ''"
@update:model-value="(value) => set('needs', { ...needs, gate_retries: String(value) === '' ? undefined : Number(String(value)) })"
/>
</label>
</Label>
</div>
<section class="space-y-1.5">
<label for="workflow-instructions" class="text-xs font-medium text-fg-muted">Instructions</label>
<Label for="workflow-instructions" class="text-xs font-medium text-fg-muted">Instructions</Label>
<Textarea
id="workflow-instructions"
:model-value="text('instructions')"
+3 -2
View File
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { Spinner } from "@/components/ui/spinner";
import { computed, onMounted, ref, watch } from "vue";
import { useRoute } from "vue-router";
import { Plus } from "@lucide/vue";
@@ -176,7 +177,7 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
<p>{{ error || store.error }}</p>
<Button variant="outline" size="sm" @click="load(); store.load()">Retry</Button>
</div>
<p v-if="loading || (!store.state.resource && !store.error)" class="text-sm text-fg-muted" role="status">Loading workflows…</p>
<p v-if="loading || (!store.state.resource && !store.error)" class="flex items-center gap-2 text-sm text-fg-muted"><Spinner />Loading workflows…</p>
<div class="grid items-start gap-6 lg:grid-cols-[24rem_minmax(0,1fr)] max-md:min-h-0 max-md:flex-1 max-md:grid-rows-[minmax(0,1fr)]">
<div class="hidden min-w-0 flex-col gap-1 lg:flex">
@@ -244,7 +245,7 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
</template>
</template>
<template #runs>
<p v-if="runsLoading" role="status" class="text-sm text-fg-muted">Loading runs…</p>
<p v-if="runsLoading" class="flex items-center gap-2 text-sm text-fg-muted"><Spinner />Loading runs…</p>
<div v-else-if="runsError" role="alert" class="text-sm text-danger">
<p>{{ runsError }}</p>
<Button variant="outline" size="sm" @click="loadWorkflowRuns">Retry</Button>