File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 11import { MetricsTimeSpanContext } from '@scality/core-ui/dist/components/charts/MetricsTimeSpanProvider' ;
22import { useShellHooks } from '@scality/module-federation' ;
3- import { useLayoutEffect , useMemo } from 'react' ;
3+ import { useEffect , useLayoutEffect , useMemo } from 'react' ;
44import FederatedIntlProvider from '../containers/IntlProvider' ;
55import StartTimeProvider from '../containers/StartTimeProvider' ;
66import { initialize as initializePrometheus , setHeaders } from '../services/prometheus/api' ;
@@ -27,7 +27,13 @@ export default function PlatformGlobalHealthBarFederated({
2727 const { userData } = useAuth ( ) ;
2828 const token = userData ?. token ;
2929
30- useLayoutEffect ( ( ) => {
30+
31+ /**
32+ * Initialize the Prometheus client and set the authorization header if the token is available
33+ * The initialization of Prometheus client is neeeded here as it is shared with Module Federation to another ui
34+ * The prometheus client could not be initialized in the parent component rendering it.
35+ */
36+ useEffect ( ( ) => {
3137 if ( token ) {
3238 initializePrometheus ( prometheusUrl ) ;
3339 setHeaders ( { Authorization : `Bearer ${ token } ` } ) ;
You can’t perform that action at this time.
0 commit comments