mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-30 00:16:53 +00:00
* fix everything * fix(frontend): Restore module deletion + restore for loop settings * fix(frontend): Add missing focus on number inputs * fix(frontend): Add key wrapper to make sure the editor content is reloaded * fix(frontend): Fix mini-map spacing + add icon to schedule and retry buttons Co-authored-by: Faton Ramadani <faton.ramadani14@gmail.com>
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
import type { Schema } from '$lib/common'
|
|
import type { Flow, FlowModule } from '$lib/gen'
|
|
import { derived, writable } from 'svelte/store'
|
|
import { emptyFlowModuleSchema, isEmptyFlowModule, loadFlowModuleSchema } from './flowStateUtils'
|
|
|
|
export type FlowModuleState = {
|
|
schema: Schema
|
|
childFlowModules?: FlowModuleState[]
|
|
previewResult?: any
|
|
}
|
|
|
|
export type FlowState = {
|
|
modules: FlowModuleState[]
|
|
failureModule: FlowModuleState
|
|
}
|
|
|
|
export const flowStateStore = writable<FlowState>(undefined)
|
|
|
|
export async function initFlowState(flow: Flow) {
|
|
const modules = await mapFlowModules(flow.value.modules)
|
|
|
|
const failureModule = flow.value.failure_module
|
|
? await mapFlowModule(flow.value.failure_module)
|
|
: emptyFlowModuleSchema()
|
|
|
|
flowStateStore.set({
|
|
modules,
|
|
failureModule
|
|
})
|
|
}
|
|
|
|
|
|
|
|
async function mapFlowModule(flowModule: FlowModule) {
|
|
const value = flowModule.value
|
|
if (value.type === 'forloopflow') {
|
|
const childFlowModules = await Promise.all(
|
|
value.modules.map(async (module) => loadFlowModuleSchema(module))
|
|
)
|
|
const loopFlowModule = await loadFlowModuleSchema(flowModule)
|
|
|
|
return {
|
|
...loopFlowModule,
|
|
childFlowModules
|
|
}
|
|
}
|
|
|
|
if (isEmptyFlowModule(flowModule)) {
|
|
return emptyFlowModuleSchema()
|
|
}
|
|
|
|
return loadFlowModuleSchema(flowModule)
|
|
}
|
|
|
|
export async function mapFlowModules(flowModules: FlowModule[]): Promise<FlowModuleState[]> {
|
|
return Promise.all(flowModules.map(async (flowModule: FlowModule) => mapFlowModule(flowModule)))
|
|
}
|