11import React , { Suspense , useContext } from 'react' ;
2- import { Routes , Route , Navigate } from 'react-router-dom' ;
2+ import { Routes , Route , Navigate , useLocation } 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,51 +50,57 @@ const queryClient = new QueryClient({
4950} ) ;
5051const App : React . FC = ( ) => {
5152 const { isDarkMode } = useContext ( ThemeModeContext ) ;
53+ const location = useLocation ( ) ;
54+ const isAuthPage = location . pathname === '/auth' ;
5255
5356 return (
5457 < QueryClientProvider client = { queryClient } >
5558 < GlobalSettingsProvider >
5659 < ThemeProvider theme = { isDarkMode ? darkTheme : theme } >
5760 < Suspense fallback = { < PageLoader fullSize /> } >
58- < UserInfoRolesAccessProvider >
59- < ConfirmContextProvider >
60- < GlobalCSS />
61- < S . Layout >
62- < PageContainer >
63- < Routes >
64- { [ '/' , '/ui' , '/ui/clusters' ] . map ( ( path ) => (
61+ { isAuthPage ? (
62+ < AuthPage />
63+ ) : (
64+ < UserInfoRolesAccessProvider >
65+ < ConfirmContextProvider >
66+ < GlobalCSS />
67+ < S . Layout >
68+ < PageContainer >
69+ < Routes >
70+ { [ '/' , '/ui' , '/ui/clusters' ] . map ( ( path ) => (
71+ < Route
72+ key = "Home" // optional: avoid full re-renders on route changes
73+ path = { path }
74+ element = { < Dashboard /> }
75+ />
76+ ) ) }
6577 < Route
66- key = "Home" // optional: avoid full re-renders on route changes
67- path = { path }
68- element = { < Dashboard /> }
78+ path = { getNonExactPath ( clusterNewConfigPath ) }
79+ element = { < ClusterConfigForm /> }
6980 />
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 >
81+ < Route
82+ path = { getNonExactPath ( clusterPath ( ) ) }
83+ element = { < ClusterPage /> }
84+ />
85+ < Route
86+ path = { accessErrorPage }
87+ element = {
88+ < ErrorPage status = { 403 } text = "Access is Denied" />
89+ }
90+ />
91+ < Route path = { errorPage } element = { < ErrorPage /> } />
92+ < Route
93+ path = "*"
94+ element = { < Navigate to = { errorPage } replace /> }
95+ />
96+ </ Routes >
97+ </ PageContainer >
98+ < Toaster position = "bottom-right" />
99+ </ S . Layout >
100+ < ConfirmationModal />
101+ </ ConfirmContextProvider >
102+ </ UserInfoRolesAccessProvider >
103+ ) }
97104 </ Suspense >
98105 </ ThemeProvider >
99106 </ GlobalSettingsProvider >
0 commit comments