@@ -14,7 +14,6 @@ import routes from '../../routes';
14
14
import type { RootState } from '../../store' ;
15
15
import { authenticationApi } from '../../store/reducers/authentication/authentication' ;
16
16
import {
17
- useCapabilitiesLoaded ,
18
17
useCapabilitiesQuery ,
19
18
useClusterWithoutAuthInUI ,
20
19
useMetaCapabilitiesLoaded ,
@@ -24,6 +23,7 @@ import {nodesListApi} from '../../store/reducers/nodesList';
24
23
import { cn } from '../../utils/cn' ;
25
24
import { useDatabaseFromQuery } from '../../utils/hooks/useDatabaseFromQuery' ;
26
25
import { lazyComponent } from '../../utils/lazyComponent' ;
26
+ import { isAccessError , isRedirectToAuth } from '../../utils/response' ;
27
27
import Authentication from '../Authentication/Authentication' ;
28
28
import { getClusterPath } from '../Cluster/utils' ;
29
29
import Header from '../Header/Header' ;
@@ -207,13 +207,23 @@ function GetNodesList() {
207
207
}
208
208
209
209
function GetCapabilities ( { children} : { children : React . ReactNode } ) {
210
- useCapabilitiesQuery ( ) ;
211
- const capabilitiesLoaded = useCapabilitiesLoaded ( ) ;
210
+ const { data, error} = useCapabilitiesQuery ( ) ;
212
211
213
212
useMetaCapabilitiesQuery ( ) ;
214
213
// It is always true if there is no meta, since request finishes with an error
215
214
const metaCapabilitiesLoaded = useMetaCapabilitiesLoaded ( ) ;
216
215
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
+
217
227
return (
218
228
< LoaderWrapper loading = { ! capabilitiesLoaded || ! metaCapabilitiesLoaded } size = "l" >
219
229
{ children }
0 commit comments