@@ -14,7 +14,6 @@ import routes from '../../routes';
1414import type { RootState } from '../../store' ;
1515import { authenticationApi } from '../../store/reducers/authentication/authentication' ;
1616import {
17- useCapabilitiesLoaded ,
1817 useCapabilitiesQuery ,
1918 useClusterWithoutAuthInUI ,
2019 useMetaCapabilitiesLoaded ,
@@ -24,6 +23,7 @@ import {nodesListApi} from '../../store/reducers/nodesList';
2423import { cn } from '../../utils/cn' ;
2524import { useDatabaseFromQuery } from '../../utils/hooks/useDatabaseFromQuery' ;
2625import { lazyComponent } from '../../utils/lazyComponent' ;
26+ import { isAccessError , isRedirectToAuth } from '../../utils/response' ;
2727import Authentication from '../Authentication/Authentication' ;
2828import { getClusterPath } from '../Cluster/utils' ;
2929import Header from '../Header/Header' ;
@@ -207,13 +207,23 @@ function GetNodesList() {
207207}
208208
209209function GetCapabilities ( { children} : { children : React . ReactNode } ) {
210- useCapabilitiesQuery ( ) ;
211- const capabilitiesLoaded = useCapabilitiesLoaded ( ) ;
210+ const { data, error} = useCapabilitiesQuery ( ) ;
212211
213212 useMetaCapabilitiesQuery ( ) ;
214213 // It is always true if there is no meta, since request finishes with an error
215214 const metaCapabilitiesLoaded = useMetaCapabilitiesLoaded ( ) ;
216215
216+ //do nothing, authentication is in progress upon redirect
217+ if ( isRedirectToAuth ( error ) ) {
218+ return null ;
219+ }
220+
221+ if ( isAccessError ( error ) ) {
222+ return < AccessDenied /> ;
223+ }
224+
225+ const capabilitiesLoaded = Boolean ( data || error ) ;
226+
217227 return (
218228 < LoaderWrapper loading = { ! capabilitiesLoaded || ! metaCapabilitiesLoaded } size = "l" >
219229 { children }
0 commit comments