Bugfix/Enhance input configuration merging logic in replaceInputsWithConfig
Improve the handling of input configurations by merging existing values with overrides instead of complete replacement. This includes support for merging objects and parsing JSON strings when necessary.
This commit is contained in:
parent
c78b5326b6
commit
408da947f6
|
|
@ -1149,7 +1149,33 @@ export const replaceInputsWithConfig = (
|
||||||
if (nodeIds.includes(flowNodeData.id)) {
|
if (nodeIds.includes(flowNodeData.id)) {
|
||||||
// Check if this parameter is enabled
|
// Check if this parameter is enabled
|
||||||
if (isParameterEnabled(flowNodeData.label, config)) {
|
if (isParameterEnabled(flowNodeData.label, config)) {
|
||||||
inputsObj[config] = overrideConfig[config][flowNodeData.id]
|
const existingValue = inputsObj[config]
|
||||||
|
const overrideValue = overrideConfig[config][flowNodeData.id]
|
||||||
|
|
||||||
|
// Merge objects instead of completely overriding
|
||||||
|
if (
|
||||||
|
typeof existingValue === 'object' &&
|
||||||
|
typeof overrideValue === 'object' &&
|
||||||
|
!Array.isArray(existingValue) &&
|
||||||
|
!Array.isArray(overrideValue) &&
|
||||||
|
existingValue !== null &&
|
||||||
|
overrideValue !== null
|
||||||
|
) {
|
||||||
|
inputsObj[config] = Object.assign({}, existingValue, overrideValue)
|
||||||
|
} else if (typeof existingValue === 'string' && existingValue.startsWith('{') && existingValue.endsWith('}')) {
|
||||||
|
try {
|
||||||
|
const parsedExisting = JSON.parse(existingValue)
|
||||||
|
if (typeof overrideValue === 'object' && !Array.isArray(overrideValue)) {
|
||||||
|
inputsObj[config] = Object.assign({}, parsedExisting, overrideValue)
|
||||||
|
} else {
|
||||||
|
inputsObj[config] = overrideValue
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
inputsObj[config] = overrideValue
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
inputsObj[config] = overrideValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
} else if (nodeIds.some((nodeId) => nodeId.includes(flowNodeData.name))) {
|
} else if (nodeIds.some((nodeId) => nodeId.includes(flowNodeData.name))) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue