github.com/minio/console@v1.4.1/web-app/src/screens/Console/Dashboard/Dashboard.tsx (about) 1 // This file is part of MinIO Console Server 2 // Copyright (c) 2021 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, { Fragment, useEffect, useState } from "react"; 18 import { useSelector } from "react-redux"; 19 import { AppState, useAppDispatch } from "../../../store"; 20 import { getUsageAsync } from "./dashboardThunks"; 21 import { selFeatures } from "../consoleSlice"; 22 import { setHelpName } from "../../../systemSlice"; 23 import PrDashboard from "./Prometheus/PrDashboard"; 24 import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper"; 25 import HelpMenu from "../HelpMenu"; 26 27 const Dashboard = () => { 28 const dispatch = useAppDispatch(); 29 const [iniLoad, setIniLoad] = useState<boolean>(false); 30 31 const usage = useSelector((state: AppState) => state.dashboard.usage); 32 const features = useSelector(selFeatures); 33 const obOnly = !!features?.includes("object-browser-only"); 34 let hideMenu = false; 35 if (features?.includes("hide-menu")) { 36 hideMenu = true; 37 } else if (obOnly) { 38 hideMenu = true; 39 } 40 41 useEffect(() => { 42 if (!iniLoad) { 43 setIniLoad(true); 44 dispatch(getUsageAsync()); 45 } 46 }, [iniLoad, dispatch]); 47 48 useEffect(() => { 49 dispatch(setHelpName("metrics")); 50 }, [dispatch]); 51 52 return ( 53 <Fragment> 54 {!hideMenu && ( 55 <PageHeaderWrapper label="Metrics" actions={<HelpMenu />} /> 56 )} 57 <PrDashboard usage={usage} /> 58 </Fragment> 59 ); 60 }; 61 62 export default Dashboard;