fix(frontend) load primary schedule args in detail trigger page (#5388)

* load primary schedule args in detail trigger page

* nit
This commit is contained in:
Guilhem
2025-02-26 12:54:31 +01:00
committed by GitHub
parent 1fd9d72794
commit f3f3678843
2 changed files with 20 additions and 14 deletions
@@ -29,6 +29,7 @@
let initialPrimarySchedule: Writable<ScheduleTrigger | false | undefined> = writable(undefined)
async function updateSchedules(forceRefresh: boolean) {
const loadPrimarySchedule = true
loadSchedules(
forceRefresh,
path,
@@ -37,7 +38,8 @@
primarySchedule,
initialPrimarySchedule,
$workspaceStore ?? '',
triggersCount
triggersCount,
loadPrimarySchedule
)
}
@@ -5,7 +5,7 @@ import { get } from 'svelte/store'
import { sendUserToast } from '$lib/utils'
// Load the schedule of a flow given its path and the workspace
export async function loadFlowSchedule(path: string, workspace: string): Promise<ScheduleTrigger> {
export async function loadSchedule(path: string, workspace: string): Promise<ScheduleTrigger> {
const existsSchedule = await ScheduleService.existsSchedule({
workspace,
path
@@ -37,16 +37,15 @@ export async function loadSchedules(
primarySchedule: Writable<ScheduleTrigger | false | undefined>,
initialPrimarySchedule: Writable<ScheduleTrigger | false | undefined>,
workspace: string,
triggersCount: Writable<TriggersCount | undefined>
triggersCount: Writable<TriggersCount | undefined>,
loadPrimarySchedule: boolean = false
) {
console.log('loading schedules for path', path)
if (!path || path == '') {
schedules.set([])
primarySchedule.update((ps) => (ps === undefined ? false : ps))
initialPrimarySchedule.set(structuredClone(get(primarySchedule)))
return
}
console.log('loading schedules for path', path)
try {
const allSchedules = await ScheduleService.listSchedules({
workspace,
@@ -54,15 +53,20 @@ export async function loadSchedules(
isFlow
})
const primary = allSchedules.find((s) => s.path == path)
let remotePrimarySchedule: ScheduleTrigger | false | undefined = primary
? {
summary: primary.summary,
args: primary.args ?? {},
cron: primary.schedule,
timezone: primary.timezone,
enabled: primary.enabled
}
: false
let remotePrimarySchedule: ScheduleTrigger | false | undefined = undefined
if (loadPrimarySchedule && primary) {
remotePrimarySchedule = await loadSchedule(path, workspace)
} else {
remotePrimarySchedule = primary
? {
summary: primary.summary,
args: primary.args ?? {},
cron: primary.schedule,
timezone: primary.timezone,
enabled: primary.enabled
}
: false
}
primarySchedule.update((ps) => (ps === undefined || forceRefresh ? remotePrimarySchedule : ps))
initialPrimarySchedule.set(structuredClone(remotePrimarySchedule))