Skip to content

Commit 1ed746b

Browse files
fix(paste): single instance trigger notification correction (#2653)
1 parent bf5d0a5 commit 1ed746b

File tree

1 file changed

+16
-15
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]

1 file changed

+16
-15
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -622,23 +622,24 @@ const WorkflowContent = React.memo(() => {
622622
const pasteData = preparePasteData(pasteOffset)
623623
if (pasteData) {
624624
const pastedBlocks = Object.values(pasteData.blocks)
625-
const hasTriggerInPaste = pastedBlocks.some((block) =>
626-
TriggerUtils.isAnyTriggerType(block.type)
627-
)
628-
if (hasTriggerInPaste) {
629-
const existingTrigger = Object.values(blocks).find((block) =>
630-
TriggerUtils.isAnyTriggerType(block.type)
631-
)
632-
if (existingTrigger) {
633-
addNotification({
634-
level: 'error',
635-
message:
636-
'A workflow can only have one trigger block. Please remove the existing one before pasting.',
637-
workflowId: activeWorkflowId || undefined,
638-
})
639-
return
625+
for (const block of pastedBlocks) {
626+
if (TriggerUtils.isAnyTriggerType(block.type)) {
627+
const issue = TriggerUtils.getTriggerAdditionIssue(blocks, block.type)
628+
if (issue) {
629+
const message =
630+
issue.issue === 'legacy'
631+
? 'Cannot paste trigger blocks when a legacy Start block exists.'
632+
: `A workflow can only have one ${issue.triggerName} trigger block. Please remove the existing one before pasting.`
633+
addNotification({
634+
level: 'error',
635+
message,
636+
workflowId: activeWorkflowId || undefined,
637+
})
638+
return
639+
}
640640
}
641641
}
642+
642643
collaborativeBatchAddBlocks(
643644
pastedBlocks,
644645
pasteData.edges,

0 commit comments

Comments
 (0)