MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / onNodeDataChange

Function onNodeDataChange

packages/ui/src/store/context/ReactFlowContext.jsx:51–91  ·  view source on GitHub ↗
({ nodeId, inputParam, newValue })

Source from the content-addressed store, hash-verified

49 }
50
51 const onNodeDataChange = ({ nodeId, inputParam, newValue }) => {
52 const updatedNodes = reactFlowInstance.getNodes().map((node) => {
53 if (node.id === nodeId) {
54 const updatedInputs = { ...node.data.inputs }
55
56 updatedInputs[inputParam.name] = newValue
57
58 const updatedInputParams = showHideInputParams({
59 ...node.data,
60 inputs: updatedInputs
61 })
62
63 // Remove inputs with display set to false
64 Object.keys(updatedInputs).forEach((key) => {
65 const input = updatedInputParams.find((param) => param.name === key)
66 if (input && input.display === false) {
67 delete updatedInputs[key]
68 }
69 })
70
71 return {
72 ...node,
73 data: {
74 ...node.data,
75 inputParams: updatedInputParams,
76 inputs: updatedInputs
77 }
78 }
79 }
80 return node
81 })
82
83 // Check if any node's inputParams have changed before updating
84 const hasChanges = updatedNodes.some(
85 (node, index) => !isEqual(node.data.inputParams, reactFlowInstance.getNodes()[index].data.inputParams)
86 )
87
88 if (hasChanges) {
89 reactFlowInstance.setNodes(updatedNodes)
90 }
91 }
92
93 const deleteNode = (nodeid) => {
94 deleteConnectedInput(nodeid, 'node')

Callers 1

handleDataChangeFunction · 0.85

Calls 1

showHideInputParamsFunction · 0.90

Tested by

no test coverage detected