diff --git a/frontend/src/lib/components/Dev.svelte b/frontend/src/lib/components/Dev.svelte index 0453ef9db5..c78eb2afc0 100644 --- a/frontend/src/lib/components/Dev.svelte +++ b/frontend/src/lib/components/Dev.svelte @@ -49,6 +49,7 @@ parseTypescriptDeps } from '$lib/relative_imports' import Tooltip from './Tooltip.svelte' + import type { TriggerContext } from './triggers' $: token = $page.url.searchParams.get('wm_token') ?? undefined $: workspace = $page.url.searchParams.get('workspace') ?? undefined $: themeDarkRaw = $page.url.searchParams.get('activeColorTheme') @@ -485,12 +486,15 @@ const httpTriggersStore = writable(undefined) const schedulesStore = writable(undefined) const primaryScheduleStore = writable(undefined) + setContext('TriggerContext', { + httpTriggers: httpTriggersStore, + schedule: scheduleStore, + primarySchedule: primaryScheduleStore + }) setContext('FlowEditorContext', { selectedId: selectedIdStore, selectedTrigger: selectedTriggerStore, - httpTriggers: httpTriggersStore, - schedule: scheduleStore, - primarySchedule: primaryScheduleStore, + schedules: schedulesStore, previewArgs: previewArgsStore, scriptEditorDrawer, diff --git a/frontend/src/lib/components/flows/scheduleUtils.ts b/frontend/src/lib/components/flows/scheduleUtils.ts index 2390043ac1..ef1f2b1fde 100644 --- a/frontend/src/lib/components/flows/scheduleUtils.ts +++ b/frontend/src/lib/components/flows/scheduleUtils.ts @@ -1,15 +1,8 @@ import { ScheduleService } from '$lib/gen' - -export type Schedule = { - summary: string | undefined - args: Record - cron: string - timezone: string - enabled: boolean -} +import type { ScheduleTrigger } from '../triggers' // Load the schedule of a flow given its path and the workspace -export async function loadFlowSchedule(path: string, workspace: string): Promise { +export async function loadFlowSchedule(path: string, workspace: string): Promise { const existsSchedule = await ScheduleService.existsSchedule({ workspace, path diff --git a/frontend/src/lib/components/flows/types.ts b/frontend/src/lib/components/flows/types.ts index 2c5cb368d9..d6e7f15122 100644 --- a/frontend/src/lib/components/flows/types.ts +++ b/frontend/src/lib/components/flows/types.ts @@ -3,10 +3,10 @@ import type { History } from '$lib/history' import type { Writable } from 'svelte/store' import type ScriptEditorDrawer from './content/ScriptEditorDrawer.svelte' import type { FlowState } from './flowState' -import type { Schedule as ScheduleUtils } from './scheduleUtils' import type { FlowBuilderWhitelabelCustomUi } from '../custom_ui' import { type HttpTrigger } from '$lib/gen' import type { Schedule } from '$lib/gen' +import type { ScheduleTrigger } from '../triggers' export type FlowInput = Record< string, @@ -33,7 +33,7 @@ export type FlowEditorContext = { selectedTrigger: Writable httpTriggers: Writable<(HttpTrigger & { canWrite: boolean })[] | undefined> moving: Writable<{ module: FlowModule; modules: FlowModule[] } | undefined> - schedule: Writable + schedule: Writable primarySchedule: Writable schedules: Writable previewArgs: Writable> diff --git a/frontend/src/lib/components/triggers.ts b/frontend/src/lib/components/triggers.ts new file mode 100644 index 0000000000..92ba4b3cf7 --- /dev/null +++ b/frontend/src/lib/components/triggers.ts @@ -0,0 +1,18 @@ +import type { HttpTrigger, Schedule } from '$lib/gen' +import type { Writable } from 'svelte/store' + +export type ScheduleTrigger = { + summary: string | undefined + args: Record + cron: string + timezone: string + enabled: boolean +} + +export type TriggerContext = { + selectedTrigger: Writable + httpTriggers: Writable<(HttpTrigger & { canWrite: boolean })[] | undefined> + schedule: Writable + primarySchedule: Writable + schedules: Writable +}