feat: add intances list

This commit is contained in:
jialin
2026-05-11 19:49:21 +08:00
committed by jialin
parent 75d7eff63b
commit 3ae49dc826
18 changed files with 692 additions and 6 deletions
@@ -0,0 +1,66 @@
import { PageAction } from '@/config';
import { PageActionType } from '@/config/types';
import { Form } from 'antd';
import { forwardRef, useEffect, useImperativeHandle } from 'react';
import { FormData, ListItem } from '../config/types';
import Basic from './basic';
interface InstanceFormProps {
ref?: any;
open: boolean;
action: PageActionType;
currentData?: ListItem | null;
onFinish: (values: FormData) => Promise<void>;
}
const GPUServiceInstanceForm: React.FC<InstanceFormProps> = forwardRef(
(props, ref) => {
const { action, currentData, open, onFinish } = props;
const [form] = Form.useForm<FormData>();
useEffect(() => {
if (!open) {
form.resetFields();
return;
}
if (action === PageAction.EDIT && currentData) {
form.setFieldsValue({
name: currentData.name,
description: currentData.description,
image: currentData.image,
gpu_count: currentData.gpu_count,
replicas: currentData.replicas
});
return;
}
form.setFieldsValue({
gpu_count: 1,
replicas: 1
});
}, [action, currentData, form, open]);
useImperativeHandle(ref, () => ({
submit: () => {
form.submit();
},
resetFields: () => {
form.resetFields();
}
}));
return (
<Form
name="gpuServiceInstanceForm"
form={form}
onFinish={onFinish}
preserve={false}
>
<Basic />
</Form>
);
}
);
export default GPUServiceInstanceForm;