Skip to content

Commit 6560b41

Browse files
committed
Merge branch 'bugfix/react18-navigation-issues' into tmp/octopus/w/130.0/bugfix/react18-navigation-issues
2 parents 973c0b5 + 7a715d5 commit 6560b41

File tree

8 files changed

+46
-43
lines changed

8 files changed

+46
-43
lines changed

shell-ui/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shell-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"dependencies": {
4848
"@scality/core-ui": "0.155.0",
49-
"@scality/module-federation": "^1.4.0",
49+
"@scality/module-federation": "^1.4.1",
5050
"downshift": "^8.0.0",
5151
"history": "^5.3.0",
5252
"jest-environment-jsdom": "^29.7.0",

shell-ui/src/FederatedApp.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@ import {
88
FederatedComponentProps,
99
SolutionUI,
1010
} from '@scality/module-federation';
11-
import React, { useEffect, useMemo } from 'react';
11+
import React, {
12+
useEffect,
13+
useLayoutEffect,
14+
useMemo,
15+
useTransition,
16+
useRef,
17+
useState,
18+
} from 'react';
1219
import { ErrorBoundary } from 'react-error-boundary';
1320
import { QueryClient } from 'react-query';
14-
import { BrowserRouter, Route, Routes } from 'react-router-dom';
21+
import { BrowserRouter, Route, Routes, useLocation } from 'react-router';
1522

1623
import { loadShare } from '@module-federation/enhanced/runtime';
1724
import { useQuery } from 'react-query';
@@ -229,6 +236,9 @@ function InternalApp() {
229236
loadShareModule('@scality/module-federation'),
230237
]);
231238
},
239+
refetchOnWindowFocus: false,
240+
refetchOnMount: false,
241+
refetchOnReconnect: false,
232242
});
233243

234244
return (

shell-ui/src/navbar/NavBar.tsx

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -122,30 +122,6 @@ const Link = ({
122122
);
123123
};
124124

125-
function prefetch(url: string) {
126-
return new Promise((resolve, reject) => {
127-
const existingElement = [
128-
...(document.head?.querySelectorAll('script') || []),
129-
// @ts-expect-error - FIXME when you are working on it
130-
].find((scriptElement) => scriptElement.attributes.src?.value === url);
131-
132-
if (existingElement) {
133-
// @ts-expect-error - FIXME when you are working on it
134-
resolve();
135-
}
136-
137-
const script = document.createElement('script');
138-
script.src = url;
139-
script.async = true;
140-
script.onload = (evt) => {
141-
script.setAttribute('data-loaded', 'true');
142-
resolve(evt);
143-
};
144-
script.onerror = reject;
145-
document.head?.appendChild(script);
146-
});
147-
}
148-
149125
export const useNavbarLinksToActions = (
150126
links: TypeLink[],
151127
): {
@@ -154,8 +130,8 @@ export const useNavbarLinksToActions = (
154130
}[] => {
155131
const location = useLocation();
156132
const doesRouteMatch = useCallback(
157-
(path: RouteProps) => {
158-
return matchPath(path.path + '*', location.pathname);
133+
({ path, exact }: { path: string; exact: boolean }) => {
134+
return matchPath(path + (exact ? '' : '*'), location.pathname);
159135
},
160136
[location],
161137
);
@@ -181,6 +157,7 @@ export const useNavbarLinksToActions = (
181157
.find((link) =>
182158
link.view.isFederated
183159
? doesRouteMatch({
160+
exact: link.view.view.exact,
184161
path: link.view.view.activeIfMatches
185162
? new RegExp(
186163
link.view.app.appHistoryBasePath +

shell-ui/src/navbar/NavbarUpdaterComponents.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ import { useConfigRetriever } from '../initFederation/ConfigurationProviders';
99
import { useDeployedApps } from '../initFederation/UIListProvider';
1010
import { useNotificationCenter } from '../useNotificationCenter';
1111
import { useNavbar } from './navbarHooks';
12+
import {
13+
ShellAlerts,
14+
shellAlerts,
15+
ShellHooks,
16+
shellHooks,
17+
} from '../hooks/useShellHooks';
1218

1319
export const NavbarUpdaterComponents = () => {
1420
const deployedApps = useDeployedApps();
@@ -41,7 +47,16 @@ export const NavbarUpdaterComponents = () => {
4147
{componentsToFederate.map((component, index) => {
4248
return (
4349
<Fragment key={index}>
44-
<ErrorBoundary FallbackComponent={() => <></>}>
50+
<ErrorBoundary
51+
FallbackComponent={(props) => {
52+
console.error(
53+
'error while loading navbar updater component',
54+
component,
55+
props,
56+
);
57+
return <></>;
58+
}}
59+
>
4560
<FederatedComponent
4661
key={component.module}
4762
url={`${component.app.url}${component.remoteEntryPath}?version=${component.app.version}`}
@@ -54,6 +69,8 @@ export const NavbarUpdaterComponents = () => {
5469
unPublishNotification: unPublish,
5570
isFirstTimeLogin: firstTimeLogin,
5671
userData,
72+
shellHooks,
73+
shellAlerts,
5774
}}
5875
/>
5976
</ErrorBoundary>

ui/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"@js-temporal/polyfill": "^0.4.4",
99
"@kubernetes/client-node": "github:scality/kubernetes-client-javascript.git#browser-0.10.4-64-ge7c6721",
1010
"@scality/core-ui": "0.155.0",
11-
"@scality/module-federation": "^1.4.0",
11+
"@scality/module-federation": "^1.4.1",
1212
"axios": "^0.21.1",
1313
"formik": "2.2.5",
1414
"jsonpath": "^1.1.1",

ui/src/containers/DashboardPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import DashboardServices from '../components/DashboardServices';
99
import DashboardGlobalHealth from '../components/DashboardGlobalHealth';
1010
import TimespanSelector from './TimespanSelector';
1111
import DashboardNetwork from '../components/DashboardNetwork';
12-
import { Outlet } from 'react-router';
1312

1413
const DashboardGrid = styled.div`
1514
display: grid;

0 commit comments

Comments
 (0)