MCPcopy
hub / github.com/FlowiseAI/Flowise / AgentflowCanvas

Function AgentflowCanvas

packages/ui/src/views/agentflowsv2/Canvas.jsx:69–829  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

67// ==============================|| CANVAS ||============================== //
68
69const AgentflowCanvas = () => {
70 const theme = useTheme()
71 const navigate = useNavigate()
72 const customization = useSelector((state) => state.customization)
73
74 const { state } = useLocation()
75 const templateFlowData = state ? state.templateFlowData : ''
76
77 const URLpath = document.location.pathname.toString().split('/')
78 const chatflowId =
79 URLpath[URLpath.length - 1] === 'canvas' || URLpath[URLpath.length - 1] === 'agentcanvas' ? '' : URLpath[URLpath.length - 1]
80 const canvasTitle = URLpath.includes('agentcanvas') ? 'Agent' : 'Chatflow'
81
82 const { confirm } = useConfirm()
83
84 const dispatch = useDispatch()
85 const canvas = useSelector((state) => state.canvas)
86 const [canvasDataStore, setCanvasDataStore] = useState(canvas)
87 const [chatflow, setChatflow] = useState(null)
88 const { reactFlowInstance, setReactFlowInstance } = useContext(flowContext)
89
90 // ==============================|| Snackbar ||============================== //
91
92 useNotifier()
93 const enqueueSnackbar = (...args) => dispatch(enqueueSnackbarAction(...args))
94 const closeSnackbar = (...args) => dispatch(closeSnackbarAction(...args))
95
96 // ==============================|| ReactFlow ||============================== //
97
98 const [nodes, setNodes, onNodesChange] = useNodesState()
99 const [edges, setEdges, onEdgesChange] = useEdgesState()
100
101 const isScheduleFlow = useMemo(() => {
102 if (!nodes || nodes.length === 0) return false
103 const startNode = nodes.find((n) => n.data?.name === 'startAgentflow')
104 return startNode?.data?.inputs?.startInputType === 'scheduleInput'
105 }, [nodes])
106
107 const isWebhookFlow = useMemo(() => {
108 if (!nodes || nodes.length === 0) return false
109 const startNode = nodes.find((n) => n.data?.name === 'startAgentflow')
110 return startNode?.data?.inputs?.startInputType === 'webhookTrigger'
111 }, [nodes])
112
113 const [selectedNode, setSelectedNode] = useState(null)
114 const [isSyncNodesButtonEnabled, setIsSyncNodesButtonEnabled] = useState(false)
115 const [editNodeDialogOpen, setEditNodeDialogOpen] = useState(false)
116 const [editNodeDialogProps, setEditNodeDialogProps] = useState({})
117 const [isSnappingEnabled, setIsSnappingEnabled] = useState(false)
118 const [isBackgroundEnabled, setIsBackgroundEnabled] = useState(true)
119
120 const reactFlowWrapper = useRef(null)
121
122 // ==============================|| Chatflow API ||============================== //
123
124 const getNodesApi = useApi(nodesApi.getAllNodes)
125 const createNewChatflowApi = useApi(chatflowsApi.createNewChatflow)
126 const updateChatflowApi = useApi(chatflowsApi.updateChatflow)

Callers

nothing calls this directly

Calls 15

useNodesStateFunction · 0.90
useEdgesStateFunction · 0.90
enqueueSnackbarFunction · 0.90
closeSnackbarFunction · 0.90
getUniqueNodeIdFunction · 0.90
getUniqueNodeLabelFunction · 0.90
initNodeFunction · 0.90
usePromptFunction · 0.90
useConfirmFunction · 0.85
useNotifierFunction · 0.85
setDirtyFunction · 0.70
errorFailedFunction · 0.70

Tested by

no test coverage detected