mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 03:42:07 +08:00
[Optimize]权限新增ACL,自定义权限配置,资源TransactionalId优化(#1160)
This commit is contained in:
@@ -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,37 +366,43 @@ 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' ? (
|
||||||
<Form.Item
|
type !== 'transactionalId' ? (
|
||||||
name={`${type}Name`}
|
<Form.Item
|
||||||
dependencies={[`${type}PatternType`]}
|
name={`${type}Name`}
|
||||||
validateTrigger="onBlur"
|
dependencies={[`${type}PatternType`]}
|
||||||
rules={[
|
validateTrigger="onBlur"
|
||||||
({ getFieldValue }) => ({
|
rules={[
|
||||||
validator: (rule: any, value: string) => {
|
({ getFieldValue }) => ({
|
||||||
if (!value) {
|
validator: (rule: any, value: string) => {
|
||||||
return Promise.reject(`${UpperCaseType}Name 不能为空`);
|
if (!value) {
|
||||||
|
return Promise.reject(`${UpperCaseType}Name 不能为空`);
|
||||||
|
}
|
||||||
|
if (type === 'topic' && getFieldValue(`${type}PatternType`) === ACL_PATTERN_TYPE['Literal']) {
|
||||||
|
return Utils.request(api.getTopicMetadata(clusterId as any, value)).then((res: any) => {
|
||||||
|
return res?.exist ? Promise.resolve() : Promise.reject('该 Topic 不存在');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Promise.resolve();
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<AutoComplete
|
||||||
|
filterOption={(value, option) => {
|
||||||
|
if (option?.value.includes(value)) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (type === 'topic' && getFieldValue(`${type}PatternType`) === ACL_PATTERN_TYPE['Literal']) {
|
return false;
|
||||||
return Utils.request(api.getTopicMetadata(clusterId as any, value)).then((res: any) => {
|
}}
|
||||||
return res?.exist ? Promise.resolve() : Promise.reject('该 Topic 不存在');
|
options={type === 'topic' ? topicMetaData : groupMetaData}
|
||||||
});
|
placeholder={`请输入 ${type}Name`}
|
||||||
}
|
/>
|
||||||
return Promise.resolve();
|
</Form.Item>
|
||||||
},
|
) : (
|
||||||
}),
|
<Form.Item name={`transactionalId`} rules={[{ required: true, message: `TransactionalId不能为空` }]}>
|
||||||
]}
|
<Input placeholder={`请输入TransactionalId`}></Input>
|
||||||
>
|
</Form.Item>
|
||||||
<AutoComplete
|
)
|
||||||
filterOption={(value, option) => {
|
|
||||||
if (option?.value.includes(value)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}}
|
|
||||||
options={type === 'topic' ? topicMetaData : groupMetaData}
|
|
||||||
placeholder={`请输入 ${type}Name`}
|
|
||||||
/>
|
|
||||||
</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']) {
|
||||||
|
|||||||
Reference in New Issue
Block a user