diff --git a/ui/src/schedules/SchedulesPage.vue b/ui/src/schedules/SchedulesPage.vue index 3855dea45..28affabcf 100644 --- a/ui/src/schedules/SchedulesPage.vue +++ b/ui/src/schedules/SchedulesPage.vue @@ -44,7 +44,7 @@ import ApplyStatusRows from "@/settings/ApplyStatusRows.vue"; import DraftHint from "@/settings/DraftHint.vue"; import HistoryLink from "@/settings/HistoryLink.vue"; import ScheduleEditor from "./ScheduleEditor.vue"; -import { runDuration, timingWords, type Schedule, type ScheduleSettings } from "./schedule"; +import { blankSchedule, runDuration, timingWords, type Schedule, type ScheduleSettings } from "./schedule"; const SETTINGS = "schedule-settings"; @@ -128,19 +128,9 @@ function edit(schedule: Schedule, title: string): void { editorTitle.value = title; editorOpen.value = true; } -function blank(): Schedule { - return { - id: crypto.randomUUID(), - name: "", - owner: { kind: "instance" }, - enabled: true, - built_in: false, - timing: { kind: "interval", interval: "24h0m0s" }, - }; -} -const create = () => edit(blank(), "New schedule"); +const create = () => edit(blankSchedule(), "New schedule"); const duplicate = (schedule: Schedule) => - edit({ ...blank(), name: `${schedule.name} copy`, timing: { ...schedule.timing }, enabled: false }, "Duplicate schedule"); + edit({ ...blankSchedule(), name: `${schedule.name} copy`, timing: { ...schedule.timing }, enabled: false }, "Duplicate schedule"); const removing = ref(null); const remove = () => diff --git a/ui/src/schedules/schedule.ts b/ui/src/schedules/schedule.ts index 8adbefcd3..98ca6ea56 100644 --- a/ui/src/schedules/schedule.ts +++ b/ui/src/schedules/schedule.ts @@ -163,3 +163,15 @@ export const RESULT_TONE: Record = failed: "danger", skipped: "warn", }; + +/** A new schedule's starting values: runs daily, owned by the instance. */ +export function blankSchedule(): Schedule { + return { + id: crypto.randomUUID(), + name: "", + owner: { kind: "instance" }, + enabled: true, + built_in: false, + timing: { kind: "interval", interval: "24h0m0s" }, + }; +} diff --git a/ui/src/workflows/BindEvent.vue b/ui/src/workflows/BindEvent.vue index 4bbe71053..f2a9868d8 100644 --- a/ui/src/workflows/BindEvent.vue +++ b/ui/src/workflows/BindEvent.vue @@ -250,12 +250,14 @@ async function save(): Promise { } // transition runs one lifecycle command and shows the status it leads to. -async function transition(command: (id: string) => Promise, next: string): Promise { +// The server answers with the binding as it now stands; its status is what +// the form shows, not a guess at the next state. +async function transition(command: (id: string) => Promise): Promise { if (!props.binding) return; error.value = ""; try { - await command(props.binding.id); - status.value = next; + const updated = (await command(props.binding.id)) as { status?: string } | undefined; + if (updated?.status) status.value = updated.status; emit("saved"); } catch (err) { error.value = describeError(err, errors.common.unknown); @@ -274,9 +276,9 @@ async function removeBinding(): Promise { saving.value = false; } } -const approve = () => transition(api.bindingApprove, "armed"); -const pause = () => transition(api.bindingPause, "paused"); -const resume = () => transition(api.bindingResume, "pending_approval"); +const approve = () => transition(api.bindingApprove); +const pause = () => transition(api.bindingPause); +const resume = () => transition(api.bindingResume);