(columns, inputParam)
| 322 | } |
| 323 | |
| 324 | const getDataGridColDef = (columns, inputParam) => { |
| 325 | const colDef = [] |
| 326 | for (const column of columns) { |
| 327 | const stateNode = reactFlowInstance ? reactFlowInstance.getNodes().find((node) => node.data.name === 'seqState') : null |
| 328 | if (column.type === 'asyncSingleSelect' && column.loadMethod && column.loadMethod.includes('loadStateKeys')) { |
| 329 | if (stateNode) { |
| 330 | const tabParam = stateNode.data.inputParams.find((param) => param.tabIdentifier) |
| 331 | if (tabParam && tabParam.tabs.length > 0) { |
| 332 | const selectedTabIdentifier = tabParam.tabIdentifier |
| 333 | |
| 334 | const selectedTab = |
| 335 | stateNode.data.inputs[`${selectedTabIdentifier}_${stateNode.data.id}`] || |
| 336 | tabParam.default || |
| 337 | tabParam.tabs[0].name |
| 338 | |
| 339 | const datagridValues = stateNode.data.inputs[selectedTab] |
| 340 | if (datagridValues) { |
| 341 | try { |
| 342 | const parsedDatagridValues = JSON.parse(datagridValues) |
| 343 | const keys = Array.isArray(parsedDatagridValues) |
| 344 | ? parsedDatagridValues.map((item) => item.key) |
| 345 | : Object.keys(parsedDatagridValues) |
| 346 | colDef.push({ |
| 347 | ...column, |
| 348 | field: column.field, |
| 349 | headerName: column.headerName, |
| 350 | type: 'singleSelect', |
| 351 | editable: true, |
| 352 | valueOptions: keys |
| 353 | }) |
| 354 | } catch (error) { |
| 355 | console.error('Error parsing stateMemory', error) |
| 356 | } |
| 357 | } |
| 358 | } |
| 359 | } else { |
| 360 | colDef.push({ |
| 361 | ...column, |
| 362 | field: column.field, |
| 363 | headerName: column.headerName, |
| 364 | type: 'singleSelect', |
| 365 | editable: true, |
| 366 | valueOptions: [] |
| 367 | }) |
| 368 | } |
| 369 | } else if (column.type === 'freeSolo') { |
| 370 | const preLoadOptions = [] |
| 371 | if (column.loadMethod && column.loadMethod.includes('getPreviousMessages')) { |
| 372 | const nodes = getAvailableNodesForVariable( |
| 373 | reactFlowInstance?.getNodes() || [], |
| 374 | reactFlowInstance?.getEdges() || [], |
| 375 | data.id, |
| 376 | inputParam.id |
| 377 | ) |
| 378 | for (const node of nodes) { |
| 379 | preLoadOptions.push({ |
| 380 | value: `$${node.id}`, |
| 381 | label: `Output from ${node.data.id}` |
no test coverage detected