github.com/minio/console@v1.4.1/web-app/src/MainRouter.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, { Suspense } from "react"; 18 import { BrowserRouter, Route, Routes } from "react-router-dom"; 19 import ProtectedRoute from "./ProtectedRoutes"; 20 import LoadingComponent from "./common/LoadingComponent"; 21 import AppConsole from "./screens/Console/ConsoleKBar"; 22 import { baseUrl } from "./history"; 23 24 const Login = React.lazy(() => import("./screens/LoginPage/Login")); 25 const Logout = React.lazy(() => import("./screens/LogoutPage/LogoutPage")); 26 const LoginCallback = React.lazy( 27 () => import("./screens/LoginPage/LoginCallback"), 28 ); 29 30 const MainRouter = () => { 31 return ( 32 <BrowserRouter basename={baseUrl}> 33 <Routes> 34 <Route 35 path="/oauth_callback" 36 element={ 37 <Suspense fallback={<LoadingComponent />}> 38 <LoginCallback /> 39 </Suspense> 40 } 41 /> 42 <Route 43 path="/logout" 44 element={ 45 <Suspense fallback={<LoadingComponent />}> 46 <Logout /> 47 </Suspense> 48 } 49 /> 50 <Route 51 path="/login" 52 element={ 53 <Suspense fallback={<LoadingComponent />}> 54 <Login /> 55 </Suspense> 56 } 57 /> 58 <Route 59 path={"/*"} 60 element={<ProtectedRoute Component={AppConsole} />} 61 /> 62 </Routes> 63 </BrowserRouter> 64 ); 65 }; 66 67 export default MainRouter;