From 7d4aa252449dad10f75247125a49b542820cb281 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Fri, 20 Sep 2024 11:53:48 +0100 Subject: [PATCH 1/6] fix issue with loop bindings showing for non loop steps --- .../automation/SetupPanel/AutomationBlockSetup.svelte | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index af67ae8d22..927b8588b3 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -752,13 +752,21 @@ : allSteps[idx].icon if (wasLoopBlock) { - loopBlockCount++ schema = cloneDeep(allSteps[idx - 1]?.schema?.outputs?.properties) } Object.entries(schema).forEach(([name, value]) => { addBinding(name, value, icon, idx, isLoopBlock, bindingName) }) } + + if ( + allSteps[blockIdx - 1]?.stepId !== ActionStepID.LOOP && + allSteps + .slice(0, blockIdx) + .some(step => step.stepId === ActionStepID.LOOP) + ) { + bindings = bindings.filter(x => !x.readableBinding.includes("loop")) + } return bindings } From c083fe3bd7fa99d52a26201e65f0b81ae254e498 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 23 Sep 2024 14:43:46 +0100 Subject: [PATCH 2/6] fix issue with js bindings not using quotes --- .../automation/SetupPanel/AutomationBlockSetup.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index 927b8588b3..aceb980786 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -643,8 +643,8 @@ runtimeName = `loop.${name}` } else if (block.name.startsWith("JS")) { runtimeName = hasUserDefinedName - ? `stepsByName[${bindingName}].${name}` - : `steps[${idx - loopBlockCount}].${name}` + ? `stepsByName["${bindingName}"].${name}` + : `steps["${idx - loopBlockCount}"].${name}` } else { runtimeName = hasUserDefinedName ? `stepsByName.${bindingName}.${name}` From 189caa6235b14404f0ccff4a66797ad1bc7497aa Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 23 Sep 2024 14:59:41 +0100 Subject: [PATCH 3/6] fix issue where you could have multiple steps with the same name --- .../FlowChart/FlowItemHeader.svelte | 61 +++++++++++-------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte index 5533572511..52f3f49511 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte @@ -16,9 +16,11 @@ export let enableNaming = true let validRegex = /^[A-Za-z0-9_\s]+$/ let typing = false + let editing = false const dispatch = createEventDispatcher() $: stepNames = $selectedAutomation?.definition.stepNames + $: allSteps = $selectedAutomation?.definition.steps || [] $: automationName = stepNames?.[block.id] || block?.name || "" $: automationNameError = getAutomationNameError(automationName) $: status = updateStatus(testResult) @@ -56,9 +58,17 @@ } } const getAutomationNameError = name => { - if (stepNames) { + if (stepNames && editing) { + // Check against stepNames for (const [key, value] of Object.entries(stepNames)) { - if (name === value && key !== block.id) { + if (name !== block.name && name === value && key !== block.id) { + return "This name already exists, please enter a unique name" + } + } + + // Check against other block names + for (const step of allSteps) { + if (step.id !== block.id && name === step.name) { return "This name already exists, please enter a unique name" } } @@ -67,11 +77,11 @@ if (name !== block.name && name?.length > 0) { let invalidRoleName = !validRegex.test(name) if (invalidRoleName) { - return "Please enter a role name consisting of only alphanumeric symbols and underscores" + return "Please enter a name consisting of only alphanumeric symbols and underscores" } - - return null } + + return null } const startTyping = async () => { @@ -89,13 +99,28 @@ await automationStore.actions.saveAutomationName(block.id, automationName) } } + + const startEditing = () => { + editing = true + typing = true + } + + const stopEditing = async () => { + editing = false + typing = false + if (automationNameError) { + automationName = stepNames[block.id] || block?.name + } else { + await saveName() + } + }
dispatch("toggle")} > @@ -132,7 +157,7 @@ { e.stopPropagation() - startTyping() + startEditing() }} on:keydown={async e => { if (e.key === "Enter") { - typing = false - if (automationNameError) { - automationName = stepNames[block.id] || block?.name - } else { - await saveName() - } - } - }} - on:blur={async () => { - typing = false - if (automationNameError) { - automationName = stepNames[block.id] || block?.name - } else { - await saveName() + await stopEditing() } }} + on:blur={stopEditing} /> {:else}
@@ -222,7 +235,7 @@ /> {/if}
- {#if automationNameError} + {#if automationNameError && editing}
From 335240718c94ee4e433d4f2c1706f17c86f6524b Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 23 Sep 2024 15:02:37 +0100 Subject: [PATCH 4/6] tidy up --- .../AutomationBuilder/FlowChart/FlowItemHeader.svelte | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte index 52f3f49511..f85496ec81 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte @@ -59,14 +59,12 @@ } const getAutomationNameError = name => { if (stepNames && editing) { - // Check against stepNames for (const [key, value] of Object.entries(stepNames)) { if (name !== block.name && name === value && key !== block.id) { return "This name already exists, please enter a unique name" } } - // Check against other block names for (const step of allSteps) { if (step.id !== block.id && name === step.name) { return "This name already exists, please enter a unique name" From 63651b21e6f43f827ee6db38b5b90c47b4fa9f15 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 23 Sep 2024 15:17:44 +0100 Subject: [PATCH 5/6] lint --- .../AutomationBuilder/FlowChart/FlowItemHeader.svelte | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte index f85496ec81..361164cfe5 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte @@ -82,10 +82,6 @@ return null } - const startTyping = async () => { - typing = true - } - const saveName = async () => { if (automationNameError || block.name === automationName) { return From 89354f640bf30534924ddb1814f2fb4eb681b120 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 23 Sep 2024 15:29:27 +0100 Subject: [PATCH 6/6] dupe string --- .../AutomationBuilder/FlowChart/FlowItemHeader.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte index 361164cfe5..a98c597142 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte @@ -58,16 +58,18 @@ } } const getAutomationNameError = name => { + const duplicateError = + "This name already exists, please enter a unique name" if (stepNames && editing) { for (const [key, value] of Object.entries(stepNames)) { if (name !== block.name && name === value && key !== block.id) { - return "This name already exists, please enter a unique name" + return duplicateError } } for (const step of allSteps) { if (step.id !== block.id && name === step.name) { - return "This name already exists, please enter a unique name" + return duplicateError } } }