11import React , { Suspense , useContext } from 'react' ;
2- import { Routes , Route , Navigate } from 'react-router-dom' ;
2+ import { Routes , Route , Navigate , useMatch } from 'react-router-dom' ;
33import {
44 accessErrorPage ,
55 clusterPath ,
@@ -24,6 +24,7 @@ import { GlobalSettingsProvider } from './contexts/GlobalSettingsContext';
2424import { UserInfoRolesAccessProvider } from './contexts/UserInfoRolesAccessContext' ;
2525import PageContainer from './PageContainer/PageContainer' ;
2626
27+ const AuthPage = React . lazy ( ( ) => import ( 'components/AuthPage/AuthPage' ) ) ;
2728const Dashboard = React . lazy ( ( ) => import ( 'components/Dashboard/Dashboard' ) ) ;
2829const ClusterPage = React . lazy (
2930 ( ) => import ( 'components/ClusterPage/ClusterPage' )
@@ -49,54 +50,59 @@ const queryClient = new QueryClient({
4950} ) ;
5051const App : React . FC = ( ) => {
5152 const { isDarkMode } = useContext ( ThemeModeContext ) ;
53+ const isAuthRoute = useMatch ( '/login' ) ;
5254
5355 return (
5456 < QueryClientProvider client = { queryClient } >
55- < GlobalSettingsProvider >
56- < ThemeProvider theme = { isDarkMode ? darkTheme : theme } >
57- < Suspense fallback = { < PageLoader fullSize /> } >
58- < UserInfoRolesAccessProvider >
59- < ConfirmContextProvider >
60- < GlobalCSS />
61- < S . Layout >
62- < PageContainer >
63- < Routes >
64- { [ '/' , '/ui' , '/ui/clusters' ] . map ( ( path ) => (
57+ < ThemeProvider theme = { isDarkMode ? darkTheme : theme } >
58+ { isAuthRoute ? (
59+ < AuthPage />
60+ ) : (
61+ < GlobalSettingsProvider >
62+ < Suspense fallback = { < PageLoader fullSize /> } >
63+ < UserInfoRolesAccessProvider >
64+ < ConfirmContextProvider >
65+ < GlobalCSS />
66+ < S . Layout >
67+ < PageContainer >
68+ < Routes >
69+ { [ '/' , '/ui' , '/ui/clusters' ] . map ( ( path ) => (
70+ < Route
71+ key = "Home" // optional: avoid full re-renders on route changes
72+ path = { path }
73+ element = { < Dashboard /> }
74+ />
75+ ) ) }
6576 < Route
66- key = "Home" // optional: avoid full re-renders on route changes
67- path = { path }
68- element = { < Dashboard /> }
77+ path = { getNonExactPath ( clusterNewConfigPath ) }
78+ element = { < ClusterConfigForm /> }
6979 />
70- ) ) }
71- < Route
72- path = { getNonExactPath ( clusterNewConfigPath ) }
73- element = { < ClusterConfigForm /> }
74- />
75- < Route
76- path = { getNonExactPath ( clusterPath ( ) ) }
77- element = { < ClusterPage /> }
78- />
79- < Route
80- path = { accessErrorPage }
81- element = {
82- < ErrorPage status = { 403 } text = "Access is Denied" />
83- }
84- />
85- < Route path = { errorPage } element = { < ErrorPage /> } />
86- < Route
87- path = "*"
88- element = { < Navigate to = { errorPage } replace /> }
89- />
90- </ Routes >
91- </ PageContainer >
92- < Toaster position = "bottom-right" />
93- </ S . Layout >
94- < ConfirmationModal />
95- </ ConfirmContextProvider >
96- </ UserInfoRolesAccessProvider >
97- </ Suspense >
98- </ ThemeProvider >
99- </ GlobalSettingsProvider >
80+ < Route
81+ path = { getNonExactPath ( clusterPath ( ) ) }
82+ element = { < ClusterPage /> }
83+ />
84+ < Route
85+ path = { accessErrorPage }
86+ element = {
87+ < ErrorPage status = { 403 } text = "Access is Denied" />
88+ }
89+ />
90+ < Route path = { errorPage } element = { < ErrorPage /> } />
91+ < Route
92+ path = "*"
93+ element = { < Navigate to = { errorPage } replace /> }
94+ />
95+ </ Routes >
96+ </ PageContainer >
97+ < Toaster position = "bottom-right" />
98+ </ S . Layout >
99+ < ConfirmationModal />
100+ </ ConfirmContextProvider >
101+ </ UserInfoRolesAccessProvider >
102+ </ Suspense >
103+ </ GlobalSettingsProvider >
104+ ) }
105+ </ ThemeProvider >
100106 < ReactQueryDevtools initialIsOpen = { false } position = "bottom-right" />
101107 </ QueryClientProvider >
102108 ) ;
0 commit comments