From d864eaa9ea73b7f13e44f17d2ca19430f37c900a Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Thu, 26 Oct 2023 16:05:15 +0100 Subject: [PATCH] pr comments --- .../builderStore/store/automation/index.js | 2 +- .../FlowChart/FlowChart.svelte | 7 +--- .../FlowChart/FlowItemHeader.svelte | 37 +++++++++---------- .../SetupPanel/AutomationBlockSetup.svelte | 5 ++- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/packages/builder/src/builderStore/store/automation/index.js b/packages/builder/src/builderStore/store/automation/index.js index dd28d14461..66715faf3a 100644 --- a/packages/builder/src/builderStore/store/automation/index.js +++ b/packages/builder/src/builderStore/store/automation/index.js @@ -229,7 +229,7 @@ const automationActions = store => ({ } newAutomation.definition.stepNames = { ...newAutomation.definition.stepNames, - [stepId]: name, + [stepId]: name.trim(), } await store.actions.save(newAutomation) diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte index 784cdf2357..d45fe96ad7 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte @@ -15,7 +15,6 @@ let testDataModal let confirmDeleteDialog let scrolling = false - let hasScrolled = false $: blocks = getBlocks(automation) const getBlocks = automation => { @@ -36,13 +35,11 @@ } const handleScroll = e => { - if (e.target.scrollTop >= 30 && !hasScrolled) { + if (e.target.scrollTop >= 30) { scrolling = true - hasScrolled = true - } else if (e.target.scrollTop < 30 && hasScrolled) { + } else if (e.target.scrollTop) { // Set scrolling back to false if scrolled back to less than 100px scrolling = false - hasScrolled = false } } diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte index 8b907ae0f6..868e6eb1bd 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte @@ -31,7 +31,7 @@ )?.[0] } } - $: loopBlock = $selectedAutomation?.definition.steps.find( + $: loopBlock = $selectedAutomation.definition.steps.find( x => x.blockToLoop === block?.id ) @@ -57,12 +57,10 @@ } const getAutomationNameError = name => { - if (name !== block.name && block.name.includes(name)) { - if (name?.length > 0) { - let invalidRoleName = !validRegex.test(name) - if (invalidRoleName) { - return "Please enter a role name consisting of only alphanumeric symbols and underscores" - } + 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 null } @@ -73,14 +71,14 @@ } const saveName = async () => { - if (automationNameError) { + if (automationNameError || block.name === automationName) { return } if (automationName.length === 0) { - automationStore.actions.deleteAutomationName(block.id) + await automationStore.actions.deleteAutomationName(block.id) } else { - automationStore.actions.saveAutomationName(block.id, automationName) + await automationStore.actions.saveAutomationName(block.id, automationName) } } @@ -114,7 +112,9 @@ {#if isTrigger} Trigger {:else} - Step {idx} +
+ Step {idx} +
{/if} { - automationNameError = getAutomationNameError(e.target.value) - automationName = e.target.value - if (!automationNameError) { - automationNameError = false // Reset the error when input is valid - } + automationName = e.target.value.trim() }} on:click={startTyping} on:blur={async () => { typing = false if (automationNameError) { automationName = stepNames[block.id] - automationNameError = null } else { await saveName() } @@ -225,7 +220,7 @@ font-family: var(--font-sans); color: var(--ink); background-color: transparent; - border: none; + border: 1px solid transparent; font-size: var(--spectrum-alias-font-size-default); width: 260px; box-sizing: border-box; @@ -246,11 +241,13 @@ } .typing { - border: 0.5px solid var(--spectrum-global-color-static-blue-500); + border: 1px solid var(--spectrum-global-color-static-blue-500); + border-radius: 4px 4px 4px 4px; } .typing-error { - border: 0.5px solid var(--spectrum-global-color-static-red-500); + border: 1px solid var(--spectrum-global-color-static-red-500); + border-radius: 4px 4px 4px 4px; } .error-icon :global(.spectrum-Icon) { diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index 4a0f1094ad..de3a66e216 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -204,7 +204,7 @@ const runtime = idx === 0 ? `trigger.${name}` : runtimeName let bindingName = - automation.stepNames[allSteps[bindingRank - loopBlockCount].id] + automation.stepNames?.[allSteps[bindingRank - loopBlockCount].id] let categoryName if (idx === 0) { @@ -287,7 +287,8 @@ return ( value.customType !== "row" && value.customType !== "code" && - value.customType !== "queryParams" + value.customType !== "queryParams" && + value.customType !== "cron" ) }