forked from didi/KnowStreaming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelete.tsx
More file actions
104 lines (103 loc) · 3.13 KB
/
Delete.tsx
File metadata and controls
104 lines (103 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import React, { useState } from 'react';
import { useParams } from 'react-router-dom';
import { Button, Form, Input, Modal, Utils } from 'knowdesign';
import notification from '@src/components/Notification';
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.clusterPhyId = Number(routeParams.clusterId);
formVal.deleteType = 0;
Utils.delete(Api.deleteGroupOffset(), { data: formVal }).then((res: any) => {
if (res === null) {
notification.success({
message: '删除消费组成功',
});
setDelDialogVisble(false);
onConfirm && onConfirm();
} else {
notification.error({
message: '删除消费组失败',
});
}
});
});
};
return (
<>
<Button
style={{ paddingLeft: 0 }}
type="link"
onClick={(_) => {
setDelDialogVisble(true);
}}
>
删除
</Button>
<Modal
className="custom-modal"
title="确定要删除此Topic吗?"
centered={true}
visible={delDialogVisible}
wrapClassName="del-topic-modal"
destroyOnClose={true}
maskClosable={false}
onOk={handleDelOk}
onCancel={(_) => {
setDelDialogVisble(false);
}}
okText="删除"
okButtonProps={{
danger: true,
size: 'small',
style: {
paddingLeft: '16px',
paddingRight: '16px',
},
}}
cancelButtonProps={{
size: 'small',
style: {
paddingLeft: '16px',
paddingRight: '16px',
},
}}
>
{/* <div className="tip-info">
<IconFont type="icon-warning-circle"></IconFont>
<span>会删除Topic的全部消息数据和ACL权限!请再次输入Topic名称进行确认!</span>
</div> */}
<Form form={form} labelCol={{ span: 5 }} style={{ marginTop: 18 }}>
<Form.Item label="TopicName">{record.name}</Form.Item>
<Form.Item
name="groupName"
label="GroupName"
rules={[
// { required: true },
() => ({
validator(_, value) {
if (!value) {
return Promise.reject(new Error('请输入Group名称'));
} else if (value !== record.name) {
return Promise.reject(new Error('请输入正确的Group名称'));
}
return Promise.resolve();
},
}),
]}
>
<Input placeholder="请输入" size="small"></Input>
</Form.Item>
</Form>
</Modal>
</>
);
};