MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / groupByNodeLabel

Function groupByNodeLabel

packages/ui/src/views/chatflows/APICodeDialog.jsx:188–230  ·  view source on GitHub ↗
(nodes)

Source from the content-addressed store, hash-verified

186 }
187
188 const groupByNodeLabel = (nodes) => {
189 const result = {}
190 const newNodeOverrides = {}
191 const seenNodes = new Set()
192
193 nodes.forEach((item) => {
194 const { node, nodeId, label, name, type } = item
195 seenNodes.add(node)
196
197 if (!result[node]) {
198 result[node] = {
199 nodeIds: [],
200 params: []
201 }
202 }
203
204 if (!newNodeOverrides[node]) {
205 // If overrideConfigStatus is true, copy existing config for this node
206 newNodeOverrides[node] = overrideConfigStatus ? [...(nodeOverrides[node] || [])] : []
207 }
208
209 if (!result[node].nodeIds.includes(nodeId)) result[node].nodeIds.push(nodeId)
210
211 const param = { label, name, type }
212
213 if (!result[node].params.some((existingParam) => JSON.stringify(existingParam) === JSON.stringify(param))) {
214 result[node].params.push(param)
215 const paramExists = newNodeOverrides[node].some(
216 (existingParam) => existingParam.label === label && existingParam.name === name && existingParam.type === type
217 )
218 if (!paramExists) {
219 newNodeOverrides[node].push({ ...param, enabled: false })
220 }
221 }
222 })
223
224 // Sort the nodeIds array
225 for (const node in result) {
226 result[node].nodeIds.sort()
227 }
228 setNodeConfig(result)
229 setNodeOverrides(newNodeOverrides)
230 }
231
232 const groupByVariableLabel = (variables) => {
233 const newVariables = []

Callers 1

APICodeDialogFunction · 0.70

Calls 2

stringifyMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected