fix: failed to enable gpu instance while creating cluster
This commit is contained in:
@@ -81,10 +81,22 @@ const GpuInstanceOptionsForm: React.FC<{
|
|||||||
initialValue?: GpuInstanceOptions;
|
initialValue?: GpuInstanceOptions;
|
||||||
}> = ({ initialValue }) => {
|
}> = ({ initialValue }) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const form = Form.useFormInstance();
|
||||||
const [enabled, setEnabled] = useState<boolean>(!!initialValue);
|
const [enabled, setEnabled] = useState<boolean>(!!initialValue);
|
||||||
|
|
||||||
const handleToggle = (checked: boolean) => {
|
const handleToggle = (checked: boolean) => {
|
||||||
setEnabled(checked);
|
setEnabled(checked);
|
||||||
|
// The presence of `gpuInstanceOptions` on `k8s_options` is what signals
|
||||||
|
// "GPU instances enabled" to the backend. The toggle is the source of
|
||||||
|
// truth for that presence — when on, ensure the object exists (defaulting
|
||||||
|
// to {} so it survives even when the static address is left blank); when
|
||||||
|
// off, remove it entirely.
|
||||||
|
const path = ['k8s_options', 'gpuInstanceOptions'];
|
||||||
|
if (checked) {
|
||||||
|
form.setFieldValue(path, form.getFieldValue(path) ?? {});
|
||||||
|
} else {
|
||||||
|
form.setFieldValue(path, undefined);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user