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, }} /> - - - - - - + + + + + ) : ( + <> + )}