Skip to content

Commit 59e8a41

Browse files
HZSUZJsuzj
andauthored
[Bugfix]修复未勾选系统管理查看权限,但是依然可以查看系统管理的问题 (#1105)
请不要在没有先创建Issue的情况下创建Pull Request。 ## 变更的目的是什么 修复未勾选系统管理查看权限,但是依然可以查看系统管理的问题 ## 简短的更新日志 修复未勾选系统管理查看权限,但是依然可以查看系统管理的问题 ## 验证这一变化 ### 权限表 <img width="587" alt="image" src="https://github.com/didi/KnowStreaming/assets/43955116/497fea54-3216-4ae7-8dab-304a07e81209"> ### 效果 <img width="1500" alt="image" src="https://github.com/didi/KnowStreaming/assets/43955116/1e4a8260-336e-4c15-a244-5f768107a990"> 请遵循此清单,以帮助我们快速轻松地整合您的贡献: * [x] 一个 PR(Pull Request的简写)只解决一个问题,禁止一个 PR 解决多个问题; * [x] 确保 PR 有对应的 Issue(通常在您开始处理之前创建),除非是书写错误之类的琐碎更改不需要 Issue ; * [x] 格式化 PR 及 Commit-Log 的标题及内容,例如 #861 。PS:Commit-Log 需要在 Git Commit 代码时进行填写,在 GitHub 上修改不了; * [x] 编写足够详细的 PR 描述,以了解 PR 的作用、方式和原因; * [x] 编写必要的单元测试来验证您的逻辑更正。如果提交了新功能或重大更改,请记住在 test 模块中添加 integration-test; * [x] 确保编译通过,集成测试通过; Co-authored-by: suzj <[email protected]>
1 parent f6becbd commit 59e8a41

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

km-console/packages/layout-clusters-fe/src/app.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { getLicenseInfo } from './constants/common';
2020
import api from './api';
2121
import ClusterContainer from './pages/index';
2222
import ksLogo from './assets/ks-logo.png';
23+
import {ClustersPermissionMap} from "./pages/CommonConfig";
2324

2425
interface ILocaleMap {
2526
[index: string]: any;
@@ -116,6 +117,8 @@ const AppContent = (props: { setlanguage: (language: string) => void }) => {
116117
const userInfo = localStorage.getItem('userInfo');
117118
const [curActiveAppName, setCurActiveAppName] = useState('');
118119
const [versionInfo, setVersionInfo] = useState<VersionInfo>();
120+
const [global] = AppContainer.useGlobalValue();
121+
const quickEntries=[];
119122

120123
useEffect(() => {
121124
if (pathname.startsWith('/config')) {
@@ -132,6 +135,23 @@ const AppContent = (props: { setlanguage: (language: string) => void }) => {
132135
});
133136
}, []);
134137

138+
if (global.hasPermission && global.hasPermission(ClustersPermissionMap.CLUSTERS_MANAGE_VIEW)){
139+
quickEntries.push({
140+
icon: <IconFont type="icon-duojiqunguanli"/>,
141+
txt: '多集群管理',
142+
ident: '',
143+
active: curActiveAppName === 'cluster',
144+
});
145+
}
146+
if (global.hasPermission && global.hasPermission(ClustersPermissionMap.SYS_MANAGE_VIEW)){
147+
quickEntries.push({
148+
icon: <IconFont type="icon-xitongguanli" />,
149+
txt: '系统管理',
150+
ident: 'config',
151+
active: curActiveAppName === 'config',
152+
});
153+
}
154+
135155
return (
136156
<DProLayout.Container
137157
headerProps={{
@@ -142,20 +162,7 @@ const AppContent = (props: { setlanguage: (language: string) => void }) => {
142162
),
143163
username: userInfo ? JSON.parse(userInfo)?.userName : '',
144164
icon: <DotChartOutlined />,
145-
quickEntries: [
146-
{
147-
icon: <IconFont type="icon-duojiqunguanli" />,
148-
txt: '多集群管理',
149-
ident: '',
150-
active: curActiveAppName === 'cluster',
151-
},
152-
{
153-
icon: <IconFont type="icon-xitongguanli" />,
154-
txt: '系统管理',
155-
ident: 'config',
156-
active: curActiveAppName === 'config',
157-
},
158-
],
165+
quickEntries: quickEntries,
159166
isFixed: false,
160167
userDropMenuItems: [
161168
<Menu.Item key={0}>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { goLogin } from '@src/constants/axiosConfig';
77
export enum ClustersPermissionMap {
88
CLUSTERS_MANAGE = '多集群管理',
99
CLUSTERS_MANAGE_VIEW = '多集群管理查看',
10+
//仅用作隐藏掉系统管理菜单
11+
SYS_MANAGE = '系统管理',
12+
SYS_MANAGE_VIEW = '系统管理查看',
1013
// Cluster
1114
CLUSTER_ADD = '接入集群',
1215
CLUSTER_DEL = '删除集群',
@@ -94,6 +97,13 @@ const CommonConfig = () => {
9497
clustersPermissions &&
9598
clustersPermissions.childList.forEach((node: PermissionNode) => node.has && userPermissions.push(node.permissionName));
9699

100+
// 获取用户在系统管理拥有的权限
101+
const configPermissions = userPermissionTree.find(
102+
(sys: PermissionNode) => sys.permissionName === ClustersPermissionMap.SYS_MANAGE
103+
);
104+
configPermissions &&
105+
configPermissions.childList.forEach((node: PermissionNode) => node.has && userPermissions.push(node.permissionName));
106+
97107
const hasPermission = (permissionName: ClustersPermissionMap) => permissionName && userPermissions.includes(permissionName);
98108

99109
setGlobal((curState: any) => ({ ...curState, permissions: allPermissions, userPermissions, hasPermission, userInfo }));

0 commit comments

Comments
 (0)