From e80f8086d458cc29254fab43b2420a7600340120 Mon Sep 17 00:00:00 2001 From: erge Date: Sun, 26 Nov 2023 16:18:39 +0800 Subject: [PATCH 1/8] =?UTF-8?q?[Bugfix]=E4=BC=98=E5=8C=96=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E7=AE=A1=E7=90=86=E5=AD=90=E5=BA=94=E7=94=A8=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=AD=A3=E5=B8=B8=E5=90=AF=E5=8A=A8(#1167)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../packages/config-manager-fe/config/webpack.common.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/km-console/packages/config-manager-fe/config/webpack.common.js b/km-console/packages/config-manager-fe/config/webpack.common.js index cef88e615..7521137bc 100644 --- a/km-console/packages/config-manager-fe/config/webpack.common.js +++ b/km-console/packages/config-manager-fe/config/webpack.common.js @@ -16,6 +16,13 @@ const babelOptions = { cacheDirectory: true, babelrc: false, presets: [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-typescript'), require.resolve('@babel/preset-react')], + overrides: [ + // TODO:编译时需要做的事情更多,应该只针对目标第三方库 + { + include: './node_modules', + sourceType: 'unambiguous' + } + ], plugins: [ [require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }], [require.resolve('@babel/plugin-proposal-class-properties'), { loose: true }], From 8a95401364cf100c6ea59d0f8a9d37315d5119d1 Mon Sep 17 00:00:00 2001 From: erge Date: Sun, 26 Nov 2023 16:21:14 +0800 Subject: [PATCH 2/8] =?UTF-8?q?[Optimize]security=E4=B8=8B=E7=9A=84users?= =?UTF-8?q?=E3=80=81acls=E6=8E=A5=E5=85=A5=E8=BF=9B=E6=9D=83=E9=99=90?= =?UTF-8?q?=E7=AE=A1=E7=90=86(#1089)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/CommonConfig.tsx | 10 ++++-- .../src/pages/SecurityACLs/index.tsx | 33 +++++++++++-------- 2 files changed, 27 insertions(+), 16 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 722d04e67..5c0ded8d6 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx @@ -48,6 +48,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 { @@ -98,9 +104,7 @@ const CommonConfig = () => { clustersPermissions.childList.forEach((node: PermissionNode) => node.has && userPermissions.push(node.permissionName)); // 获取用户在系统管理拥有的权限 - const configPermissions = userPermissionTree.find( - (sys: PermissionNode) => sys.permissionName === ClustersPermissionMap.SYS_MANAGE - ); + const configPermissions = userPermissionTree.find((sys: PermissionNode) => sys.permissionName === ClustersPermissionMap.SYS_MANAGE); configPermissions && configPermissions.childList.forEach((node: PermissionNode) => node.has && userPermissions.push(node.permissionName)); 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) ? ( +
+ +
+ ) : ( + <> + )} Date: Sun, 26 Nov 2023 16:23:12 +0800 Subject: [PATCH 3/8] =?UTF-8?q?[BugFix]=E4=BF=AE=E5=A4=8DTopic=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=B1=95=E7=A4=BA=EF=BC=8Coffset=E4=B8=BA0=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98(#996)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout-clusters-fe/src/pages/TopicDetail/config.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/km-console/packages/layout-clusters-fe/src/pages/TopicDetail/config.tsx b/km-console/packages/layout-clusters-fe/src/pages/TopicDetail/config.tsx index a6cdbc251..70055b2da 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/TopicDetail/config.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/TopicDetail/config.tsx @@ -82,7 +82,7 @@ export const getTopicMessagesColmns = () => { dataIndex: 'offset', key: 'offset', sorter: true, - render: (t: number) => (+t ? t.toLocaleString() : '-'), + render: (t: number) => (+t || +t === 0 ? t.toLocaleString() : '-'), // TODO: 千分位展示 }, { title: 'Timestamp', From 592dee884a5a4a67e0f7991e9e8f6123fd618e19 Mon Sep 17 00:00:00 2001 From: erge Date: Sun, 26 Nov 2023 16:25:00 +0800 Subject: [PATCH 4/8] =?UTF-8?q?[Optimize]Connect=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=8E=A5=E5=85=A5=E6=9D=83=E9=99=90=E7=AE=A1=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E6=89=80=E6=9C=89=E7=94=A8=E6=88=B7=E9=83=BD=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E9=87=8D=E5=90=AF=E3=80=81=E7=BC=96=E8=BE=91=E3=80=81=E5=88=A0?= =?UTF-8?q?=E9=99=A4(#1050)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/Connect/config.tsx | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/km-console/packages/layout-clusters-fe/src/pages/Connect/config.tsx b/km-console/packages/layout-clusters-fe/src/pages/Connect/config.tsx index 84c2b5190..d6d12bfab 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/Connect/config.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/Connect/config.tsx @@ -315,6 +315,7 @@ export const getWorkersColumns = (arg?: any) => { // Detail export const getConnectorsDetailColumns = (arg?: any) => { + const [global] = AppContainer.useGlobalValue(); const columns = [ { title: 'Task ID', @@ -363,16 +364,20 @@ export const getConnectorsDetailColumns = (arg?: any) => { render: (_t: any, r: any) => { return (
- arg?.retryOption(r.taskId)} - // onCancel={cancel} - okText="是" - cancelText="否" - overlayClassName="connect-popconfirm" - > - 重试 - + {global.hasPermission(ClustersPermissionMap.CONNECTOR_RESTART) ? ( + arg?.retryOption(r.taskId)} + // onCancel={cancel} + okText="是" + cancelText="否" + overlayClassName="connect-popconfirm" + > + 重试 + + ) : ( + <> + )}
); }, From 8b30f78744791a504cc50074c9ed5636bed79e8a Mon Sep 17 00:00:00 2001 From: erge Date: Sun, 26 Nov 2023 16:26:06 +0800 Subject: [PATCH 5/8] =?UTF-8?q?[Optimize]=E6=9D=83=E9=99=90=E6=96=B0?= =?UTF-8?q?=E5=A2=9EACL=EF=BC=8C=E8=87=AA=E5=AE=9A=E4=B9=89=E6=9D=83?= =?UTF-8?q?=E9=99=90=E9=85=8D=E7=BD=AE=EF=BC=8C=E8=B5=84=E6=BA=90Transacti?= =?UTF-8?q?onalId=E4=BC=98=E5=8C=96(#1160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/SecurityACLs/EditDrawer.tsx | 100 +++++++++++------- 1 file changed, 63 insertions(+), 37 deletions(-) diff --git a/km-console/packages/layout-clusters-fe/src/pages/SecurityACLs/EditDrawer.tsx b/km-console/packages/layout-clusters-fe/src/pages/SecurityACLs/EditDrawer.tsx index e155f3dad..1cc3a9099 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/SecurityACLs/EditDrawer.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/SecurityACLs/EditDrawer.tsx @@ -132,17 +132,35 @@ const AddDrawer = forwardRef((_, ref) => { form.validateFields().then((formData) => { const submitData = []; const { configType, principle, kafkaUser } = formData; - if (configType === 'custom') { // 1. 自定义权限 // TODO: 需要和后端联调 - const { resourceType, resourcePatternType, aclPermissionType, aclOperation, aclClientHost } = formData; + const { + resourceType, + resourcePatternType, + aclPermissionType, + aclOperation, + aclClientHost, + cluster, + topicName, + topicPatternType, + groupName, + groupPatternType, + transactionalId, + transactionalIdPatternType, + } = formData; submitData.push({ clusterId, kafkaUser: principle === 'all' ? '*' : kafkaUser, resourceType, - resourcePatternType, - resourceName: '*', + resourcePatternType: cluster + ? 3 + : topicPatternType + ? topicPatternType + : groupPatternType + ? groupPatternType + : transactionalIdPatternType, + resourceName: cluster ? cluster : topicName ? topicName : groupName ? groupName : transactionalId, aclPermissionType, aclOperation, aclClientHost, @@ -348,37 +366,43 @@ const AddDrawer = forwardRef((_, ref) => { {({ getFieldValue }) => getFieldValue(`${type}Principle`) === 'special' ? ( - ({ - validator: (rule: any, value: string) => { - 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 不存在'); - }); + type !== 'transactionalId' ? ( + ({ + validator: (rule: any, value: string) => { + 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(); + }, + }), + ]} + > + { + if (option?.value.includes(value)) { + return true; } - return Promise.resolve(); - }, - }), - ]} - > - { - if (option?.value.includes(value)) { - return true; - } - return false; - }} - options={type === 'topic' ? topicMetaData : groupMetaData} - placeholder={`请输入 ${type}Name`} - /> - + return false; + }} + options={type === 'topic' ? topicMetaData : groupMetaData} + placeholder={`请输入 ${type}Name`} + /> + + ) : ( + + + + ) ) : null } @@ -400,7 +424,7 @@ const AddDrawer = forwardRef((_, ref) => { Deny - { Literal Prefixed - + */} { {({ getFieldValue }) => { const type = getFieldValue('resourceType'); - if (type === ACL_RESOURCE_TYPE['Cluster'] || type === ACL_RESOURCE_TYPE['TransactionalId']) { + if (type === ACL_RESOURCE_TYPE['Cluster']) { //TODO需要和后端获取集群和事务接口联调 return ( { ); + } else if (type === ACL_RESOURCE_TYPE['TransactionalId']) { + return ; } else if (type === ACL_RESOURCE_TYPE['Topic']) { return ; } else if (type === ACL_RESOURCE_TYPE['Group']) { From af916d5a7162dc5773b2dce16996b9ef438e12dc Mon Sep 17 00:00:00 2001 From: erge Date: Sun, 26 Nov 2023 16:28:29 +0800 Subject: [PATCH 6/8] =?UTF-8?q?[Optimize]Connect-JSON=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=E7=9A=84JSON=E6=A0=BC=E5=BC=8F=E5=92=8C=E5=AE=98?= =?UTF-8?q?=E6=96=B9API=E7=9A=84=E6=A0=BC=E5=BC=8F=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4(#1048)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/Connect/AddConnectorUseJSON.tsx | 88 +++++++++++-------- 1 file changed, 52 insertions(+), 36 deletions(-) diff --git a/km-console/packages/layout-clusters-fe/src/pages/Connect/AddConnectorUseJSON.tsx b/km-console/packages/layout-clusters-fe/src/pages/Connect/AddConnectorUseJSON.tsx index e06ede24e..37d646e9d 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/Connect/AddConnectorUseJSON.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/Connect/AddConnectorUseJSON.tsx @@ -1,7 +1,7 @@ import api from '@src/api'; import CodeMirrorFormItem from '@src/components/CodeMirrorFormItem'; import customMessage from '@src/components/Message'; -import { Button, Divider, Drawer, Form, message, Space, Utils } from 'knowdesign'; +import { Button, Divider, Drawer, Form, message, Space, Utils, Select } from 'knowdesign'; import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react'; import { useParams } from 'react-router-dom'; import { ConnectCluster, ConnectorPlugin, ConnectorPluginConfig, OperateInfo } from './AddConnector'; @@ -9,9 +9,8 @@ import { ConnectCluster, ConnectorPlugin, ConnectorPluginConfig, OperateInfo } f const PLACEHOLDER = `配置格式如下 { - "connectClusterName": "", // Connect Cluster 名称 + "name": "", // Connect Cluster 名称 "config": { // 具体配置项 - "name": "", "connector.class": "", "tasks.max": 1, ... @@ -43,11 +42,16 @@ export default forwardRef((props: any, ref) => { const onOpen = (type: 'create' | 'edit', connectClusterName?: string, defaultConfigs?: { [key: string]: any }) => { if (defaultConfigs) { setDefaultConfigs({ ...defaultConfigs, connectClusterName }); + const connectorName = connectClusterName; + const connectClusterId = connectClusters.find((cluster) => cluster.label === connectClusterName).value; form.setFieldsValue({ + connectClusterId, + connectorName, configs: JSON.stringify( { - connectClusterName, - config: defaultConfigs, + // connectClusterName, + name: defaultConfigs.name, + config: { ...defaultConfigs, name: undefined }, }, null, 2 @@ -63,10 +67,11 @@ export default forwardRef((props: any, ref) => { form.validateFields().then( (data) => { const postData = JSON.parse(data.configs); - postData.connectorName = postData.config.name; - postData.connectClusterId = connectClusters.find((cluster) => cluster.label === postData.connectClusterName).value; - delete postData.connectClusterName; - + postData.connectorName = postData.name; + postData.connectClusterId = data.connectClusterId; + postData.config.name = postData.name; + // delete postData.connectClusterName; + delete postData.name; Object.entries(postData.config).forEach(([key, val]) => { if (val === null) { delete postData.config[key]; @@ -161,6 +166,26 @@ export default forwardRef((props: any, ref) => { } >
+ +