()
| 126 | setLoading(true) |
| 127 | ;(async () => { |
| 128 | const fetchData = async () => { |
| 129 | let response = [] |
| 130 | if (credentialNames.length) { |
| 131 | response = await fetchCredentialList() |
| 132 | } else { |
| 133 | const body = { |
| 134 | name, |
| 135 | nodeData |
| 136 | } |
| 137 | if (reactFlowInstance) { |
| 138 | const previousNodes = getAvailableNodesForVariable( |
| 139 | reactFlowInstance.getNodes(), |
| 140 | reactFlowInstance.getEdges(), |
| 141 | nodeData.id, |
| 142 | `${nodeData.id}-input-${name}-${nodeData.inputParams.find((param) => param.name === name)?.type || ''}`, |
| 143 | true |
| 144 | ).map((node) => ({ id: node.id, name: node.data.name, label: node.data.label, inputs: node.data.inputs })) |
| 145 | |
| 146 | let currentNode = reactFlowInstance.getNodes().find((node) => node.id === nodeData.id) |
| 147 | if (currentNode) { |
| 148 | currentNode = { |
| 149 | id: currentNode.id, |
| 150 | name: currentNode.data.name, |
| 151 | label: currentNode.data.label, |
| 152 | inputs: currentNode.data.inputs |
| 153 | } |
| 154 | body.currentNode = currentNode |
| 155 | } |
| 156 | |
| 157 | body.previousNodes = previousNodes |
| 158 | } |
| 159 | |
| 160 | response = await fetchList(body) |
| 161 | } |
| 162 | for (let j = 0; j < response.length; j += 1) { |
| 163 | if (response[j].imageSrc) { |
| 164 | const imageSrc = `${baseURL}/api/v1/node-icon/${response[j].name}` |
| 165 | response[j].imageSrc = imageSrc |
| 166 | } |
| 167 | } |
| 168 | if (isCreateNewOption) setOptions([...response, ...addNewOption]) |
| 169 | else setOptions([...response]) |
| 170 | setLoading(false) |
| 171 | } |
| 172 | fetchData() |
| 173 | })() |
| 174 |
no test coverage detected