From fde979d2b83e86ea1e99ee87bec9dc241e61e52d Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Tue, 25 Oct 2022 19:29:55 +0200 Subject: [PATCH] fix(frontend): Fix legacy input transforms (#814) --- .../flows/content/FlowModuleComponent.svelte | 2 +- .../lib/components/flows/flowStateUtils.ts | 22 +++++++------------ .../flows/map/FlowErrorHandlerItem.svelte | 3 +-- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte b/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte index d2d2465d42..59f32e63db 100644 --- a/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte +++ b/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte @@ -71,7 +71,7 @@ if ( flowModule.value.type == 'script' || (flowModule.value.type == 'rawscript' && - JSON.stringify(flowModule.input_transforms) !== JSON.stringify(input_transforms)) + JSON.stringify(flowModule.value.input_transforms) !== JSON.stringify(input_transforms)) ) { flowModule.value.input_transforms = input_transforms hasChanged = true diff --git a/frontend/src/lib/components/flows/flowStateUtils.ts b/frontend/src/lib/components/flows/flowStateUtils.ts index 1cb5dd9ecc..e777adb132 100644 --- a/frontend/src/lib/components/flows/flowStateUtils.ts +++ b/frontend/src/lib/components/flows/flowStateUtils.ts @@ -60,9 +60,8 @@ export async function pickScript( ): Promise<[FlowModule, FlowModuleState]> { const flowModule: FlowModule = { id, - value: { type: 'script', path }, - summary, - input_transforms: {} + value: { type: 'script', path, input_transforms: {} }, + summary } return [flowModule, await loadFlowModuleState(flowModule)] @@ -78,8 +77,7 @@ export async function createInlineScriptModule( const flowModule: FlowModule = { id, - value: { type: 'rawscript', content: code, language }, - input_transforms: {} + value: { type: 'rawscript', content: code, language, input_transforms: {} } } return [flowModule, await loadFlowModuleState(flowModule)] @@ -93,8 +91,7 @@ export async function createLoop(id: string): Promise<[FlowModule, FlowModuleSta modules: [], iterator: { type: 'javascript', expr: 'previous_result' }, skip_failures: true - }, - input_transforms: {} + } } const flowModuleState = await loadFlowModuleState(loopFlowModule) @@ -109,7 +106,6 @@ export async function createBranches(id: string): Promise<[FlowModule, FlowModul branches: [], default: [] }, - input_transforms: {}, summary: '' } @@ -125,7 +121,6 @@ export async function createBranchAll(id: string): Promise<[FlowModule, FlowModu type: 'branchall', branches: [] }, - input_transforms: {}, summary: '' } @@ -155,17 +150,16 @@ async function createInlineScriptModuleFromPath(path: string, id: string): Promi type: 'rawscript', language: language as RawScript.language, content: content, - path - }, - input_transforms: {} + path, + input_transforms: {} + } } } export function emptyModule(): FlowModule { return { id: nextId(), - value: { type: 'identity' }, - input_transforms: {} + value: { type: 'identity' } } } diff --git a/frontend/src/lib/components/flows/map/FlowErrorHandlerItem.svelte b/frontend/src/lib/components/flows/map/FlowErrorHandlerItem.svelte index 5ababb0fee..d03b67ae37 100644 --- a/frontend/src/lib/components/flows/map/FlowErrorHandlerItem.svelte +++ b/frontend/src/lib/components/flows/map/FlowErrorHandlerItem.svelte @@ -25,8 +25,7 @@ $flowStateStore.failureModule = failureModule $flowStore.value.failure_module = { id: 'failure', - value: { type: 'identity' }, - input_transforms: {} + value: { type: 'identity' } } select('failure') }