import React, { useState } from 'react'; import { useParams } from 'react-router-dom'; import { Button, Form, Input, Modal, notification, Utils } from 'knowdesign'; import { IconFont } from '@knowdesign/icons'; import Api from '@src/api/index'; // eslint-disable-next-line react/display-name export default (props: { record: any; onConfirm?: () => void }) => { const { record, onConfirm } = props; const routeParams = useParams<{ clusterId: string; }>(); const [form] = Form.useForm(); const [delDialogVisible, setDelDialogVisble] = useState(false); const handleDelOk = () => { form.validateFields().then((e) => { const formVal = form.getFieldsValue(); formVal.clusterId = Number(routeParams.clusterId); Utils.delete(Api.deleteTopic(), { data: formVal }).then((res: any) => { if (res === null) { notification.success({ message: '删除成功', }); setDelDialogVisble(false); onConfirm && onConfirm(); } else { notification.error({ message: '删除失败', }); } }); }); }; return ( <> { setDelDialogVisble(false); }} okText="删除" okButtonProps={{ danger: true, size: 'small', style: { paddingLeft: '16px', paddingRight: '16px', }, }} cancelButtonProps={{ size: 'small', style: { paddingLeft: '16px', paddingRight: '16px', }, }} >
会删除Topic的全部消息数据和ACL权限!请再次输入Topic名称进行确认!
{record.topicName} ({ validator(_, value) { if (!value) { return Promise.reject(new Error('请输入Topic名称')); } else if (value !== record.topicName) { return Promise.reject(new Error('请输入正确的Topic名称')); } return Promise.resolve(); }, }), ]} >
); };