pr comments

This commit is contained in:
Peter Clement 2023-10-26 16:05:15 +01:00
parent 73a7b8eb50
commit d864eaa9ea
4 changed files with 23 additions and 28 deletions

View File

@ -229,7 +229,7 @@ const automationActions = store => ({
} }
newAutomation.definition.stepNames = { newAutomation.definition.stepNames = {
...newAutomation.definition.stepNames, ...newAutomation.definition.stepNames,
[stepId]: name, [stepId]: name.trim(),
} }
await store.actions.save(newAutomation) await store.actions.save(newAutomation)

View File

@ -15,7 +15,6 @@
let testDataModal let testDataModal
let confirmDeleteDialog let confirmDeleteDialog
let scrolling = false let scrolling = false
let hasScrolled = false
$: blocks = getBlocks(automation) $: blocks = getBlocks(automation)
const getBlocks = automation => { const getBlocks = automation => {
@ -36,13 +35,11 @@
} }
const handleScroll = e => { const handleScroll = e => {
if (e.target.scrollTop >= 30 && !hasScrolled) { if (e.target.scrollTop >= 30) {
scrolling = true scrolling = true
hasScrolled = true } else if (e.target.scrollTop) {
} else if (e.target.scrollTop < 30 && hasScrolled) {
// Set scrolling back to false if scrolled back to less than 100px // Set scrolling back to false if scrolled back to less than 100px
scrolling = false scrolling = false
hasScrolled = false
} }
} }
</script> </script>

View File

@ -31,7 +31,7 @@
)?.[0] )?.[0]
} }
} }
$: loopBlock = $selectedAutomation?.definition.steps.find( $: loopBlock = $selectedAutomation.definition.steps.find(
x => x.blockToLoop === block?.id x => x.blockToLoop === block?.id
) )
@ -57,12 +57,10 @@
} }
const getAutomationNameError = name => { const getAutomationNameError = name => {
if (name !== block.name && block.name.includes(name)) { if (name !== block.name && name?.length > 0) {
if (name?.length > 0) { let invalidRoleName = !validRegex.test(name)
let invalidRoleName = !validRegex.test(name) if (invalidRoleName) {
if (invalidRoleName) { return "Please enter a role name consisting of only alphanumeric symbols and underscores"
return "Please enter a role name consisting of only alphanumeric symbols and underscores"
}
} }
return null return null
} }
@ -73,14 +71,14 @@
} }
const saveName = async () => { const saveName = async () => {
if (automationNameError) { if (automationNameError || block.name === automationName) {
return return
} }
if (automationName.length === 0) { if (automationName.length === 0) {
automationStore.actions.deleteAutomationName(block.id) await automationStore.actions.deleteAutomationName(block.id)
} else { } else {
automationStore.actions.saveAutomationName(block.id, automationName) await automationStore.actions.saveAutomationName(block.id, automationName)
} }
} }
</script> </script>
@ -114,7 +112,9 @@
{#if isTrigger} {#if isTrigger}
<Body size="XS"><b>Trigger</b></Body> <Body size="XS"><b>Trigger</b></Body>
{:else} {:else}
<Body size="XS"><b>Step {idx}</b></Body> <div style="margin-left: 2px;">
<Body size="XS"><b>Step {idx}</b></Body>
</div>
{/if} {/if}
<input <input
placeholder="Enter some text" placeholder="Enter some text"
@ -122,18 +122,13 @@
autocomplete="off" autocomplete="off"
value={automationName} value={automationName}
on:input={e => { on:input={e => {
automationNameError = getAutomationNameError(e.target.value) automationName = e.target.value.trim()
automationName = e.target.value
if (!automationNameError) {
automationNameError = false // Reset the error when input is valid
}
}} }}
on:click={startTyping} on:click={startTyping}
on:blur={async () => { on:blur={async () => {
typing = false typing = false
if (automationNameError) { if (automationNameError) {
automationName = stepNames[block.id] automationName = stepNames[block.id]
automationNameError = null
} else { } else {
await saveName() await saveName()
} }
@ -225,7 +220,7 @@
font-family: var(--font-sans); font-family: var(--font-sans);
color: var(--ink); color: var(--ink);
background-color: transparent; background-color: transparent;
border: none; border: 1px solid transparent;
font-size: var(--spectrum-alias-font-size-default); font-size: var(--spectrum-alias-font-size-default);
width: 260px; width: 260px;
box-sizing: border-box; box-sizing: border-box;
@ -246,11 +241,13 @@
} }
.typing { .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 { .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) { .error-icon :global(.spectrum-Icon) {

View File

@ -204,7 +204,7 @@
const runtime = idx === 0 ? `trigger.${name}` : runtimeName const runtime = idx === 0 ? `trigger.${name}` : runtimeName
let bindingName = let bindingName =
automation.stepNames[allSteps[bindingRank - loopBlockCount].id] automation.stepNames?.[allSteps[bindingRank - loopBlockCount].id]
let categoryName let categoryName
if (idx === 0) { if (idx === 0) {
@ -287,7 +287,8 @@
return ( return (
value.customType !== "row" && value.customType !== "row" &&
value.customType !== "code" && value.customType !== "code" &&
value.customType !== "queryParams" value.customType !== "queryParams" &&
value.customType !== "cron"
) )
} }