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

Function EditNodeDialog

packages/ui/src/views/agentflowsv2/EditNodeDialog.jsx:14–271  ·  view source on GitHub ↗
({ show, dialogProps, onCancel })

Source from the content-addressed store, hash-verified

12import { applyVisibleInputDefaults, showHideInputParams } from '@/utils/genericHelper'
13
14const EditNodeDialog = ({ show, dialogProps, onCancel }) => {
15 const portalElement = document.getElementById('portal')
16 const dispatch = useDispatch()
17 const theme = useTheme()
18 const customization = useSelector((state) => state.customization)
19 const nodeNameRef = useRef()
20 const { reactFlowInstance } = useContext(flowContext)
21 const updateNodeInternals = useUpdateNodeInternals()
22
23 const [inputParams, setInputParams] = useState([])
24 const [data, setData] = useState({})
25 const [isEditingNodeName, setEditingNodeName] = useState(null)
26 const [nodeName, setNodeName] = useState('')
27
28 const onNodeLabelChange = () => {
29 reactFlowInstance.setNodes((nds) =>
30 nds.map((node) => {
31 if (node.id === data.id) {
32 node.data = {
33 ...node.data,
34 label: nodeNameRef.current.value
35 }
36 setData(node.data)
37 }
38 return node
39 })
40 )
41 updateNodeInternals(data.id)
42 }
43
44 const onCustomDataChange = ({ nodeId, inputParam, newValue }) => {
45 reactFlowInstance.setNodes((nds) =>
46 nds.map((node) => {
47 if (node.id === nodeId) {
48 const updatedInputs = applyVisibleInputDefaults(node.data.inputParams, {
49 ...node.data.inputs,
50 [inputParam.name]: newValue
51 })
52
53 const updatedInputParams = showHideInputParams({
54 ...node.data,
55 inputs: updatedInputs
56 })
57
58 // Remove inputs with display set to false
59 Object.keys(updatedInputs).forEach((key) => {
60 const input = updatedInputParams.find((param) => param.name === key)
61 if (input && input.display === false) {
62 delete updatedInputs[key]
63 }
64 })
65
66 node.data = {
67 ...node.data,
68 inputParams: updatedInputParams,
69 inputs: updatedInputs
70 }
71

Callers

nothing calls this directly

Calls 2

useUpdateNodeInternalsFunction · 0.90
onNodeLabelChangeFunction · 0.70

Tested by

no test coverage detected