mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
improvement(trigger-subflow): reuse helper code (#1885)
This commit is contained in:
committed by
GitHub
parent
37fd21e0aa
commit
ec70f6fafe
@@ -3,6 +3,7 @@ import type { Edge } from 'reactflow'
|
||||
import { useSession } from '@/lib/auth-client'
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import { getBlockOutputs } from '@/lib/workflows/block-outputs'
|
||||
import { TriggerUtils } from '@/lib/workflows/triggers'
|
||||
import { getBlock } from '@/blocks'
|
||||
import { useSocket } from '@/contexts/socket-context'
|
||||
import { useUndoRedo } from '@/hooks/use-undo-redo'
|
||||
@@ -972,20 +973,17 @@ export function useCollaborativeWorkflow() {
|
||||
const newTriggerMode = !currentBlock.triggerMode
|
||||
|
||||
// When enabling trigger mode, check if block is inside a subflow
|
||||
if (newTriggerMode && currentBlock.data?.parentId) {
|
||||
const parent = workflowStore.blocks[currentBlock.data.parentId]
|
||||
if (parent && (parent.type === 'loop' || parent.type === 'parallel')) {
|
||||
// Dispatch custom event to show warning modal
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('show-trigger-warning', {
|
||||
detail: {
|
||||
type: 'trigger_in_subflow',
|
||||
triggerName: 'trigger',
|
||||
},
|
||||
})
|
||||
)
|
||||
return
|
||||
}
|
||||
if (newTriggerMode && TriggerUtils.isBlockInSubflow(id, workflowStore.blocks)) {
|
||||
// Dispatch custom event to show warning modal
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('show-trigger-warning', {
|
||||
detail: {
|
||||
type: 'trigger_in_subflow',
|
||||
triggerName: 'trigger',
|
||||
},
|
||||
})
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
executeQueuedOperation(
|
||||
|
||||
@@ -3,6 +3,7 @@ import { create } from 'zustand'
|
||||
import { devtools } from 'zustand/middleware'
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import { getBlockOutputs } from '@/lib/workflows/block-outputs'
|
||||
import { TriggerUtils } from '@/lib/workflows/triggers'
|
||||
import { getBlock } from '@/blocks'
|
||||
import type { SubBlockConfig } from '@/blocks/types'
|
||||
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
|
||||
@@ -1052,17 +1053,12 @@ export const useWorkflowStore = create<WorkflowStore>()(
|
||||
const newTriggerMode = !block.triggerMode
|
||||
|
||||
// When switching TO trigger mode, check if block is inside a subflow
|
||||
if (newTriggerMode && block.data?.parentId) {
|
||||
const parent = get().blocks[block.data.parentId]
|
||||
if (parent && (parent.type === 'loop' || parent.type === 'parallel')) {
|
||||
logger.warn('Cannot enable trigger mode for block inside loop or parallel subflow', {
|
||||
blockId: id,
|
||||
blockType: block.type,
|
||||
parentId: block.data.parentId,
|
||||
parentType: parent.type,
|
||||
})
|
||||
return
|
||||
}
|
||||
if (newTriggerMode && TriggerUtils.isBlockInSubflow(id, get().blocks)) {
|
||||
logger.warn('Cannot enable trigger mode for block inside loop or parallel subflow', {
|
||||
blockId: id,
|
||||
blockType: block.type,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// When switching TO trigger mode, remove all incoming connections
|
||||
|
||||
Reference in New Issue
Block a user