|
| 1 | +import { intl } from '@/utils/intl'; |
| 2 | +import { Button, Col, Form, Input, Modal, Row, Space } from 'antd'; |
| 3 | +import React from 'react'; |
| 4 | + |
| 5 | +export interface ParametersModalProps { |
| 6 | + visible: boolean; |
| 7 | + onCancel: () => void; |
| 8 | + onSuccess: () => void; |
| 9 | + initialValues: any[]; |
| 10 | + name: string; |
| 11 | + namespace: string; |
| 12 | +} |
| 13 | + |
| 14 | +const ParametersModal: React.FC<ParametersModalProps> = ({ |
| 15 | + visible, |
| 16 | + onCancel, |
| 17 | + initialValues, |
| 18 | + // onSuccess, |
| 19 | + // name, |
| 20 | + // namespace, |
| 21 | +}) => { |
| 22 | + const [form] = Form.useForm<API.CreateClusterData>(); |
| 23 | + const { validateFields } = form; |
| 24 | + |
| 25 | + // const { runAsync: updateParameters, loading } = useRequest( |
| 26 | + // obcluster.patchOBCluster, |
| 27 | + // { |
| 28 | + // manual: true, |
| 29 | + // onSuccess: (res) => { |
| 30 | + // if (res.successful) { |
| 31 | + // message.success( |
| 32 | + // intl.formatMessage({ |
| 33 | + // id: 'src.pages.Cluster.Detail.Overview.E908AA54', |
| 34 | + // defaultMessage: '编辑参数已成功', |
| 35 | + // }), |
| 36 | + // ); |
| 37 | + // onSuccess(); |
| 38 | + // } |
| 39 | + // }, |
| 40 | + // }, |
| 41 | + // ); |
| 42 | + |
| 43 | + return ( |
| 44 | + <Modal |
| 45 | + title={intl.formatMessage({ |
| 46 | + id: 'src.pages.Cluster.Detail.Overview.849E8956', |
| 47 | + defaultMessage: '参数编辑', |
| 48 | + })} |
| 49 | + open={visible} |
| 50 | + destroyOnClose |
| 51 | + onCancel={() => onCancel()} |
| 52 | + width={520} |
| 53 | + footer={ |
| 54 | + <Space> |
| 55 | + <Button onClick={onCancel}>取消</Button> |
| 56 | + <Button |
| 57 | + type="primary" |
| 58 | + // loading={loading} |
| 59 | + // TODO 单独编辑参数接口 |
| 60 | + onClick={() => { |
| 61 | + validateFields().then((values) => { |
| 62 | + console.log('values', values); |
| 63 | + // updateParameters(name, namespace, values, `编辑参数已成功`); |
| 64 | + }); |
| 65 | + }} |
| 66 | + > |
| 67 | + 确定 |
| 68 | + </Button> |
| 69 | + </Space> |
| 70 | + } |
| 71 | + > |
| 72 | + <Form form={form} layout="vertical" style={{ marginBottom: 56 }}> |
| 73 | + <Row gutter={4}> |
| 74 | + <Col span={12}> |
| 75 | + <Form.Item |
| 76 | + label={intl.formatMessage({ |
| 77 | + id: 'src.pages.Cluster.Detail.Overview.0F9AD89D', |
| 78 | + defaultMessage: '参数名', |
| 79 | + })} |
| 80 | + initialValue={initialValues?.name} |
| 81 | + name={'name'} |
| 82 | + > |
| 83 | + <Input disabled={true} /> |
| 84 | + </Form.Item> |
| 85 | + </Col> |
| 86 | + <Col span={12}> |
| 87 | + <Form.Item |
| 88 | + label={intl.formatMessage({ |
| 89 | + id: 'src.pages.Cluster.Detail.Overview.4E02366B', |
| 90 | + defaultMessage: '参数值', |
| 91 | + })} |
| 92 | + name={'value'} |
| 93 | + initialValue={initialValues?.value} |
| 94 | + rules={[ |
| 95 | + { |
| 96 | + required: true, |
| 97 | + message: intl.formatMessage({ |
| 98 | + id: 'src.pages.Cluster.Detail.Overview.5DA70D14', |
| 99 | + defaultMessage: '请输入参数值', |
| 100 | + }), |
| 101 | + }, |
| 102 | + ]} |
| 103 | + > |
| 104 | + <Input |
| 105 | + placeholder={intl.formatMessage({ |
| 106 | + id: 'src.pages.Cluster.Detail.Overview.E26B7DFD', |
| 107 | + defaultMessage: '请输入', |
| 108 | + })} |
| 109 | + /> |
| 110 | + </Form.Item> |
| 111 | + </Col> |
| 112 | + </Row> |
| 113 | + </Form> |
| 114 | + </Modal> |
| 115 | + ); |
| 116 | +}; |
| 117 | + |
| 118 | +export default ParametersModal; |
0 commit comments