Skip to content

Commit

Permalink
ARTESCA-13612 // Add listener to custom event in NavbarUC
Browse files Browse the repository at this point in the history
  • Loading branch information
hervedombya committed Oct 7, 2024
1 parent c28c59c commit de84229
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion shell-ui/src/navbar/NavbarUpdaterComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SolutionUI } from '@scality/module-federation';
import { FederatedComponent } from '@scality/module-federation';
import { Fragment } from 'react';
import { Fragment, useEffect } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import { useAuth } from '../auth/AuthProvider';
import { useFirstTimeLogin } from '../auth/FirstTimeLoginProvider';
Expand All @@ -9,6 +9,7 @@ import { useConfigRetriever } from '../initFederation/ConfigurationProviders';
import { useDeployedApps } from '../initFederation/UIListProvider';
import { useNotificationCenter } from '../useNotificationCenter';
import { useNavbar } from './navbarHooks';
import { useShellHistory } from '../initFederation/ShellHistoryProvider';

export const NavbarUpdaterComponents = () => {
const deployedApps = useDeployedApps();
Expand Down Expand Up @@ -36,6 +37,23 @@ export const NavbarUpdaterComponents = () => {
.filter((appBuildConfig) => !!appBuildConfig);
const { firstTimeLogin } = useFirstTimeLogin();
const { userData } = useAuth();
const history = useShellHistory();

useEffect(() => {
const handleDownloadUploadEvent = (event: CustomEvent) => {
history.push(event.detail);
};

window.addEventListener('downloadUploadEvent', handleDownloadUploadEvent);

return () => {
window.removeEventListener(
'downloadUploadEvent',
handleDownloadUploadEvent,
);
};
}, []);

return (
<>
{componentsToFederate.map((component, index) => {
Expand Down

0 comments on commit de84229

Please sign in to comment.