Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -105,7 +106,7 @@ const SecurityACLs = (): JSX.Element => {
};

const columns = () => {
const baseColumns = [
const baseColumns: any = [
{
title: 'Principal',
dataIndex: 'kafkaUser',
Expand Down Expand Up @@ -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,
Expand All @@ -156,8 +159,8 @@ const SecurityACLs = (): JSX.Element => {
</>
);
},
},
];
});
}

return baseColumns;
};
Expand Down Expand Up @@ -238,15 +241,19 @@ const SecurityACLs = (): JSX.Element => {
</Form.Item>
</Form>
</div>
<div className={`${tableHeaderPrefix}-right`}>
<Button
type="primary"
// icon={<PlusOutlined />}
onClick={() => editDrawerRef.current.onOpen(true, getACLs)}
>
新增ACL
</Button>
</div>
{global.hasPermission && global.hasPermission(ClustersPermissionMap.SECURITY_ACL_ADD) ? (
<div className={`${tableHeaderPrefix}-right`}>
<Button
type="primary"
// icon={<PlusOutlined />}
onClick={() => editDrawerRef.current.onOpen(true, getACLs)}
>
新增ACL
</Button>
</div>
) : (
<></>
)}
</div>
<ProTable
tableProps={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import api from '@src/api';
import { useParams } from 'react-router-dom';
import { regKafkaPassword } from '@src/constants/reg';
import { tableHeaderPrefix } from '@src/constants/common';

import { ClustersPermissionMap } from '../CommonConfig';
export const randomString = (len = 32, chars = 'abcdefghijklmnopqrstuvwxyz1234567890'): string => {
const maxPos = chars.length;
let str = '';
Expand Down Expand Up @@ -323,7 +323,7 @@ const SecurityUsers = (): JSX.Element => {
};

const columns = () => {
const baseColumns = [
const baseColumns: any = [
{
title: 'KafkaUser',
dataIndex: 'name',
Expand All @@ -348,30 +348,39 @@ const SecurityUsers = (): JSX.Element => {
return <PasswordContent clusterId={clusterId} name={record.name} />;
},
},
{
];
if (global.hasPermission) {
baseColumns.push({
title: '操作',
dataIndex: '',
width: 240,
render(record: UsersProps) {
return (
<>
<Button
type="link"
size="small"
style={{ paddingLeft: 0 }}
onClick={() => editDrawerRef.current.onOpen(true, UsersOperate.ChangePassword, getKafkaUserList, record)}
>
修改密码
</Button>
<Button type="link" size="small" onClick={() => onDelete(record)}>
删除
</Button>
{global.hasPermission(ClustersPermissionMap.SECURITY_USER_EDIT_PASSWORD) ? (
<Button
type="link"
size="small"
style={{ paddingLeft: 0 }}
onClick={() => editDrawerRef.current.onOpen(true, UsersOperate.ChangePassword, getKafkaUserList, record)}
>
修改密码
</Button>
) : (
<></>
)}
{global.hasPermission(ClustersPermissionMap.SECURITY_USER_DELETE) ? (
<Button type="link" size="small" onClick={() => onDelete(record)}>
删除
</Button>
) : (
<></>
)}
</>
);
},
},
];

});
}
return baseColumns;
};

Expand Down Expand Up @@ -454,13 +463,17 @@ const SecurityUsers = (): JSX.Element => {
setSearchKeywordsInput(e.target.value);
}}
/>
<Button
type="primary"
// icon={<PlusOutlined />}
onClick={() => editDrawerRef.current.onOpen(true, UsersOperate.Add, getKafkaUserList)}
>
新增KafkaUser
</Button>
{global.hasPermission && global.hasPermission(ClustersPermissionMap.SECURITY_USER_ADD) ? (
<Button
type="primary"
// icon={<PlusOutlined />}
onClick={() => editDrawerRef.current.onOpen(true, UsersOperate.Add, getKafkaUserList)}
>
新增KafkaUser
</Button>
) : (
<></>
)}
</div>
</div>

Expand Down