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
35 changes: 21 additions & 14 deletions km-console/packages/layout-clusters-fe/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -116,6 +117,8 @@ const AppContent = (props: { setlanguage: (language: string) => void }) => {
const userInfo = localStorage.getItem('userInfo');
const [curActiveAppName, setCurActiveAppName] = useState('');
const [versionInfo, setVersionInfo] = useState<VersionInfo>();
const [global] = AppContainer.useGlobalValue();
const quickEntries=[];

useEffect(() => {
if (pathname.startsWith('/config')) {
Expand All @@ -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 (
<DProLayout.Container
headerProps={{
Expand All @@ -142,20 +162,7 @@ const AppContent = (props: { setlanguage: (language: string) => void }) => {
),
username: userInfo ? JSON.parse(userInfo)?.userName : '',
icon: <DotChartOutlined />,
quickEntries: [
{
icon: <IconFont type="icon-duojiqunguanli" />,
txt: '多集群管理',
ident: '',
active: curActiveAppName === 'cluster',
},
{
icon: <IconFont type="icon-xitongguanli" />,
txt: '系统管理',
ident: 'config',
active: curActiveAppName === 'config',
},
],
quickEntries: quickEntries,
isFixed: false,
userDropMenuItems: [
<Menu.Item key={0}>
Expand Down
10 changes: 10 additions & 0 deletions km-console/packages/layout-clusters-fe/src/pages/CommonConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '删除集群',
Expand Down Expand Up @@ -88,6 +91,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 }));
Expand Down