diff --git a/src/pages/workflows/[id].tsx b/src/pages/workflows/[id].tsx index bdef677..b3f86d5 100644 --- a/src/pages/workflows/[id].tsx +++ b/src/pages/workflows/[id].tsx @@ -132,26 +132,27 @@ function parseCronToForm(cron: string): { every: number; interval: string } { return { every: 0, interval: "hours" }; } -function SchedulePopover({ value, onChange, workflowId }: { value: string; onChange: (cron: string) => void; workflowId?: string }) { - const parsed = parseCronToForm(value); +function TriggerPopover({ + cronSchedule, onCronChange, webhookToken, workflowId, +}: { + cronSchedule: string; onCronChange: (cron: string) => void; webhookToken: string | null; workflowId?: string; +}) { + const parsed = parseCronToForm(cronSchedule); const [every, setEvery] = useState(parsed.every); const [interval, setInterval] = useState(parsed.interval); useEffect(() => { - const p = parseCronToForm(value); + const p = parseCronToForm(cronSchedule); setEvery(p.every); setInterval(p.interval); - }, [value]); + }, [cronSchedule]); const handleApply = () => { - if (every <= 0) { - onChange(""); - return; - } + if (every <= 0) { handleClear(); return; } const opt = intervalOptions.find((o) => o.value === interval); if (opt) { const cron = opt.cron(every); - onChange(cron); + onCronChange(cron); if (workflowId) { updateWorkflow(workflowId, { cronSchedule: cron } as any) .then(() => hotToast.success(`Schedule set — every ${every} ${interval}`)) @@ -163,7 +164,7 @@ function SchedulePopover({ value, onChange, workflowId }: { value: string; onCha const handleClear = () => { setEvery(0); setInterval("hours"); - onChange(""); + onCronChange(""); if (workflowId) { updateWorkflow(workflowId, { cronSchedule: null } as any) .then(() => hotToast.success("Schedule cleared")) @@ -171,51 +172,81 @@ function SchedulePopover({ value, onChange, workflowId }: { value: string; onCha } }; - const summaryLabel = value - ? `Every ${parseCronToForm(value).every} ${parseCronToForm(value).interval}` - : "Schedule"; + const hasSchedule = !!cronSchedule; + const hasWebhook = !!webhookToken; + const isActive = hasSchedule || hasWebhook; + + const webhookUrl = webhookToken + ? `${typeof window !== "undefined" ? window.location.origin : ""}/api/webhooks/${webhookToken}` + : ""; return ( - - -
- -
- setEvery(parseInt(e.target.value) || 0)} - placeholder="0" - /> - + +
+ {/* Schedule section */} +
+
+ + Schedule + {hasSchedule && {cronSchedule}} +
+
+ Every + setEvery(parseInt(e.target.value) || 0)} + placeholder="—" + /> + +
+
+ + +
- {every > 0 && ( -

- {intervalOptions.find((o) => o.value === interval)?.cron(every)} + +

+ + {/* Webhook section */} +
+
+ + Webhook +
+ +

+ Configure this URL in Immich admin webhook settings to trigger on events.

- )} -
- -
@@ -459,36 +490,14 @@ function WorkflowEditorInner() { }} />
-
- - {/* Schedule config */} - - - {/* Webhook URL */} - - - - - -
- - -

- Configure this URL in Immich admin webhook settings to trigger this workflow on events. -

-
-
-
- -
+ +