@@ -2,28 +2,28 @@ import React from 'react';
22
33import { connect } from 'react-redux' ;
44import type { RedirectProps } from 'react-router-dom' ;
5- import { Redirect , Route , Switch , useLocation } from 'react-router-dom' ;
5+ import { Redirect , Route , Switch } from 'react-router-dom' ;
66
77import { AccessDenied } from '../../components/Errors/403' ;
88import { PageError } from '../../components/Errors/PageError/PageError' ;
99import { LoaderWrapper } from '../../components/LoaderWrapper/LoaderWrapper' ;
1010import { useSlots } from '../../components/slots' ;
1111import type { SlotMap } from '../../components/slots/SlotMap' ;
1212import type { SlotComponent } from '../../components/slots/types' ;
13- import routes , { checkIsClustersPage } from '../../routes' ;
13+ import routes from '../../routes' ;
1414import type { RootState } from '../../store' ;
1515import { authenticationApi } from '../../store/reducers/authentication/authentication' ;
1616import {
1717 useCapabilitiesQuery ,
1818 useClusterWithoutAuthInUI ,
1919 useMetaCapabilitiesLoaded ,
2020 useMetaCapabilitiesQuery ,
21- useMetaLoginAvailable ,
2221} from '../../store/reducers/capabilities/hooks' ;
2322import { nodesListApi } from '../../store/reducers/nodesList' ;
2423import { uiFactory } from '../../uiFactory/uiFactory' ;
2524import { cn } from '../../utils/cn' ;
2625import { useDatabaseFromQuery } from '../../utils/hooks/useDatabaseFromQuery' ;
26+ import { useMetaAuth , useMetaAuthUnavailable } from '../../utils/hooks/useMetaAuth' ;
2727import { lazyComponent } from '../../utils/lazyComponent' ;
2828import { isAccessError , isRedirectToAuth } from '../../utils/response' ;
2929import Authentication from '../Authentication/Authentication' ;
@@ -201,13 +201,9 @@ function ClustersDataWrapper({children}: {children: React.ReactNode}) {
201201}
202202
203203function GetMetaUser ( { children} : { children : React . ReactNode } ) {
204- const location = useLocation ( ) ;
204+ const metaAuth = useMetaAuth ( ) ;
205205
206- const isClustersPage = checkIsClustersPage ( location . pathname ) ;
207-
208- const isMetaLoginAvailable = useMetaLoginAvailable ( ) ;
209-
210- if ( isClustersPage && isMetaLoginAvailable ) {
206+ if ( metaAuth ) {
211207 return < GetUser useMeta > { children } </ GetUser > ;
212208 }
213209 return children ;
@@ -216,7 +212,7 @@ function GetMetaUser({children}: {children: React.ReactNode}) {
216212function GetUser ( { children, useMeta} : { children : React . ReactNode ; useMeta ?: boolean } ) {
217213 const database = useDatabaseFromQuery ( ) ;
218214
219- const { isLoading , error} = authenticationApi . useWhoamiQuery ( {
215+ const { isFetching , error} = authenticationApi . useWhoamiQuery ( {
220216 database,
221217 useMeta,
222218 } ) ;
@@ -225,7 +221,7 @@ function GetUser({children, useMeta}: {children: React.ReactNode; useMeta?: bool
225221 const errorProps = error ? { ...uiFactory . clusterOrDatabaseAccessError } : undefined ;
226222
227223 return (
228- < LoaderWrapper loading = { isLoading } size = "l" >
224+ < LoaderWrapper loading = { isFetching } size = "l" delay = { 0 } >
229225 < PageError error = { error } { ...errorProps } errorPageTitle = { appTitle } >
230226 { children }
231227 </ PageError >
@@ -288,15 +284,10 @@ function ContentWrapper(props: ContentWrapperProps) {
288284 const { singleClusterMode, isAuthenticated} = props ;
289285 const authUnavailable = useClusterWithoutAuthInUI ( ) ;
290286
291- const location = useLocation ( ) ;
292- const isClustersPage = checkIsClustersPage ( location . pathname ) ;
293-
294- const isMetaLoginAvailable = useMetaLoginAvailable ( ) ;
295-
296- const isClustersAuthUnavailable = isClustersPage && ! isMetaLoginAvailable ;
287+ const metaAuthUnavailable = useMetaAuthUnavailable ( ) ;
297288
298289 const renderNotAuthenticated = ( ) => {
299- if ( authUnavailable || isClustersAuthUnavailable ) {
290+ if ( authUnavailable || metaAuthUnavailable ) {
300291 return < AccessDenied /> ;
301292 }
302293 return < Authentication /> ;
0 commit comments