Skip to content

Commit 8346453

Browse files
authored
修复一些前端问题 (#1195)
请不要在没有先创建Issue的情况下创建Pull Request。 ## 变更的目的是什么 XXXXX ## 简短的更新日志 [[Optimize]Security、Consumer权限点更新 [BugFix]JMX端口维护信息错误 ## 验证这一变化 XXXX 请遵循此清单,以帮助我们快速轻松地整合您的贡献: * [ ] 一个 PR(Pull Request的简写)只解决一个问题,禁止一个 PR 解决多个问题; * [ ] 确保 PR 有对应的 Issue(通常在您开始处理之前创建),除非是书写错误之类的琐碎更改不需要 Issue ; * [ ] 格式化 PR 及 Commit-Log 的标题及内容,例如 #861 。PS:Commit-Log 需要在 Git Commit 代码时进行填写,在 GitHub 上修改不了; * [ ] 编写足够详细的 PR 描述,以了解 PR 的作用、方式和原因; * [ ] 编写必要的单元测试来验证您的逻辑更正。如果提交了新功能或重大更改,请记住在 test 模块中添加 integration-test; * [ ] 确保编译通过,集成测试通过;
2 parents 009ffeb + a9eb4ae commit 8346453

File tree

4 files changed

+77
-45
lines changed

4 files changed

+77
-45
lines changed

km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export enum ClustersPermissionMap {
3333
TOPIC_CANCEL_REPLICATOR = 'Topic-详情-取消Topic复制',
3434
// Consumers
3535
CONSUMERS_RESET_OFFSET = 'Consumers-重置Offset',
36+
GROUP_DELETE = 'Group-删除',
37+
GROUP_TOPIC_DELETE = 'GroupOffset-Topic纬度删除',
38+
GROUP_PARTITION_DELETE = 'GroupOffset-Partition纬度删除',
3639
// Test
3740
TEST_CONSUMER = 'Test-Consumer',
3841
TEST_PRODUCER = 'Test-Producer',
@@ -54,6 +57,7 @@ export enum ClustersPermissionMap {
5457
SECURITY_USER_ADD = 'Security-User新增',
5558
SECURITY_USER_DELETE = 'Security-User删除',
5659
SECURITY_USER_EDIT_PASSWORD = 'Security-User修改密码',
60+
SECURITY_USER_VIEW_PASSWORD = 'Security-User查看密码',
5761
}
5862

5963
export interface PermissionNode {

km-console/packages/layout-clusters-fe/src/pages/ConsumerGroup/config.tsx

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export const defaultPagination = {
2222
};
2323

2424
export const getGroupColumns = (arg?: any) => {
25-
const columns = [
25+
const [global] = AppContainer.useGlobalValue();
26+
const columns: any = [
2627
{
2728
title: 'ConsumerGroup',
2829
dataIndex: 'name',
@@ -63,7 +64,9 @@ export const getGroupColumns = (arg?: any) => {
6364
width: 200,
6465
render: (t: number) => (t ? t.toLocaleString() : '-'),
6566
},
66-
{
67+
];
68+
if (global.hasPermission && global.hasPermission(ClustersPermissionMap.GROUP_DELETE)) {
69+
columns.push({
6770
title: '操作',
6871
dataIndex: 'options',
6972
key: 'options',
@@ -77,8 +80,8 @@ export const getGroupColumns = (arg?: any) => {
7780
</div>
7881
);
7982
},
80-
},
81-
];
83+
});
84+
}
8285
return columns;
8386
};
8487

@@ -114,7 +117,7 @@ export const getGtoupTopicColumns = (arg?: any) => {
114117
render: (t: number) => (t ? t.toLocaleString() : '-'),
115118
},
116119
];
117-
if (global.hasPermission && global.hasPermission(ClustersPermissionMap.CONSUMERS_RESET_OFFSET)) {
120+
if (global.hasPermission) {
118121
columns.push({
119122
title: '操作',
120123
dataIndex: 'desc',
@@ -123,16 +126,24 @@ export const getGtoupTopicColumns = (arg?: any) => {
123126
render: (value: any, record: any) => {
124127
return (
125128
<div>
126-
<a onClick={() => arg.resetOffset(record)}>重置Offset</a>
127-
<Popconfirm
128-
placement="top"
129-
title={`是否要删除当前Topic?`}
130-
onConfirm={() => arg.deleteOffset(record)}
131-
okText="是"
132-
cancelText="否"
133-
>
134-
<Button type="link">删除</Button>
135-
</Popconfirm>
129+
{global.hasPermission(ClustersPermissionMap.CONSUMERS_RESET_OFFSET) ? (
130+
<a onClick={() => arg.resetOffset(record)}>重置Offset</a>
131+
) : (
132+
<></>
133+
)}
134+
{global.hasPermission(ClustersPermissionMap.GROUP_TOPIC_DELETE) ? (
135+
<Popconfirm
136+
placement="top"
137+
title={`是否要删除当前Topic?`}
138+
onConfirm={() => arg.deleteOffset(record)}
139+
okText="是"
140+
cancelText="否"
141+
>
142+
<Button type="link">删除</Button>
143+
</Popconfirm>
144+
) : (
145+
<></>
146+
)}
136147
</div>
137148
);
138149
},

km-console/packages/layout-clusters-fe/src/pages/MutliClusterPage/AccessCluster.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ const ConnectorForm = (props: {
537537
setSelectedTabKey(undefined);
538538
try {
539539
const jmxPortInfo = JSON.parse(initFieldsValue.jmxProperties) || {};
540-
form.setFieldsValue({ ...initFieldsValue, jmxProperties: jmxPortInfo.jmxProperties });
540+
form.setFieldsValue({ ...initFieldsValue, jmxProperties: jmxPortInfo.jmxPort });
541541
} catch {
542542
form.setFieldsValue({ ...initFieldsValue });
543543
}
@@ -546,7 +546,7 @@ const ConnectorForm = (props: {
546546
useLayoutEffect(() => {
547547
try {
548548
const jmxPortInfo = JSON.parse(initFieldsValue.jmxProperties) || {};
549-
form.setFieldsValue({ ...initFieldsValue, jmxProperties: jmxPortInfo.jmxProperties });
549+
form.setFieldsValue({ ...initFieldsValue, jmxProperties: jmxPortInfo.jmxPort });
550550
} catch {
551551
form.setFieldsValue({ ...initFieldsValue });
552552
}

km-console/packages/layout-clusters-fe/src/pages/SecurityUsers/index.tsx

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import api from '@src/api';
2323
import { useParams } from 'react-router-dom';
2424
import { regKafkaPassword } from '@src/constants/reg';
2525
import { tableHeaderPrefix } from '@src/constants/common';
26-
26+
import { ClustersPermissionMap } from '../CommonConfig';
2727
export const randomString = (len = 32, chars = 'abcdefghijklmnopqrstuvwxyz1234567890'): string => {
2828
const maxPos = chars.length;
2929
let str = '';
@@ -85,7 +85,7 @@ const PasswordContent = (props: { clusterId: string; name: string }) => {
8585
const { clusterId, name } = props;
8686
const [loading, setLoading] = useState(false);
8787
const [pw, setPw] = useState(initialShowPassword);
88-
88+
const [global] = AppContainer.useGlobalValue();
8989
const switchPwStatus = () => {
9090
if (!loading) {
9191
setLoading(true);
@@ -113,9 +113,13 @@ const PasswordContent = (props: { clusterId: string; name: string }) => {
113113
<Tooltip title={pw} placement="bottom">
114114
<div style={{ maxWidth: '80%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{pw}</div>
115115
</Tooltip>
116-
<span style={{ marginLeft: 6 }} onClick={switchPwStatus}>
117-
{loading ? <LoadingOutlined /> : pw === initialShowPassword ? <EyeInvisibleOutlined /> : <EyeOutlined />}
118-
</span>
116+
{global.hasPermission(ClustersPermissionMap.SECURITY_USER_VIEW_PASSWORD) ? (
117+
<span style={{ marginLeft: 6 }} onClick={switchPwStatus}>
118+
{loading ? <LoadingOutlined /> : pw === initialShowPassword ? <EyeInvisibleOutlined /> : <EyeOutlined />}
119+
</span>
120+
) : (
121+
<></>
122+
)}
119123
</div>
120124
);
121125
};
@@ -323,7 +327,7 @@ const SecurityUsers = (): JSX.Element => {
323327
};
324328

325329
const columns = () => {
326-
const baseColumns = [
330+
const baseColumns: any = [
327331
{
328332
title: 'KafkaUser',
329333
dataIndex: 'name',
@@ -348,30 +352,39 @@ const SecurityUsers = (): JSX.Element => {
348352
return <PasswordContent clusterId={clusterId} name={record.name} />;
349353
},
350354
},
351-
{
355+
];
356+
if (global.hasPermission) {
357+
baseColumns.push({
352358
title: '操作',
353359
dataIndex: '',
354360
width: 240,
355361
render(record: UsersProps) {
356362
return (
357363
<>
358-
<Button
359-
type="link"
360-
size="small"
361-
style={{ paddingLeft: 0 }}
362-
onClick={() => editDrawerRef.current.onOpen(true, UsersOperate.ChangePassword, getKafkaUserList, record)}
363-
>
364-
修改密码
365-
</Button>
366-
<Button type="link" size="small" onClick={() => onDelete(record)}>
367-
删除
368-
</Button>
364+
{global.hasPermission(ClustersPermissionMap.SECURITY_USER_EDIT_PASSWORD) ? (
365+
<Button
366+
type="link"
367+
size="small"
368+
style={{ paddingLeft: 0 }}
369+
onClick={() => editDrawerRef.current.onOpen(true, UsersOperate.ChangePassword, getKafkaUserList, record)}
370+
>
371+
修改密码
372+
</Button>
373+
) : (
374+
<></>
375+
)}
376+
{global.hasPermission(ClustersPermissionMap.SECURITY_USER_DELETE) ? (
377+
<Button type="link" size="small" onClick={() => onDelete(record)}>
378+
删除
379+
</Button>
380+
) : (
381+
<></>
382+
)}
369383
</>
370384
);
371385
},
372-
},
373-
];
374-
386+
});
387+
}
375388
return baseColumns;
376389
};
377390

@@ -454,13 +467,17 @@ const SecurityUsers = (): JSX.Element => {
454467
setSearchKeywordsInput(e.target.value);
455468
}}
456469
/>
457-
<Button
458-
type="primary"
459-
// icon={<PlusOutlined />}
460-
onClick={() => editDrawerRef.current.onOpen(true, UsersOperate.Add, getKafkaUserList)}
461-
>
462-
新增KafkaUser
463-
</Button>
470+
{global.hasPermission && global.hasPermission(ClustersPermissionMap.SECURITY_USER_ADD) ? (
471+
<Button
472+
type="primary"
473+
// icon={<PlusOutlined />}
474+
onClick={() => editDrawerRef.current.onOpen(true, UsersOperate.Add, getKafkaUserList)}
475+
>
476+
新增KafkaUser
477+
</Button>
478+
) : (
479+
<></>
480+
)}
464481
</div>
465482
</div>
466483

0 commit comments

Comments
 (0)