@@ -132,17 +132,35 @@ const AddDrawer = forwardRef((_, ref) => {
132132 form . validateFields ( ) . then ( ( formData ) => {
133133 const submitData = [ ] ;
134134 const { configType, principle, kafkaUser } = formData ;
135-
136135 if ( configType === 'custom' ) {
137136 // 1. 自定义权限
138137 // TODO: 需要和后端联调
139- const { resourceType, resourcePatternType, aclPermissionType, aclOperation, aclClientHost } = formData ;
138+ const {
139+ resourceType,
140+ resourcePatternType,
141+ aclPermissionType,
142+ aclOperation,
143+ aclClientHost,
144+ cluster,
145+ topicName,
146+ topicPatternType,
147+ groupName,
148+ groupPatternType,
149+ transactionalId,
150+ transactionalIdPatternType,
151+ } = formData ;
140152 submitData . push ( {
141153 clusterId,
142154 kafkaUser : principle === 'all' ? '*' : kafkaUser ,
143155 resourceType,
144- resourcePatternType,
145- resourceName : '*' ,
156+ resourcePatternType : cluster
157+ ? 3
158+ : topicPatternType
159+ ? topicPatternType
160+ : groupPatternType
161+ ? groupPatternType
162+ : transactionalIdPatternType ,
163+ resourceName : cluster ? cluster : topicName ? topicName : groupName ? groupName : transactionalId ,
146164 aclPermissionType,
147165 aclOperation,
148166 aclClientHost,
@@ -348,37 +366,43 @@ const AddDrawer = forwardRef((_, ref) => {
348366 < Form . Item dependencies = { [ `${ type } Principle` ] } style = { { marginBottom : 0 } } >
349367 { ( { getFieldValue } ) =>
350368 getFieldValue ( `${ type } Principle` ) === 'special' ? (
351- < Form . Item
352- name = { `${ type } Name` }
353- dependencies = { [ `${ type } PatternType` ] }
354- validateTrigger = "onBlur"
355- rules = { [
356- ( { getFieldValue } ) => ( {
357- validator : ( rule : any , value : string ) => {
358- if ( ! value ) {
359- return Promise . reject ( `${ UpperCaseType } Name 不能为空` ) ;
360- }
361- if ( type === 'topic' && getFieldValue ( `${ type } PatternType` ) === ACL_PATTERN_TYPE [ 'Literal' ] ) {
362- return Utils . request ( api . getTopicMetadata ( clusterId as any , value ) ) . then ( ( res : any ) => {
363- return res ?. exist ? Promise . resolve ( ) : Promise . reject ( '该 Topic 不存在' ) ;
364- } ) ;
369+ type !== 'transactionalId' ? (
370+ < Form . Item
371+ name = { `${ type } Name` }
372+ dependencies = { [ `${ type } PatternType` ] }
373+ validateTrigger = "onBlur"
374+ rules = { [
375+ ( { getFieldValue } ) => ( {
376+ validator : ( rule : any , value : string ) => {
377+ if ( ! value ) {
378+ return Promise . reject ( `${ UpperCaseType } Name 不能为空` ) ;
379+ }
380+ if ( type === 'topic' && getFieldValue ( `${ type } PatternType` ) === ACL_PATTERN_TYPE [ 'Literal' ] ) {
381+ return Utils . request ( api . getTopicMetadata ( clusterId as any , value ) ) . then ( ( res : any ) => {
382+ return res ?. exist ? Promise . resolve ( ) : Promise . reject ( '该 Topic 不存在' ) ;
383+ } ) ;
384+ }
385+ return Promise . resolve ( ) ;
386+ } ,
387+ } ) ,
388+ ] }
389+ >
390+ < AutoComplete
391+ filterOption = { ( value , option ) => {
392+ if ( option ?. value . includes ( value ) ) {
393+ return true ;
365394 }
366- return Promise . resolve ( ) ;
367- } ,
368- } ) ,
369- ] }
370- >
371- < AutoComplete
372- filterOption = { ( value , option ) => {
373- if ( option ?. value . includes ( value ) ) {
374- return true ;
375- }
376- return false ;
377- } }
378- options = { type === 'topic' ? topicMetaData : groupMetaData }
379- placeholder = { `请输入 ${ type } Name` }
380- />
381- </ Form . Item >
395+ return false ;
396+ } }
397+ options = { type === 'topic' ? topicMetaData : groupMetaData }
398+ placeholder = { `请输入 ${ type } Name` }
399+ />
400+ </ Form . Item >
401+ ) : (
402+ < Form . Item name = { `transactionalId` } rules = { [ { required : true , message : `TransactionalId不能为空` } ] } >
403+ < Input placeholder = { `请输入TransactionalId` } > </ Input >
404+ </ Form . Item >
405+ )
382406 ) : null
383407 }
384408 </ Form . Item >
@@ -400,7 +424,7 @@ const AddDrawer = forwardRef((_, ref) => {
400424 < Radio value = { ACL_PERMISSION_TYPE [ 'Deny' ] } > Deny</ Radio >
401425 </ Radio . Group >
402426 </ Form . Item >
403- < Form . Item
427+ { /* <Form.Item
404428 label="Pattern Type"
405429 name="resourcePatternType"
406430 rules={[{ required: true, message: 'Pattern Type 不能为空' }]}
@@ -410,7 +434,7 @@ const AddDrawer = forwardRef((_, ref) => {
410434 <Radio value={ACL_PATTERN_TYPE['Literal']}>Literal</Radio>
411435 <Radio value={ACL_PATTERN_TYPE['Prefixed']}>Prefixed</Radio>
412436 </Radio.Group>
413- </ Form . Item >
437+ </Form.Item> */ }
414438 < Form . Item
415439 label = "Resource Type"
416440 name = "resourceType"
@@ -428,7 +452,7 @@ const AddDrawer = forwardRef((_, ref) => {
428452 < Form . Item dependencies = { [ 'resourceType' ] } >
429453 { ( { getFieldValue } ) => {
430454 const type = getFieldValue ( 'resourceType' ) ;
431- if ( type === ACL_RESOURCE_TYPE [ 'Cluster' ] || type === ACL_RESOURCE_TYPE [ 'TransactionalId' ] ) {
455+ if ( type === ACL_RESOURCE_TYPE [ 'Cluster' ] ) {
432456 //TODO需要和后端获取集群和事务接口联调
433457 return (
434458 < Form . Item
@@ -438,6 +462,8 @@ const AddDrawer = forwardRef((_, ref) => {
438462 < Input placeholder = { `请输入${ type === 4 ? 'Cluster名称' : 'TransactionalId' } ` } > </ Input >
439463 </ Form . Item >
440464 ) ;
465+ } else if ( type === ACL_RESOURCE_TYPE [ 'TransactionalId' ] ) {
466+ return < PatternTypeFormItems type = "transactionalId" /> ;
441467 } else if ( type === ACL_RESOURCE_TYPE [ 'Topic' ] ) {
442468 return < PatternTypeFormItems type = "topic" /> ;
443469 } else if ( type === ACL_RESOURCE_TYPE [ 'Group' ] ) {
0 commit comments