From 1a42472fd830307f6fd39ee068cb7d5528b06200 Mon Sep 17 00:00:00 2001 From: erge Date: Sun, 10 Sep 2023 17:17:20 +0800 Subject: [PATCH] =?UTF-8?q?[Optimize]Connect=E6=93=8D=E4=BD=9C=E6=9C=AA?= =?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/CommonConfig.tsx | 6 ++ .../src/pages/Connect/config.tsx | 61 ++++++++++++------- .../src/pages/Connect/index.tsx | 33 +++++----- 3 files changed, 64 insertions(+), 36 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 4d01da97..712e98fc 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx @@ -39,6 +39,12 @@ export enum ClustersPermissionMap { MM2_DELETE = 'MM2-删除', MM2_RESTART = 'MM2-重启', MM2_STOP_RESUME = 'MM2-暂停&恢复', + // Connector + CONNECTOR_ADD = 'Connector-新增', + CONNECTOR_CHANGE_CONFIG = 'Connector-编辑', + CONNECTOR_DELETE = 'Connector-删除', + CONNECTOR_RESTART = 'Connector-重启', + CONNECTOR_STOP_RESUME = 'Connector-暂停&恢复', } export interface PermissionNode { 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 67691d74..84c2b519 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 @@ -1,8 +1,9 @@ import SmallChart from '@src/components/SmallChart'; import TagsWithHide from '@src/components/TagsWithHide'; -import { Button, Tag, Tooltip, Utils, Popconfirm } from 'knowdesign'; +import { Button, Tag, Tooltip, Utils, Popconfirm, AppContainer } from 'knowdesign'; import React from 'react'; import Delete from './Delete'; +import { ClustersPermissionMap } from '../CommonConfig'; export const defaultPagination = { current: 1, pageSize: 10, @@ -93,7 +94,8 @@ const renderLine = (record: any, metricName: string) => { }; export const getConnectorsColumns = (arg?: any) => { - const columns = [ + const [global] = AppContainer.useGlobalValue(); + const columns: any = [ { title: 'Connector Name', dataIndex: 'connectorName', @@ -213,7 +215,10 @@ export const getConnectorsColumns = (arg?: any) => { return t && t.length > 0 ? `共有${num}个`} /> : '-'; }, }, - { + ]; + + if (global.hasPermission) { + columns.push({ title: '操作', dataIndex: 'options', key: 'options', @@ -224,20 +229,24 @@ export const getConnectorsColumns = (arg?: any) => { render: (_t: any, r: any) => { return (
- arg?.optionConnect(r, 'restart')} - // onCancel={cancel} - okText="是" - cancelText="否" - overlayClassName="connect-popconfirm" - > - - + {global.hasPermission(ClustersPermissionMap.CONNECTOR_RESTART) ? ( + arg?.optionConnect(r, 'restart')} + // onCancel={cancel} + okText="是" + cancelText="否" + overlayClassName="connect-popconfirm" + > + + + ) : ( + <> + )} - {(r.state === 'RUNNING' || r.state === 'PAUSED') && ( + {global.hasPermission(ClustersPermissionMap.CONNECTOR_STOP_RESUME) && (r.state === 'RUNNING' || r.state === 'PAUSED') && ( arg?.optionConnect(r, r.state === 'RUNNING' ? 'stop' : 'resume')} @@ -252,16 +261,24 @@ export const getConnectorsColumns = (arg?: any) => { )} + {global.hasPermission(ClustersPermissionMap.CONNECTOR_CHANGE_CONFIG) ? ( + + ) : ( + <> + )} - - + {global.hasPermission(ClustersPermissionMap.CONNECTOR_DELETE) ? ( + + ) : ( + <> + )}
); }, - }, - ]; + }); + } return columns; }; diff --git a/km-console/packages/layout-clusters-fe/src/pages/Connect/index.tsx b/km-console/packages/layout-clusters-fe/src/pages/Connect/index.tsx index 4c8dbb88..e07a047a 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/Connect/index.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/Connect/index.tsx @@ -12,6 +12,7 @@ import notification from '@src/components/Notification'; import './index.less'; import AddConnectorUseJSON from './AddConnectorUseJSON'; import HasConnector from './HasConnector'; +import { ClustersPermissionMap } from '../CommonConfig'; const { request } = Utils; const rateMap: any = { @@ -174,21 +175,25 @@ const Connectors: React.FC = () => { maxLength: 128, }} /> - - - - - - + + + + + ) : ( + <> + )}