fix: add worker, create cluster

This commit is contained in:
jialin
2025-12-17 14:59:07 +08:00
parent 5e48d75ead
commit bd6f4b3f76
14 changed files with 234 additions and 103 deletions
@@ -4,29 +4,34 @@ import YamlEditor from '@/pages/_components/yaml-editor';
import { useIntl } from '@umijs/max';
import { Form } from 'antd';
import React, { forwardRef, useImperativeHandle } from 'react';
import { ProviderType, ProviderValueMap } from '../config';
import { ClusterFormData as FormData } from '../config/types';
import schema from '../config/worker-config.json';
import yamlTemplate from '../config/yaml-template';
const ClusterAdvanceConfig: React.FC<{ action: PageActionType; ref?: any }> =
forwardRef(({ action }, ref) => {
const [form] = Form.useForm();
const intl = useIntl();
const editorRef = React.useRef<any>(null);
const [fileContent, setFileContent] = React.useState<string>('');
const ClusterAdvanceConfig: React.FC<{
action: PageActionType;
provider: ProviderType;
ref?: any;
}> = forwardRef(({ action, provider }, ref) => {
const [form] = Form.useForm();
const intl = useIntl();
const editorRef = React.useRef<any>(null);
const [fileContent, setFileContent] = React.useState<string>(yamlTemplate);
useImperativeHandle(ref, () => ({
getYamlValue: () => {
return editorRef.current?.getValue();
},
setYamlValue: (values: any) => {
console.log('setYamlValue:', values, editorRef.current);
editorRef.current?.setValue(values);
}
}));
useImperativeHandle(ref, () => ({
getYamlValue: () => {
return editorRef.current?.getValue();
},
setYamlValue: (values: any) => {
console.log('setYamlValue:', values, editorRef.current);
editorRef.current?.setValue(values);
}
}));
return (
<>
return (
<>
{provider !== ProviderValueMap.DigitalOcean && (
<Form.Item<FormData>
name="server_url"
rules={[
@@ -42,34 +47,31 @@ const ClusterAdvanceConfig: React.FC<{ action: PageActionType; ref?: any }> =
trim={true}
></SealInput.Input>
</Form.Item>
<Form.Item<FormData>
hidden
name="worker_config"
rules={[
{
required: false,
message: ''
}
]}
>
<SealInput.TextArea
required={false}
trim={false}
></SealInput.TextArea>
</Form.Item>
<YamlEditor
ref={editorRef}
title={`${intl.formatMessage({ id: 'clusters.create.workerConfig' })} YAML`}
value={fileContent}
height={300}
onUpload={(content) => {
setFileContent(content);
}}
schema={schema}
placeholder={yamlTemplate}
></YamlEditor>
</>
);
});
)}
<Form.Item<FormData>
hidden
name="worker_config"
rules={[
{
required: false,
message: ''
}
]}
>
<SealInput.TextArea required={false} trim={false}></SealInput.TextArea>
</Form.Item>
<YamlEditor
ref={editorRef}
title={`${intl.formatMessage({ id: 'clusters.create.workerConfig' })} YAML`}
value={fileContent}
height={300}
onUpload={(content) => {
setFileContent(content);
}}
schema={schema}
></YamlEditor>
</>
);
});
export default ClusterAdvanceConfig;