mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 11:52:08 +08:00
[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 <hzsuzj@qq.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import { getLicenseInfo } from './constants/common';
|
|||||||
import api from './api';
|
import api from './api';
|
||||||
import ClusterContainer from './pages/index';
|
import ClusterContainer from './pages/index';
|
||||||
import ksLogo from './assets/ks-logo.png';
|
import ksLogo from './assets/ks-logo.png';
|
||||||
|
import {ClustersPermissionMap} from "./pages/CommonConfig";
|
||||||
|
|
||||||
interface ILocaleMap {
|
interface ILocaleMap {
|
||||||
[index: string]: any;
|
[index: string]: any;
|
||||||
@@ -116,6 +117,8 @@ const AppContent = (props: { setlanguage: (language: string) => void }) => {
|
|||||||
const userInfo = localStorage.getItem('userInfo');
|
const userInfo = localStorage.getItem('userInfo');
|
||||||
const [curActiveAppName, setCurActiveAppName] = useState('');
|
const [curActiveAppName, setCurActiveAppName] = useState('');
|
||||||
const [versionInfo, setVersionInfo] = useState<VersionInfo>();
|
const [versionInfo, setVersionInfo] = useState<VersionInfo>();
|
||||||
|
const [global] = AppContainer.useGlobalValue();
|
||||||
|
const quickEntries=[];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (pathname.startsWith('/config')) {
|
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: <IconFont type="icon-duojiqunguanli"/>,
|
||||||
|
txt: '多集群管理',
|
||||||
|
ident: '',
|
||||||
|
active: curActiveAppName === 'cluster',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (global.hasPermission && global.hasPermission(ClustersPermissionMap.SYS_MANAGE_VIEW)){
|
||||||
|
quickEntries.push({
|
||||||
|
icon: <IconFont type="icon-xitongguanli" />,
|
||||||
|
txt: '系统管理',
|
||||||
|
ident: 'config',
|
||||||
|
active: curActiveAppName === 'config',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DProLayout.Container
|
<DProLayout.Container
|
||||||
headerProps={{
|
headerProps={{
|
||||||
@@ -142,20 +162,7 @@ const AppContent = (props: { setlanguage: (language: string) => void }) => {
|
|||||||
),
|
),
|
||||||
username: userInfo ? JSON.parse(userInfo)?.userName : '',
|
username: userInfo ? JSON.parse(userInfo)?.userName : '',
|
||||||
icon: <DotChartOutlined />,
|
icon: <DotChartOutlined />,
|
||||||
quickEntries: [
|
quickEntries: quickEntries,
|
||||||
{
|
|
||||||
icon: <IconFont type="icon-duojiqunguanli" />,
|
|
||||||
txt: '多集群管理',
|
|
||||||
ident: '',
|
|
||||||
active: curActiveAppName === 'cluster',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: <IconFont type="icon-xitongguanli" />,
|
|
||||||
txt: '系统管理',
|
|
||||||
ident: 'config',
|
|
||||||
active: curActiveAppName === 'config',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
isFixed: false,
|
isFixed: false,
|
||||||
userDropMenuItems: [
|
userDropMenuItems: [
|
||||||
<Menu.Item key={0}>
|
<Menu.Item key={0}>
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import { goLogin } from '@src/constants/axiosConfig';
|
|||||||
export enum ClustersPermissionMap {
|
export enum ClustersPermissionMap {
|
||||||
CLUSTERS_MANAGE = '多集群管理',
|
CLUSTERS_MANAGE = '多集群管理',
|
||||||
CLUSTERS_MANAGE_VIEW = '多集群管理查看',
|
CLUSTERS_MANAGE_VIEW = '多集群管理查看',
|
||||||
|
//仅用作隐藏掉系统管理菜单
|
||||||
|
SYS_MANAGE = '系统管理',
|
||||||
|
SYS_MANAGE_VIEW = '系统管理查看',
|
||||||
// Cluster
|
// Cluster
|
||||||
CLUSTER_ADD = '接入集群',
|
CLUSTER_ADD = '接入集群',
|
||||||
CLUSTER_DEL = '删除集群',
|
CLUSTER_DEL = '删除集群',
|
||||||
@@ -94,6 +97,13 @@ const CommonConfig = () => {
|
|||||||
clustersPermissions &&
|
clustersPermissions &&
|
||||||
clustersPermissions.childList.forEach((node: PermissionNode) => node.has && userPermissions.push(node.permissionName));
|
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);
|
const hasPermission = (permissionName: ClustersPermissionMap) => permissionName && userPermissions.includes(permissionName);
|
||||||
|
|
||||||
setGlobal((curState: any) => ({ ...curState, permissions: allPermissions, userPermissions, hasPermission, userInfo }));
|
setGlobal((curState: any) => ({ ...curState, permissions: allPermissions, userPermissions, hasPermission, userInfo }));
|
||||||
|
|||||||
Reference in New Issue
Block a user