fix(paste): single instance trigger notification correction (#2653)

This commit is contained in:
Vikhyath Mondreti
2025-12-31 03:34:14 -08:00
committed by GitHub
parent bf5d0a5573
commit 1ed746bacf

View File

@@ -622,23 +622,24 @@ const WorkflowContent = React.memo(() => {
const pasteData = preparePasteData(pasteOffset)
if (pasteData) {
const pastedBlocks = Object.values(pasteData.blocks)
const hasTriggerInPaste = pastedBlocks.some((block) =>
TriggerUtils.isAnyTriggerType(block.type)
)
if (hasTriggerInPaste) {
const existingTrigger = Object.values(blocks).find((block) =>
TriggerUtils.isAnyTriggerType(block.type)
)
if (existingTrigger) {
addNotification({
level: 'error',
message:
'A workflow can only have one trigger block. Please remove the existing one before pasting.',
workflowId: activeWorkflowId || undefined,
})
return
for (const block of pastedBlocks) {
if (TriggerUtils.isAnyTriggerType(block.type)) {
const issue = TriggerUtils.getTriggerAdditionIssue(blocks, block.type)
if (issue) {
const message =
issue.issue === 'legacy'
? 'Cannot paste trigger blocks when a legacy Start block exists.'
: `A workflow can only have one ${issue.triggerName} trigger block. Please remove the existing one before pasting.`
addNotification({
level: 'error',
message,
workflowId: activeWorkflowId || undefined,
})
return
}
}
}
collaborativeBatchAddBlocks(
pastedBlocks,
pasteData.edges,