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

Function updateComponentData

packages/ui/src/views/agentflowsv2/ConfigInput.jsx:183–243  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

181
182 // Update selectedComponentNodeData with new input values
183 const updateComponentData = () => {
184 const updatedComponentData = cloneDeep(selectedComponentNodeData)
185
186 // Helper functions (same as in initial load)
187 const hasArrayConfig = () => {
188 return (
189 parentParamForArray &&
190 data.inputs[parentParamForArray.name] &&
191 Array.isArray(data.inputs[parentParamForArray.name]) &&
192 data.inputs[parentParamForArray.name][arrayIndex] &&
193 data.inputs[parentParamForArray.name][arrayIndex][`${inputParam.name}Config`]
194 )
195 }
196
197 const getCurrentInputValue = () => {
198 return hasArrayConfig() ? data.inputs[parentParamForArray.name][arrayIndex][inputParam.name] : data.inputs[inputParam.name]
199 }
200
201 const getConfigData = () => {
202 return hasArrayConfig()
203 ? data.inputs[parentParamForArray.name][arrayIndex][`${inputParam.name}Config`]
204 : data.inputs[`${inputParam.name}Config`]
205 }
206
207 // Update the main input value in component data
208 const currentValue = getCurrentInputValue()
209 if (currentValue !== undefined) {
210 updatedComponentData.inputs[inputParam.name] = currentValue
211 }
212
213 // If there's config data and it matches the current value, use it
214 if (hasArrayConfig() || data.inputs[`${inputParam.name}Config`]) {
215 const configData = getConfigData()
216 if (configData && configData[inputParam.name] === currentValue) {
217 // Config is still valid, merge it with current value
218 updatedComponentData.inputs = { ...configData, [inputParam.name]: currentValue }
219 } else if (hasMainValueChanged) {
220 // Main value changed but config doesn't match, reset to defaults with new value
221 const defaultInput = initializeDefaultNodeData(updatedComponentData.inputParams)
222 updatedComponentData.inputs = { ...defaultInput, [inputParam.name]: currentValue }
223 }
224 }
225
226 // Update input parameters visibility
227 updatedComponentData.inputParams = showHideInputParams({
228 ...updatedComponentData,
229 inputs: updatedComponentData.inputs
230 })
231
232 const credential = updatedComponentData.inputs.credential || updatedComponentData.inputs[FLOWISE_CREDENTIAL_ID]
233 updatedComponentData.credential = credential ? credential : undefined
234
235 setSelectedComponentNodeData(updatedComponentData)
236
237 // Update the tracked values
238 setLastProcessedInputs({
239 mainValue: currentInputValues.mainValue,
240 configValue: currentInputValues.configValue,

Callers 1

ConfigInputFunction · 0.85

Calls 5

showHideInputParamsFunction · 0.90
getCurrentInputValueFunction · 0.85
hasArrayConfigFunction · 0.85
getConfigDataFunction · 0.85

Tested by

no test coverage detected