@@ -23,7 +23,7 @@ import api from '@src/api';
2323import { useParams } from 'react-router-dom' ;
2424import { regKafkaPassword } from '@src/constants/reg' ;
2525import { tableHeaderPrefix } from '@src/constants/common' ;
26-
26+ import { ClustersPermissionMap } from '../CommonConfig' ;
2727export const randomString = ( len = 32 , chars = 'abcdefghijklmnopqrstuvwxyz1234567890' ) : string => {
2828 const maxPos = chars . length ;
2929 let str = '' ;
@@ -85,7 +85,7 @@ const PasswordContent = (props: { clusterId: string; name: string }) => {
8585 const { clusterId, name } = props ;
8686 const [ loading , setLoading ] = useState ( false ) ;
8787 const [ pw , setPw ] = useState ( initialShowPassword ) ;
88-
88+ const [ global ] = AppContainer . useGlobalValue ( ) ;
8989 const switchPwStatus = ( ) => {
9090 if ( ! loading ) {
9191 setLoading ( true ) ;
@@ -113,9 +113,13 @@ const PasswordContent = (props: { clusterId: string; name: string }) => {
113113 < Tooltip title = { pw } placement = "bottom" >
114114 < div style = { { maxWidth : '80%' , overflow : 'hidden' , textOverflow : 'ellipsis' , whiteSpace : 'nowrap' } } > { pw } </ div >
115115 </ Tooltip >
116- < span style = { { marginLeft : 6 } } onClick = { switchPwStatus } >
117- { loading ? < LoadingOutlined /> : pw === initialShowPassword ? < EyeInvisibleOutlined /> : < EyeOutlined /> }
118- </ span >
116+ { global . hasPermission ( ClustersPermissionMap . SECURITY_USER_VIEW_PASSWORD ) ? (
117+ < span style = { { marginLeft : 6 } } onClick = { switchPwStatus } >
118+ { loading ? < LoadingOutlined /> : pw === initialShowPassword ? < EyeInvisibleOutlined /> : < EyeOutlined /> }
119+ </ span >
120+ ) : (
121+ < > </ >
122+ ) }
119123 </ div >
120124 ) ;
121125} ;
@@ -323,7 +327,7 @@ const SecurityUsers = (): JSX.Element => {
323327 } ;
324328
325329 const columns = ( ) => {
326- const baseColumns = [
330+ const baseColumns : any = [
327331 {
328332 title : 'KafkaUser' ,
329333 dataIndex : 'name' ,
@@ -348,30 +352,39 @@ const SecurityUsers = (): JSX.Element => {
348352 return < PasswordContent clusterId = { clusterId } name = { record . name } /> ;
349353 } ,
350354 } ,
351- {
355+ ] ;
356+ if ( global . hasPermission ) {
357+ baseColumns . push ( {
352358 title : '操作' ,
353359 dataIndex : '' ,
354360 width : 240 ,
355361 render ( record : UsersProps ) {
356362 return (
357363 < >
358- < Button
359- type = "link"
360- size = "small"
361- style = { { paddingLeft : 0 } }
362- onClick = { ( ) => editDrawerRef . current . onOpen ( true , UsersOperate . ChangePassword , getKafkaUserList , record ) }
363- >
364- 修改密码
365- </ Button >
366- < Button type = "link" size = "small" onClick = { ( ) => onDelete ( record ) } >
367- 删除
368- </ Button >
364+ { global . hasPermission ( ClustersPermissionMap . SECURITY_USER_EDIT_PASSWORD ) ? (
365+ < Button
366+ type = "link"
367+ size = "small"
368+ style = { { paddingLeft : 0 } }
369+ onClick = { ( ) => editDrawerRef . current . onOpen ( true , UsersOperate . ChangePassword , getKafkaUserList , record ) }
370+ >
371+ 修改密码
372+ </ Button >
373+ ) : (
374+ < > </ >
375+ ) }
376+ { global . hasPermission ( ClustersPermissionMap . SECURITY_USER_DELETE ) ? (
377+ < Button type = "link" size = "small" onClick = { ( ) => onDelete ( record ) } >
378+ 删除
379+ </ Button >
380+ ) : (
381+ < > </ >
382+ ) }
369383 </ >
370384 ) ;
371385 } ,
372- } ,
373- ] ;
374-
386+ } ) ;
387+ }
375388 return baseColumns ;
376389 } ;
377390
@@ -454,13 +467,17 @@ const SecurityUsers = (): JSX.Element => {
454467 setSearchKeywordsInput ( e . target . value ) ;
455468 } }
456469 />
457- < Button
458- type = "primary"
459- // icon={<PlusOutlined />}
460- onClick = { ( ) => editDrawerRef . current . onOpen ( true , UsersOperate . Add , getKafkaUserList ) }
461- >
462- 新增KafkaUser
463- </ Button >
470+ { global . hasPermission && global . hasPermission ( ClustersPermissionMap . SECURITY_USER_ADD ) ? (
471+ < Button
472+ type = "primary"
473+ // icon={<PlusOutlined />}
474+ onClick = { ( ) => editDrawerRef . current . onOpen ( true , UsersOperate . Add , getKafkaUserList ) }
475+ >
476+ 新增KafkaUser
477+ </ Button >
478+ ) : (
479+ < > </ >
480+ ) }
464481 </ div >
465482 </ div >
466483
0 commit comments