Skip to content

Commit

Permalink
[Optimize]Connect操作未接入权限管理,所有用户都可以重启、编辑、删除(#1050) (#1147)
Browse files Browse the repository at this point in the history
请不要在没有先创建Issue的情况下创建Pull Request。

## 变更的目的是什么

XXXXX

## 简短的更新日志

XX

## 验证这一变化

XXXX

请遵循此清单,以帮助我们快速轻松地整合您的贡献:

* [ ] 一个 PR(Pull Request的简写)只解决一个问题,禁止一个 PR 解决多个问题;
* [ ] 确保 PR 有对应的 Issue(通常在您开始处理之前创建),除非是书写错误之类的琐碎更改不需要 Issue ;
* [ ] 格式化 PR 及 Commit-Log 的标题及内容,例如 #861 。PS:Commit-Log 需要在 Git Commit
代码时进行填写,在 GitHub 上修改不了;
* [ ] 编写足够详细的 PR 描述,以了解 PR 的作用、方式和原因;
* [ ] 编写必要的单元测试来验证您的逻辑更正。如果提交了新功能或重大更改,请记住在 test 模块中添加 integration-test;
* [ ] 确保编译通过,集成测试通过;
  • Loading branch information
lucasun authored Sep 14, 2023
2 parents ae04ffd + 1a42472 commit e2ad3af
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
61 changes: 39 additions & 22 deletions km-console/packages/layout-clusters-fe/src/pages/Connect/config.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -213,7 +215,10 @@ export const getConnectorsColumns = (arg?: any) => {
return t && t.length > 0 ? <TagsWithHide placement="bottom" list={t} expandTagContent={(num: any) => `共有${num}个`} /> : '-';
},
},
{
];

if (global.hasPermission) {
columns.push({
title: '操作',
dataIndex: 'options',
key: 'options',
Expand All @@ -224,20 +229,24 @@ export const getConnectorsColumns = (arg?: any) => {
render: (_t: any, r: any) => {
return (
<div>
<Popconfirm
title="是否重启当前任务?"
onConfirm={() => arg?.optionConnect(r, 'restart')}
// onCancel={cancel}
okText="是"
cancelText="否"
overlayClassName="connect-popconfirm"
>
<Button key="restart" type="link" size="small">
重启
</Button>
</Popconfirm>
{global.hasPermission(ClustersPermissionMap.CONNECTOR_RESTART) ? (
<Popconfirm
title="是否重启当前任务?"
onConfirm={() => arg?.optionConnect(r, 'restart')}
// onCancel={cancel}
okText="是"
cancelText="否"
overlayClassName="connect-popconfirm"
>
<Button key="restart" type="link" size="small">
重启
</Button>
</Popconfirm>
) : (
<></>
)}

{(r.state === 'RUNNING' || r.state === 'PAUSED') && (
{global.hasPermission(ClustersPermissionMap.CONNECTOR_STOP_RESUME) && (r.state === 'RUNNING' || r.state === 'PAUSED') && (
<Popconfirm
title={`是否${r.state === 'RUNNING' ? '暂停' : '继续'}当前任务?`}
onConfirm={() => arg?.optionConnect(r, r.state === 'RUNNING' ? 'stop' : 'resume')}
Expand All @@ -252,16 +261,24 @@ export const getConnectorsColumns = (arg?: any) => {
</Button>
</Popconfirm>
)}
{global.hasPermission(ClustersPermissionMap.CONNECTOR_CHANGE_CONFIG) ? (
<Button type="link" size="small" onClick={() => arg?.editConnector(r)}>
编辑
</Button>
) : (
<></>
)}

<Button type="link" size="small" onClick={() => arg?.editConnector(r)}>
编辑
</Button>
<Delete record={r} onConfirm={arg?.deleteTesk}></Delete>
{global.hasPermission(ClustersPermissionMap.CONNECTOR_DELETE) ? (
<Delete record={r} onConfirm={arg?.deleteTesk}></Delete>
) : (
<></>
)}
</div>
);
},
},
];
});
}
return columns;
};

Expand Down
33 changes: 19 additions & 14 deletions km-console/packages/layout-clusters-fe/src/pages/Connect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -174,21 +175,25 @@ const Connectors: React.FC = () => {
maxLength: 128,
}}
/>
<span className="add-connect">
<Button
className="add-connect-btn"
icon={<IconFont type="icon-jiahao" />}
type="primary"
onClick={() => addConnectorRef.current?.onOpen('create', addConnectorJsonRef.current)}
>
新增Connector
</Button>
<Dropdown overlayClassName="add-connect-dropdown-menu" overlay={menu}>
<Button className="add-connect-json" type="primary">
<IconFont type="icon-guanwangxiala" />
{global.hasPermission && global.hasPermission(ClustersPermissionMap.CONNECTOR_ADD) ? (
<span className="add-connect">
<Button
className="add-connect-btn"
icon={<IconFont type="icon-jiahao" />}
type="primary"
onClick={() => addConnectorRef.current?.onOpen('create', addConnectorJsonRef.current)}
>
新增Connector
</Button>
</Dropdown>
</span>
<Dropdown overlayClassName="add-connect-dropdown-menu" overlay={menu}>
<Button className="add-connect-json" type="primary">
<IconFont type="icon-guanwangxiala" />
</Button>
</Dropdown>
</span>
) : (
<></>
)}
</div>
</div>
<ProTable
Expand Down

0 comments on commit e2ad3af

Please sign in to comment.