github.com/minio/console@v1.4.1/web-app/src/screens/Console/Menu/MenuWrapper.tsx (about) 1 // This file is part of MinIO Console Server 2 // Copyright (c) 2023 MinIO, Inc. 3 // 4 // This program is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Affero General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Affero General Public License for more details. 13 // 14 // You should have received a copy of the GNU Affero General Public License 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17 import React from "react"; 18 import { useSelector } from "react-redux"; 19 import { Menu } from "mds"; 20 import { AppState, useAppDispatch } from "../../../store"; 21 import { validRoutes } from "../valid-routes"; 22 import { menuOpen } from "../../../systemSlice"; 23 import { selFeatures } from "../consoleSlice"; 24 import { getLogoVar, registeredCluster } from "../../../config"; 25 import { useLocation, useNavigate } from "react-router-dom"; 26 import { getLicenseConsent } from "../License/utils"; 27 28 const MenuWrapper = () => { 29 const dispatch = useAppDispatch(); 30 const features = useSelector(selFeatures); 31 const navigate = useNavigate(); 32 const { pathname = "" } = useLocation(); 33 34 const sidebarOpen = useSelector( 35 (state: AppState) => state.system.sidebarOpen, 36 ); 37 const licenseInfo = useSelector( 38 (state: AppState) => state?.system?.licenseInfo, 39 ); 40 41 const isAgplAckDone = getLicenseConsent(); 42 const clusterRegistered = registeredCluster(); 43 44 const { plan = "" } = licenseInfo || {}; 45 46 let licenseNotification = true; 47 if (plan || isAgplAckDone || clusterRegistered) { 48 licenseNotification = false; 49 } 50 51 const allowedMenuItems = validRoutes(features, licenseNotification); 52 53 return ( 54 <Menu 55 isOpen={sidebarOpen} 56 displayGroupTitles 57 options={allowedMenuItems} 58 applicationLogo={{ applicationName: "console", subVariant: getLogoVar() }} 59 callPathAction={(path) => { 60 navigate(path); 61 }} 62 signOutAction={() => { 63 navigate("/logout"); 64 }} 65 collapseAction={() => { 66 dispatch(menuOpen(!sidebarOpen)); 67 }} 68 currentPath={pathname} 69 mobileModeAuto={false} 70 /> 71 ); 72 }; 73 74 export default MenuWrapper;