[Optimize]权限新增ACL,自定义权限配置,资源TransactionalId优化(#1160)

This commit is contained in:
erge
2023-11-26 16:26:06 +08:00
parent 592dee884a
commit 8b30f78744

View File

@@ -132,17 +132,35 @@ const AddDrawer = forwardRef((_, ref) => {
form.validateFields().then((formData) => { form.validateFields().then((formData) => {
const submitData = []; const submitData = [];
const { configType, principle, kafkaUser } = formData; const { configType, principle, kafkaUser } = formData;
if (configType === 'custom') { if (configType === 'custom') {
// 1. 自定义权限 // 1. 自定义权限
// TODO: 需要和后端联调 // TODO: 需要和后端联调
const { resourceType, resourcePatternType, aclPermissionType, aclOperation, aclClientHost } = formData; const {
resourceType,
resourcePatternType,
aclPermissionType,
aclOperation,
aclClientHost,
cluster,
topicName,
topicPatternType,
groupName,
groupPatternType,
transactionalId,
transactionalIdPatternType,
} = formData;
submitData.push({ submitData.push({
clusterId, clusterId,
kafkaUser: principle === 'all' ? '*' : kafkaUser, kafkaUser: principle === 'all' ? '*' : kafkaUser,
resourceType, resourceType,
resourcePatternType, resourcePatternType: cluster
resourceName: '*', ? 3
: topicPatternType
? topicPatternType
: groupPatternType
? groupPatternType
: transactionalIdPatternType,
resourceName: cluster ? cluster : topicName ? topicName : groupName ? groupName : transactionalId,
aclPermissionType, aclPermissionType,
aclOperation, aclOperation,
aclClientHost, aclClientHost,
@@ -348,6 +366,7 @@ const AddDrawer = forwardRef((_, ref) => {
<Form.Item dependencies={[`${type}Principle`]} style={{ marginBottom: 0 }}> <Form.Item dependencies={[`${type}Principle`]} style={{ marginBottom: 0 }}>
{({ getFieldValue }) => {({ getFieldValue }) =>
getFieldValue(`${type}Principle`) === 'special' ? ( getFieldValue(`${type}Principle`) === 'special' ? (
type !== 'transactionalId' ? (
<Form.Item <Form.Item
name={`${type}Name`} name={`${type}Name`}
dependencies={[`${type}PatternType`]} dependencies={[`${type}PatternType`]}
@@ -379,6 +398,11 @@ const AddDrawer = forwardRef((_, ref) => {
placeholder={`请输入 ${type}Name`} placeholder={`请输入 ${type}Name`}
/> />
</Form.Item> </Form.Item>
) : (
<Form.Item name={`transactionalId`} rules={[{ required: true, message: `TransactionalId不能为空` }]}>
<Input placeholder={`请输入TransactionalId`}></Input>
</Form.Item>
)
) : null ) : null
} }
</Form.Item> </Form.Item>
@@ -400,7 +424,7 @@ const AddDrawer = forwardRef((_, ref) => {
<Radio value={ACL_PERMISSION_TYPE['Deny']}>Deny</Radio> <Radio value={ACL_PERMISSION_TYPE['Deny']}>Deny</Radio>
</Radio.Group> </Radio.Group>
</Form.Item> </Form.Item>
<Form.Item {/* <Form.Item
label="Pattern Type" label="Pattern Type"
name="resourcePatternType" name="resourcePatternType"
rules={[{ required: true, message: 'Pattern Type 不能为空' }]} rules={[{ required: true, message: 'Pattern Type 不能为空' }]}
@@ -410,7 +434,7 @@ const AddDrawer = forwardRef((_, ref) => {
<Radio value={ACL_PATTERN_TYPE['Literal']}>Literal</Radio> <Radio value={ACL_PATTERN_TYPE['Literal']}>Literal</Radio>
<Radio value={ACL_PATTERN_TYPE['Prefixed']}>Prefixed</Radio> <Radio value={ACL_PATTERN_TYPE['Prefixed']}>Prefixed</Radio>
</Radio.Group> </Radio.Group>
</Form.Item> </Form.Item> */}
<Form.Item <Form.Item
label="Resource Type" label="Resource Type"
name="resourceType" name="resourceType"
@@ -428,7 +452,7 @@ const AddDrawer = forwardRef((_, ref) => {
<Form.Item dependencies={['resourceType']}> <Form.Item dependencies={['resourceType']}>
{({ getFieldValue }) => { {({ getFieldValue }) => {
const type = getFieldValue('resourceType'); const type = getFieldValue('resourceType');
if (type === ACL_RESOURCE_TYPE['Cluster'] || type === ACL_RESOURCE_TYPE['TransactionalId']) { if (type === ACL_RESOURCE_TYPE['Cluster']) {
//TODO需要和后端获取集群和事务接口联调 //TODO需要和后端获取集群和事务接口联调
return ( return (
<Form.Item <Form.Item
@@ -438,6 +462,8 @@ const AddDrawer = forwardRef((_, ref) => {
<Input placeholder={`请输入${type === 4 ? 'Cluster名称' : 'TransactionalId'}`}></Input> <Input placeholder={`请输入${type === 4 ? 'Cluster名称' : 'TransactionalId'}`}></Input>
</Form.Item> </Form.Item>
); );
} else if (type === ACL_RESOURCE_TYPE['TransactionalId']) {
return <PatternTypeFormItems type="transactionalId" />;
} else if (type === ACL_RESOURCE_TYPE['Topic']) { } else if (type === ACL_RESOURCE_TYPE['Topic']) {
return <PatternTypeFormItems type="topic" />; return <PatternTypeFormItems type="topic" />;
} else if (type === ACL_RESOURCE_TYPE['Group']) { } else if (type === ACL_RESOURCE_TYPE['Group']) {