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