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 }], diff --git a/km-console/packages/layout-clusters-fe/package.json b/km-console/packages/layout-clusters-fe/package.json index 4453210ba..9529094ed 100644 --- a/km-console/packages/layout-clusters-fe/package.json +++ b/km-console/packages/layout-clusters-fe/package.json @@ -108,6 +108,7 @@ "optimize-css-assets-webpack-plugin": "^5.0.1", "prettier": "2.3.2", "progress-bar-webpack-plugin": "^1.12.1", + "pubsub-js": "^1.9.4", "query-string": "^7.0.1", "react-refresh": "^0.10.0", "react-router-dom": "5.2.1", diff --git a/km-console/packages/layout-clusters-fe/src/components/CardBar/ConnectDetailCard.tsx b/km-console/packages/layout-clusters-fe/src/components/CardBar/ConnectDetailCard.tsx index f3f9f5453..615490958 100644 --- a/km-console/packages/layout-clusters-fe/src/components/CardBar/ConnectDetailCard.tsx +++ b/km-console/packages/layout-clusters-fe/src/components/CardBar/ConnectDetailCard.tsx @@ -49,7 +49,7 @@ const ConnectDetailCard = (props: { record: any }) => { return ( <> { - + {Utils.firstCharUppercase(type) || '-'} } @@ -64,7 +64,7 @@ const ConnectDetailCard = (props: { record: any }) => { return ( <> { - + {Utils.firstCharUppercase(state) || '-'} } 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/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) => { } >
+ + + + ) ) : 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']) { 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) ? ( +
+ +
+ ) : ( + <> + )} { dataIndex: 'offset', key: 'offset', sorter: true, - render: (t: number) => (+t ? t.toLocaleString() : '-'), + render: (t: number) => (+t || +t === 0 ? t.toLocaleString() : '-'), // TODO: 千分位展示 }, { title: 'Timestamp',