diff --git a/km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx b/km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx index 712e98fc8..d168b8048 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx @@ -45,6 +45,12 @@ export enum ClustersPermissionMap { CONNECTOR_DELETE = 'Connector-删除', CONNECTOR_RESTART = 'Connector-重启', CONNECTOR_STOP_RESUME = 'Connector-暂停&恢复', + // Security + SECURITY_ACL_ADD = 'Security-ACL新增', + SECURITY_ACL_DELETE = 'Security-ACL删除', + SECURITY_USER_ADD = 'Security-User新增', + SECURITY_USER_DELETE = 'Security-User删除', + SECURITY_USER_EDIT_PASSWORD = 'Security-User修改密码', } export interface PermissionNode { diff --git a/km-console/packages/layout-clusters-fe/src/pages/SecurityACLs/index.tsx b/km-console/packages/layout-clusters-fe/src/pages/SecurityACLs/index.tsx index 9919afdda..46befe501 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/SecurityACLs/index.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/SecurityACLs/index.tsx @@ -14,6 +14,7 @@ import AddACLDrawer, { RESOURCE_TO_OPERATIONS_MAP, RESOURCE_MAP_KEYS, } from './EditDrawer'; +import { ClustersPermissionMap } from '../CommonConfig'; import './index.less'; const { confirm } = Modal; @@ -105,7 +106,7 @@ const SecurityACLs = (): JSX.Element => { }; const columns = () => { - const baseColumns = [ + const baseColumns: any = [ { title: 'Principal', dataIndex: 'kafkaUser', @@ -143,7 +144,9 @@ const SecurityACLs = (): JSX.Element => { title: 'Host', dataIndex: 'aclClientHost', }, - { + ]; + if (global.hasPermission && global.hasPermission(ClustersPermissionMap.SECURITY_ACL_DELETE)) { + baseColumns.push({ title: '操作', dataIndex: '', width: 120, @@ -156,8 +159,8 @@ const SecurityACLs = (): JSX.Element => { ); }, - }, - ]; + }); + } return baseColumns; }; @@ -238,15 +241,19 @@ const SecurityACLs = (): JSX.Element => { -
- -
+ {global.hasPermission && global.hasPermission(ClustersPermissionMap.SECURITY_ACL_ADD) ? ( +
+ +
+ ) : ( + <> + )} { const maxPos = chars.length; let str = ''; @@ -323,7 +323,7 @@ const SecurityUsers = (): JSX.Element => { }; const columns = () => { - const baseColumns = [ + const baseColumns: any = [ { title: 'KafkaUser', dataIndex: 'name', @@ -348,30 +348,39 @@ const SecurityUsers = (): JSX.Element => { return ; }, }, - { + ]; + if (global.hasPermission) { + baseColumns.push({ title: '操作', dataIndex: '', width: 240, render(record: UsersProps) { return ( <> - - + {global.hasPermission(ClustersPermissionMap.SECURITY_USER_EDIT_PASSWORD) ? ( + + ) : ( + <> + )} + {global.hasPermission(ClustersPermissionMap.SECURITY_USER_DELETE) ? ( + + ) : ( + <> + )} ); }, - }, - ]; - + }); + } return baseColumns; }; @@ -454,13 +463,17 @@ const SecurityUsers = (): JSX.Element => { setSearchKeywordsInput(e.target.value); }} /> - + {global.hasPermission && global.hasPermission(ClustersPermissionMap.SECURITY_USER_ADD) ? ( + + ) : ( + <> + )}