fix bug in adding trigger

This commit is contained in:
Peter Clement 2023-10-26 11:27:20 +01:00
parent 3eba7990f9
commit 8203139c69
1 changed files with 8 additions and 7 deletions

View File

@ -20,7 +20,7 @@
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
$: stepNames = $selectedAutomation.definition.stepNames $: stepNames = $selectedAutomation.definition.stepNames
$: automationName = stepNames[block.id] || block.name || "" $: automationName = stepNames?.[block.id] || block?.name || ""
$: automationNameError = getAutomationNameError(automationName) $: automationNameError = getAutomationNameError(automationName)
$: status = updateStatus(testResult, isTrigger) $: status = updateStatus(testResult, isTrigger)
$: isTrigger = isTrigger || block.type === "TRIGGER" $: isTrigger = isTrigger || block.type === "TRIGGER"
@ -32,7 +32,7 @@
} }
} }
$: loopBlock = $selectedAutomation?.definition.steps.find( $: loopBlock = $selectedAutomation?.definition.steps.find(
x => x.blockToLoop === block.id x => x.blockToLoop === block?.id
) )
async function onSelect(block) { async function onSelect(block) {
@ -59,13 +59,14 @@
const getAutomationNameError = name => { const getAutomationNameError = name => {
if (name !== block.name && block.name.includes(name)) { if (name !== block.name && block.name.includes(name)) {
if (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 }
}}
const startTyping = async () => { const startTyping = async () => {
typing = true typing = true