From 59e8a416b56a1978980fa67f7ec1f93064675b12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=88=B1=E5=96=9D=E8=8D=AF=E7=9A=84=E5=A4=A7=E9=83=8E?=
<43955116+HZSUZJ@users.noreply.github.com>
Date: Fri, 20 Oct 2023 09:32:31 +0800
Subject: [PATCH] =?UTF-8?q?[Bugfix]=E4=BF=AE=E5=A4=8D=E6=9C=AA=E5=8B=BE?=
=?UTF-8?q?=E9=80=89=E7=B3=BB=E7=BB=9F=E7=AE=A1=E7=90=86=E6=9F=A5=E7=9C=8B?=
=?UTF-8?q?=E6=9D=83=E9=99=90=EF=BC=8C=E4=BD=86=E6=98=AF=E4=BE=9D=E7=84=B6?=
=?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=9F=A5=E7=9C=8B=E7=B3=BB=E7=BB=9F=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E7=9A=84=E9=97=AE=E9=A2=98=20(#1105)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
请不要在没有先创建Issue的情况下创建Pull Request。
## 变更的目的是什么
修复未勾选系统管理查看权限,但是依然可以查看系统管理的问题
## 简短的更新日志
修复未勾选系统管理查看权限,但是依然可以查看系统管理的问题
## 验证这一变化
### 权限表
### 效果
请遵循此清单,以帮助我们快速轻松地整合您的贡献:
* [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
---
.../packages/layout-clusters-fe/src/app.tsx | 35 +++++++++++--------
.../src/pages/CommonConfig.tsx | 10 ++++++
2 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/km-console/packages/layout-clusters-fe/src/app.tsx b/km-console/packages/layout-clusters-fe/src/app.tsx
index b945a9c08..4df691ebd 100755
--- a/km-console/packages/layout-clusters-fe/src/app.tsx
+++ b/km-console/packages/layout-clusters-fe/src/app.tsx
@@ -20,6 +20,7 @@ import { getLicenseInfo } from './constants/common';
import api from './api';
import ClusterContainer from './pages/index';
import ksLogo from './assets/ks-logo.png';
+import {ClustersPermissionMap} from "./pages/CommonConfig";
interface ILocaleMap {
[index: string]: any;
@@ -116,6 +117,8 @@ const AppContent = (props: { setlanguage: (language: string) => void }) => {
const userInfo = localStorage.getItem('userInfo');
const [curActiveAppName, setCurActiveAppName] = useState('');
const [versionInfo, setVersionInfo] = useState();
+ const [global] = AppContainer.useGlobalValue();
+ const quickEntries=[];
useEffect(() => {
if (pathname.startsWith('/config')) {
@@ -132,6 +135,23 @@ const AppContent = (props: { setlanguage: (language: string) => void }) => {
});
}, []);
+ if (global.hasPermission && global.hasPermission(ClustersPermissionMap.CLUSTERS_MANAGE_VIEW)){
+ quickEntries.push({
+ icon: ,
+ txt: '多集群管理',
+ ident: '',
+ active: curActiveAppName === 'cluster',
+ });
+ }
+ if (global.hasPermission && global.hasPermission(ClustersPermissionMap.SYS_MANAGE_VIEW)){
+ quickEntries.push({
+ icon: ,
+ txt: '系统管理',
+ ident: 'config',
+ active: curActiveAppName === 'config',
+ });
+ }
+
return (
void }) => {
),
username: userInfo ? JSON.parse(userInfo)?.userName : '',
icon: ,
- quickEntries: [
- {
- icon: ,
- txt: '多集群管理',
- ident: '',
- active: curActiveAppName === 'cluster',
- },
- {
- icon: ,
- txt: '系统管理',
- ident: 'config',
- active: curActiveAppName === 'config',
- },
- ],
+ quickEntries: quickEntries,
isFixed: false,
userDropMenuItems: [
diff --git a/km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx b/km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx
index 712e98fc8..722d04e67 100644
--- a/km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx
+++ b/km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx
@@ -7,6 +7,9 @@ import { goLogin } from '@src/constants/axiosConfig';
export enum ClustersPermissionMap {
CLUSTERS_MANAGE = '多集群管理',
CLUSTERS_MANAGE_VIEW = '多集群管理查看',
+ //仅用作隐藏掉系统管理菜单
+ SYS_MANAGE = '系统管理',
+ SYS_MANAGE_VIEW = '系统管理查看',
// Cluster
CLUSTER_ADD = '接入集群',
CLUSTER_DEL = '删除集群',
@@ -94,6 +97,13 @@ const CommonConfig = () => {
clustersPermissions &&
clustersPermissions.childList.forEach((node: PermissionNode) => node.has && userPermissions.push(node.permissionName));
+ // 获取用户在系统管理拥有的权限
+ const configPermissions = userPermissionTree.find(
+ (sys: PermissionNode) => sys.permissionName === ClustersPermissionMap.SYS_MANAGE
+ );
+ configPermissions &&
+ configPermissions.childList.forEach((node: PermissionNode) => node.has && userPermissions.push(node.permissionName));
+
const hasPermission = (permissionName: ClustersPermissionMap) => permissionName && userPermissions.includes(permissionName);
setGlobal((curState: any) => ({ ...curState, permissions: allPermissions, userPermissions, hasPermission, userInfo }));