mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 11:52:08 +08:00
[Optimize]Connect操作未接入权限管理,所有用户都可以重启、编辑、删除(#1050)
This commit is contained in:
@@ -39,6 +39,12 @@ export enum ClustersPermissionMap {
|
|||||||
MM2_DELETE = 'MM2-删除',
|
MM2_DELETE = 'MM2-删除',
|
||||||
MM2_RESTART = 'MM2-重启',
|
MM2_RESTART = 'MM2-重启',
|
||||||
MM2_STOP_RESUME = '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 {
|
export interface PermissionNode {
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import SmallChart from '@src/components/SmallChart';
|
import SmallChart from '@src/components/SmallChart';
|
||||||
import TagsWithHide from '@src/components/TagsWithHide';
|
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 React from 'react';
|
||||||
import Delete from './Delete';
|
import Delete from './Delete';
|
||||||
|
import { ClustersPermissionMap } from '../CommonConfig';
|
||||||
export const defaultPagination = {
|
export const defaultPagination = {
|
||||||
current: 1,
|
current: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
@@ -93,7 +94,8 @@ const renderLine = (record: any, metricName: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getConnectorsColumns = (arg?: any) => {
|
export const getConnectorsColumns = (arg?: any) => {
|
||||||
const columns = [
|
const [global] = AppContainer.useGlobalValue();
|
||||||
|
const columns: any = [
|
||||||
{
|
{
|
||||||
title: 'Connector Name',
|
title: 'Connector Name',
|
||||||
dataIndex: 'connectorName',
|
dataIndex: 'connectorName',
|
||||||
@@ -213,7 +215,10 @@ export const getConnectorsColumns = (arg?: any) => {
|
|||||||
return t && t.length > 0 ? <TagsWithHide placement="bottom" list={t} expandTagContent={(num: any) => `共有${num}个`} /> : '-';
|
return t && t.length > 0 ? <TagsWithHide placement="bottom" list={t} expandTagContent={(num: any) => `共有${num}个`} /> : '-';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (global.hasPermission) {
|
||||||
|
columns.push({
|
||||||
title: '操作',
|
title: '操作',
|
||||||
dataIndex: 'options',
|
dataIndex: 'options',
|
||||||
key: 'options',
|
key: 'options',
|
||||||
@@ -224,20 +229,24 @@ export const getConnectorsColumns = (arg?: any) => {
|
|||||||
render: (_t: any, r: any) => {
|
render: (_t: any, r: any) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Popconfirm
|
{global.hasPermission(ClustersPermissionMap.CONNECTOR_RESTART) ? (
|
||||||
title="是否重启当前任务?"
|
<Popconfirm
|
||||||
onConfirm={() => arg?.optionConnect(r, 'restart')}
|
title="是否重启当前任务?"
|
||||||
// onCancel={cancel}
|
onConfirm={() => arg?.optionConnect(r, 'restart')}
|
||||||
okText="是"
|
// onCancel={cancel}
|
||||||
cancelText="否"
|
okText="是"
|
||||||
overlayClassName="connect-popconfirm"
|
cancelText="否"
|
||||||
>
|
overlayClassName="connect-popconfirm"
|
||||||
<Button key="restart" type="link" size="small">
|
>
|
||||||
重启
|
<Button key="restart" type="link" size="small">
|
||||||
</Button>
|
重启
|
||||||
</Popconfirm>
|
</Button>
|
||||||
|
</Popconfirm>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
|
||||||
{(r.state === 'RUNNING' || r.state === 'PAUSED') && (
|
{global.hasPermission(ClustersPermissionMap.CONNECTOR_STOP_RESUME) && (r.state === 'RUNNING' || r.state === 'PAUSED') && (
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title={`是否${r.state === 'RUNNING' ? '暂停' : '继续'}当前任务?`}
|
title={`是否${r.state === 'RUNNING' ? '暂停' : '继续'}当前任务?`}
|
||||||
onConfirm={() => arg?.optionConnect(r, r.state === 'RUNNING' ? 'stop' : 'resume')}
|
onConfirm={() => arg?.optionConnect(r, r.state === 'RUNNING' ? 'stop' : 'resume')}
|
||||||
@@ -252,16 +261,24 @@ export const getConnectorsColumns = (arg?: any) => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Popconfirm>
|
</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)}>
|
{global.hasPermission(ClustersPermissionMap.CONNECTOR_DELETE) ? (
|
||||||
编辑
|
<Delete record={r} onConfirm={arg?.deleteTesk}></Delete>
|
||||||
</Button>
|
) : (
|
||||||
<Delete record={r} onConfirm={arg?.deleteTesk}></Delete>
|
<></>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
return columns;
|
return columns;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import notification from '@src/components/Notification';
|
|||||||
import './index.less';
|
import './index.less';
|
||||||
import AddConnectorUseJSON from './AddConnectorUseJSON';
|
import AddConnectorUseJSON from './AddConnectorUseJSON';
|
||||||
import HasConnector from './HasConnector';
|
import HasConnector from './HasConnector';
|
||||||
|
import { ClustersPermissionMap } from '../CommonConfig';
|
||||||
const { request } = Utils;
|
const { request } = Utils;
|
||||||
|
|
||||||
const rateMap: any = {
|
const rateMap: any = {
|
||||||
@@ -174,21 +175,25 @@ const Connectors: React.FC = () => {
|
|||||||
maxLength: 128,
|
maxLength: 128,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<span className="add-connect">
|
{global.hasPermission && global.hasPermission(ClustersPermissionMap.CONNECTOR_ADD) ? (
|
||||||
<Button
|
<span className="add-connect">
|
||||||
className="add-connect-btn"
|
<Button
|
||||||
icon={<IconFont type="icon-jiahao" />}
|
className="add-connect-btn"
|
||||||
type="primary"
|
icon={<IconFont type="icon-jiahao" />}
|
||||||
onClick={() => addConnectorRef.current?.onOpen('create', addConnectorJsonRef.current)}
|
type="primary"
|
||||||
>
|
onClick={() => addConnectorRef.current?.onOpen('create', addConnectorJsonRef.current)}
|
||||||
新增Connector
|
>
|
||||||
</Button>
|
新增Connector
|
||||||
<Dropdown overlayClassName="add-connect-dropdown-menu" overlay={menu}>
|
|
||||||
<Button className="add-connect-json" type="primary">
|
|
||||||
<IconFont type="icon-guanwangxiala" />
|
|
||||||
</Button>
|
</Button>
|
||||||
</Dropdown>
|
<Dropdown overlayClassName="add-connect-dropdown-menu" overlay={menu}>
|
||||||
</span>
|
<Button className="add-connect-json" type="primary">
|
||||||
|
<IconFont type="icon-guanwangxiala" />
|
||||||
|
</Button>
|
||||||
|
</Dropdown>
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ProTable
|
<ProTable
|
||||||
|
|||||||
Reference in New Issue
Block a user