mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-23 12:21:08 +00:00
feat: Add helper function to render control component in AddFlowVariableModal (#1974)
This commit is contained in:
commit
19b8d45db2
@ -126,6 +126,37 @@ export const AddFlowVariableModal: React.FC<Props> = ({ flowInfo }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Helper function to render the appropriate control component
|
||||||
|
const renderVariableValue = (type: string, index: number) => {
|
||||||
|
switch (type) {
|
||||||
|
case 'ref':
|
||||||
|
return (
|
||||||
|
<Cascader
|
||||||
|
placeholder='Select Value'
|
||||||
|
options={refVariableOptions}
|
||||||
|
loadData={loadData}
|
||||||
|
onChange={(value, selectedOptions) => onRefTypeValueChange(value, selectedOptions, index)}
|
||||||
|
changeOnSelect
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
case 'str':
|
||||||
|
return <Input placeholder='Parameter Value' />;
|
||||||
|
case 'int':
|
||||||
|
return <Input type='number' placeholder='Parameter Value' />;
|
||||||
|
case 'float':
|
||||||
|
return <Input type='number' step='0.01' placeholder='Parameter Value' />;
|
||||||
|
case 'bool':
|
||||||
|
return (
|
||||||
|
<Select placeholder='Select Value'>
|
||||||
|
<Option value='true'>True</Option>
|
||||||
|
<Option value='false'>False</Option>
|
||||||
|
</Select>
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return <Input placeholder='Parameter Value' />;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
@ -215,19 +246,7 @@ export const AddFlowVariableModal: React.FC<Props> = ({ flowInfo }) => {
|
|||||||
style={{ width: 320 }}
|
style={{ width: 320 }}
|
||||||
rules={[{ required: true, message: 'Missing parameter value' }]}
|
rules={[{ required: true, message: 'Missing parameter value' }]}
|
||||||
>
|
>
|
||||||
{controlTypes[index] === 'ref' ? (
|
{renderVariableValue(controlTypes[index], index)}
|
||||||
<Cascader
|
|
||||||
placeholder='Select Value'
|
|
||||||
options={refVariableOptions}
|
|
||||||
loadData={loadData}
|
|
||||||
onChange={(value, selectedOptions) => onRefTypeValueChange(value, selectedOptions, index)}
|
|
||||||
// displayRender={displayRender}
|
|
||||||
// dropdownRender={dropdownRender}
|
|
||||||
changeOnSelect
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<Input placeholder='Parameter Value' />
|
|
||||||
)}
|
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item {...restField} name={[name, 'description']} label='描述' style={{ width: 170 }}>
|
<Form.Item {...restField} name={[name, 'description']} label='描述' style={{ width: 170 }}>
|
||||||
|
Loading…
Reference in New Issue
Block a user