From cceff91f818a78cded5ff311b33b5faf31c40086 Mon Sep 17 00:00:00 2001 From: erge Date: Mon, 27 Nov 2023 20:17:58 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[Optimize]Security=E3=80=81Consumer?= =?UTF-8?q?=E6=9D=83=E9=99=90=E7=82=B9=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/CommonConfig.tsx | 4 + .../src/pages/ConsumerGroup/config.tsx | 41 +++++++---- .../src/pages/SecurityUsers/index.tsx | 73 ++++++++++++------- 3 files changed, 75 insertions(+), 43 deletions(-) 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 5c0ded8d6..06ed6d5df 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx @@ -33,6 +33,9 @@ export enum ClustersPermissionMap { TOPIC_CANCEL_REPLICATOR = 'Topic-详情-取消Topic复制', // Consumers CONSUMERS_RESET_OFFSET = 'Consumers-重置Offset', + GROUP_DELETE = 'Group-删除', + GROUP_TOPIC_DELETE = 'GroupOffset-Topic纬度删除', + GROUP_PARTITION_DELETE = 'GroupOffset-Partition纬度删除', // Test TEST_CONSUMER = 'Test-Consumer', TEST_PRODUCER = 'Test-Producer', @@ -54,6 +57,7 @@ export enum ClustersPermissionMap { SECURITY_USER_ADD = 'Security-User新增', SECURITY_USER_DELETE = 'Security-User删除', SECURITY_USER_EDIT_PASSWORD = 'Security-User修改密码', + SECURITY_USER_VIEW_PASSWORD = 'Security-User查看密码', } export interface PermissionNode { diff --git a/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/config.tsx b/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/config.tsx index 40b4a7f4c..977006e24 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/config.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/config.tsx @@ -22,7 +22,8 @@ export const defaultPagination = { }; export const getGroupColumns = (arg?: any) => { - const columns = [ + const [global] = AppContainer.useGlobalValue(); + const columns: any = [ { title: 'ConsumerGroup', dataIndex: 'name', @@ -63,7 +64,9 @@ export const getGroupColumns = (arg?: any) => { width: 200, render: (t: number) => (t ? t.toLocaleString() : '-'), }, - { + ]; + if (global.hasPermission && global.hasPermission(ClustersPermissionMap.GROUP_DELETE)) { + columns.push({ title: '操作', dataIndex: 'options', key: 'options', @@ -77,8 +80,8 @@ export const getGroupColumns = (arg?: any) => { ); }, - }, - ]; + }); + } return columns; }; @@ -114,7 +117,7 @@ export const getGtoupTopicColumns = (arg?: any) => { render: (t: number) => (t ? t.toLocaleString() : '-'), }, ]; - if (global.hasPermission && global.hasPermission(ClustersPermissionMap.CONSUMERS_RESET_OFFSET)) { + if (global.hasPermission) { columns.push({ title: '操作', dataIndex: 'desc', @@ -123,16 +126,24 @@ export const getGtoupTopicColumns = (arg?: any) => { render: (value: any, record: any) => { return (
- arg.resetOffset(record)}>重置Offset - arg.deleteOffset(record)} - okText="是" - cancelText="否" - > - - + {global.hasPermission(ClustersPermissionMap.CONSUMERS_RESET_OFFSET) ? ( + arg.resetOffset(record)}>重置Offset + ) : ( + <> + )} + {global.hasPermission(ClustersPermissionMap.GROUP_TOPIC_DELETE) ? ( + arg.deleteOffset(record)} + okText="是" + cancelText="否" + > + + + ) : ( + <> + )}
); }, diff --git a/km-console/packages/layout-clusters-fe/src/pages/SecurityUsers/index.tsx b/km-console/packages/layout-clusters-fe/src/pages/SecurityUsers/index.tsx index 6291ed427..9037e69a7 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/SecurityUsers/index.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/SecurityUsers/index.tsx @@ -23,7 +23,7 @@ import api from '@src/api'; import { useParams } from 'react-router-dom'; import { regKafkaPassword } from '@src/constants/reg'; import { tableHeaderPrefix } from '@src/constants/common'; - +import { ClustersPermissionMap } from '../CommonConfig'; export const randomString = (len = 32, chars = 'abcdefghijklmnopqrstuvwxyz1234567890'): string => { const maxPos = chars.length; let str = ''; @@ -85,7 +85,7 @@ const PasswordContent = (props: { clusterId: string; name: string }) => { const { clusterId, name } = props; const [loading, setLoading] = useState(false); const [pw, setPw] = useState(initialShowPassword); - + const [global] = AppContainer.useGlobalValue(); const switchPwStatus = () => { if (!loading) { setLoading(true); @@ -113,9 +113,13 @@ const PasswordContent = (props: { clusterId: string; name: string }) => {
{pw}
- - {loading ? : pw === initialShowPassword ? : } - + {global.hasPermission(ClustersPermissionMap.SECURITY_USER_VIEW_PASSWORD) ? ( + + {loading ? : pw === initialShowPassword ? : } + + ) : ( + <> + )} ); }; @@ -323,7 +327,7 @@ const SecurityUsers = (): JSX.Element => { }; const columns = () => { - const baseColumns = [ + const baseColumns: any = [ { title: 'KafkaUser', dataIndex: 'name', @@ -348,30 +352,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 +467,17 @@ const SecurityUsers = (): JSX.Element => { setSearchKeywordsInput(e.target.value); }} /> - + {global.hasPermission && global.hasPermission(ClustersPermissionMap.SECURITY_USER_ADD) ? ( + + ) : ( + <> + )} From a9eb4ae30e64ec5362a7755ac254715536cc1fd2 Mon Sep 17 00:00:00 2001 From: erge Date: Mon, 27 Nov 2023 20:18:42 +0800 Subject: [PATCH 2/3] =?UTF-8?q?[BugFix]JMX=E7=AB=AF=E5=8F=A3=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4=E4=BF=A1=E6=81=AF=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/MutliClusterPage/AccessCluster.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/km-console/packages/layout-clusters-fe/src/pages/MutliClusterPage/AccessCluster.tsx b/km-console/packages/layout-clusters-fe/src/pages/MutliClusterPage/AccessCluster.tsx index 50ab0a372..fec1a8a6b 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/MutliClusterPage/AccessCluster.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/MutliClusterPage/AccessCluster.tsx @@ -537,7 +537,7 @@ const ConnectorForm = (props: { setSelectedTabKey(undefined); try { const jmxPortInfo = JSON.parse(initFieldsValue.jmxProperties) || {}; - form.setFieldsValue({ ...initFieldsValue, jmxProperties: jmxPortInfo.jmxProperties }); + form.setFieldsValue({ ...initFieldsValue, jmxProperties: jmxPortInfo.jmxPort }); } catch { form.setFieldsValue({ ...initFieldsValue }); } @@ -546,7 +546,7 @@ const ConnectorForm = (props: { useLayoutEffect(() => { try { const jmxPortInfo = JSON.parse(initFieldsValue.jmxProperties) || {}; - form.setFieldsValue({ ...initFieldsValue, jmxProperties: jmxPortInfo.jmxProperties }); + form.setFieldsValue({ ...initFieldsValue, jmxProperties: jmxPortInfo.jmxPort }); } catch { form.setFieldsValue({ ...initFieldsValue }); } From b6ea4aec1966e8f23a215a21aa86ba783d57c7c6 Mon Sep 17 00:00:00 2001 From: EricZeng Date: Mon, 27 Nov 2023 21:08:05 +0800 Subject: [PATCH 3/3] =?UTF-8?q?[Optimize]GroupTopic=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=AE=9E=E6=97=B6=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=20(#1196)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../know/streaming/km/biz/group/GroupManager.java | 2 +- .../streaming/km/biz/group/impl/GroupManagerImpl.java | 9 +++++++-- .../km/rest/api/v3/cluster/ClusterGroupsController.java | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/km-biz/src/main/java/com/xiaojukeji/know/streaming/km/biz/group/GroupManager.java b/km-biz/src/main/java/com/xiaojukeji/know/streaming/km/biz/group/GroupManager.java index ea6465a38..60c9b0667 100644 --- a/km-biz/src/main/java/com/xiaojukeji/know/streaming/km/biz/group/GroupManager.java +++ b/km-biz/src/main/java/com/xiaojukeji/know/streaming/km/biz/group/GroupManager.java @@ -26,7 +26,7 @@ PaginationResult pagingGroupMembers(Long clusterPhyId, String searchGroupKeyword, PaginationBaseDTO dto); - PaginationResult pagingGroupTopicMembers(Long clusterPhyId, String groupName, PaginationBaseDTO dto); + PaginationResult pagingGroupTopicMembers(Long clusterPhyId, String groupName, PaginationBaseDTO dto) throws Exception; PaginationResult pagingClusterGroupsOverview(Long clusterPhyId, ClusterGroupSummaryDTO dto); diff --git a/km-biz/src/main/java/com/xiaojukeji/know/streaming/km/biz/group/impl/GroupManagerImpl.java b/km-biz/src/main/java/com/xiaojukeji/know/streaming/km/biz/group/impl/GroupManagerImpl.java index 753768dfc..55d7219c4 100644 --- a/km-biz/src/main/java/com/xiaojukeji/know/streaming/km/biz/group/impl/GroupManagerImpl.java +++ b/km-biz/src/main/java/com/xiaojukeji/know/streaming/km/biz/group/impl/GroupManagerImpl.java @@ -118,10 +118,15 @@ public PaginationResult pagingGroupMembers(Long clusterPhy } @Override - public PaginationResult pagingGroupTopicMembers(Long clusterPhyId, String groupName, PaginationBaseDTO dto) { + public PaginationResult pagingGroupTopicMembers(Long clusterPhyId, String groupName, PaginationBaseDTO dto) throws Exception { long startTimeUnitMs = System.currentTimeMillis(); - Group group = groupService.getGroupFromDB(clusterPhyId, groupName); + ClusterPhy clusterPhy = clusterPhyService.getClusterByCluster(clusterPhyId); + if (clusterPhy == null) { + return PaginationResult.buildFailure(MsgConstant.getClusterPhyNotExist(clusterPhyId), dto); + } + + Group group = groupService.getGroupFromKafka(clusterPhy, groupName); //没有topicMember则直接返回 if (group == null || ValidateUtils.isEmptyList(group.getTopicMembers())) { diff --git a/km-rest/src/main/java/com/xiaojukeji/know/streaming/km/rest/api/v3/cluster/ClusterGroupsController.java b/km-rest/src/main/java/com/xiaojukeji/know/streaming/km/rest/api/v3/cluster/ClusterGroupsController.java index 7159dca9d..d43515b67 100644 --- a/km-rest/src/main/java/com/xiaojukeji/know/streaming/km/rest/api/v3/cluster/ClusterGroupsController.java +++ b/km-rest/src/main/java/com/xiaojukeji/know/streaming/km/rest/api/v3/cluster/ClusterGroupsController.java @@ -77,7 +77,7 @@ public Result> getClusterPhyGroupPartitions(@PathVariable @GetMapping(value = "clusters/{clusterPhyId}/groups/{groupName}/topics-overview") public PaginationResult getGroupTopicsOverview(@PathVariable Long clusterPhyId, @PathVariable String groupName, - PaginationBaseDTO dto) { + PaginationBaseDTO dto) throws Exception { return groupManager.pagingGroupTopicMembers(clusterPhyId, groupName, dto); }