feat: fill single run form variable with constant value first time

This commit is contained in:
Joel 2024-03-18 11:03:23 +08:00
parent 4daf93ef4f
commit b8ecfd859b
1 changed files with 12 additions and 1 deletions

View File

@ -153,6 +153,17 @@ const useConfig = (id: string, payload: ToolNodeType) => {
setRunInputData(value)
}
// fill single run form variable with constant value first time
const inputVarValuesWithConstantValue = () => {
const res = produce(inputVarValues, (draft) => {
inputs.tool_parameters.forEach(({ variable, variable_type, value }: any) => {
if (variable_type === VarType.static && (draft[variable] === undefined || draft[variable] === null))
draft[variable] = value
})
})
return res
}
const singleRunForms = (() => {
const formInputs: InputVar[] = []
toolInputVarSchema.forEach((item: any) => {
@ -165,7 +176,7 @@ const useConfig = (id: string, payload: ToolNodeType) => {
})
const forms: FormProps[] = [{
inputs: formInputs,
values: inputVarValues,
values: inputVarValuesWithConstantValue(),
onChange: setInputVarValues,
}]
return forms