Skip to content

Commit 71639c2

Browse files
committed
Merge remote-tracking branch 'origin/main' into upgrade_lib_uuid_to_13.0.0
Signed-off-by: Franck LECUYER <[email protected]> # Conflicts: # package-lock.json # package.json
2 parents a4d46cb + b2afa56 commit 71639c2

24 files changed

+2493
-2222
lines changed

jest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { Config } from 'jest';
1010
const config: Config = {
1111
testEnvironment: 'jsdom',
1212
moduleNameMapper: {
13-
'^.+\\.svg\\?react$': 'jest-svg-transformer',
13+
'^.+\\.svg\\?react$': '<rootDir>/src/_mocks_/svg.tsx',
1414
'^.+\\.(css|less|scss)$': 'identity-obj-proxy',
1515
},
1616
// see https://github.com/react-dnd/react-dnd/issues/3443

package-lock.json

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

package.json

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,31 @@
1515
},
1616
"dependencies": {
1717
"@emotion/react": "^11.14.0",
18-
"@emotion/styled": "^11.14.0",
19-
"@gridsuite/commons-ui": "file:../commons-ui/gridsuite-commons-ui-0.124.0.tgz",
20-
"@hookform/resolvers": "^4.0.0",
21-
"@mui/icons-material": "^5.16.14",
18+
"@emotion/styled": "^11.14.1",
19+
"@gridsuite/commons-ui": "file:../commons-ui/gridsuite-commons-ui-0.126.0.tgz",
20+
"@hookform/resolvers": "^4.1.3",
21+
"@mui/icons-material": "^5.18.0",
2222
"@mui/lab": "5.0.0-alpha.175",
23-
"@mui/material": "^5.16.14",
24-
"@mui/x-date-pickers": "^7.29.3",
25-
"@mui/x-tree-view": "^7.28.1",
26-
"@reduxjs/toolkit": "^2.5.1",
23+
"@mui/material": "^5.18.0",
24+
"@mui/x-date-pickers": "^7.29.4",
25+
"@mui/x-tree-view": "^7.29.1",
26+
"@reduxjs/toolkit": "^2.9.0",
2727
"ag-grid-community": "^33.1.0",
28-
"ag-grid-react": "^33.1.0",
29-
"core-js": "^3.40.0",
28+
"ag-grid-react": "^33.3.2",
29+
"core-js": "^3.45.1",
3030
"date-fns": "^4.1.0",
3131
"notistack": "^3.0.2",
3232
"oidc-client": "^1.11.5",
3333
"react": "^18.3.1",
3434
"react-dom": "^18.3.1",
35-
"react-hook-form": "^7.54.2",
36-
"react-hook-form-mui": "^7.6.0",
37-
"react-intl": "^7.1.6",
35+
"react-hook-form": "^7.62.0",
36+
"react-hook-form-mui": "^7.6.2",
37+
"react-intl": "^7.1.11",
3838
"react-redux": "^9.2.0",
39-
"react-router": "^7.4.1",
39+
"react-router": "^7.8.2",
4040
"redux": "^5.0.1",
4141
"typeface-roboto": "^1.1.13",
42-
"yup": "^1.6.1"
42+
"yup": "^1.7.0"
4343
},
4444
"scripts": {
4545
"start": "vite",
@@ -53,52 +53,52 @@
5353
"licenses-check": "license-checker --summary --excludePrivatePackages --production --onlyAllow \"$( jq -r .onlyAllow[] license-checker-config.json | tr '\n' ';')\""
5454
},
5555
"devDependencies": {
56-
"@babel/helper-builder-react-jsx": "^7.25.9",
56+
"@babel/helper-builder-react-jsx": "^7.27.1",
5757
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
58-
"@babel/preset-env": "^7.26.8",
59-
"@babel/preset-react": "^7.26.3",
60-
"@babel/preset-typescript": "^7.26.0",
58+
"@babel/preset-env": "^7.28.3",
59+
"@babel/preset-react": "^7.27.1",
60+
"@babel/preset-typescript": "^7.27.1",
6161
"@types/core-js": "^2.5.8",
6262
"@types/eslint": "^8.56.12",
6363
"@types/eslint-config-prettier": "^6.11.3",
6464
"@types/jest": "^27.5.2",
6565
"@types/license-checker": "^25.0.6",
66-
"@types/node": "^22.13.4",
67-
"@types/prop-types": "^15.7.14",
68-
"@types/react": "^18.3.18",
69-
"@types/react-dom": "^18.3.5",
66+
"@types/node": "^22.18.1",
67+
"@types/prop-types": "^15.7.15",
68+
"@types/react": "^18.3.24",
69+
"@types/react-dom": "^18.3.7",
7070
"@types/react-redux": "^7.1.34",
7171
"@types/react-window": "^1.8.8",
7272
"@typescript-eslint/eslint-plugin": "^6.21.0",
7373
"@typescript-eslint/parser": "^6.21.0",
74-
"@vitejs/plugin-react": "^4.3.4",
74+
"@vitejs/plugin-react": "^4.7.0",
7575
"babel-eslint": "^10.1.0",
7676
"babel-preset-vite": "^1.1.3",
7777
"eslint": "^8.57.1",
78-
"eslint-config-prettier": "^10.1.1",
78+
"eslint-config-prettier": "^10.1.8",
7979
"eslint-config-react-app": "^7.0.1",
8080
"eslint-import-resolver-typescript": "3.8.3",
8181
"eslint-plugin-flowtype": "^8.0.3",
82-
"eslint-plugin-import": "^2.31.0",
82+
"eslint-plugin-import": "^2.32.0",
8383
"eslint-plugin-jsx-a11y": "^6.10.2",
84-
"eslint-plugin-prettier": "^5.2.5",
85-
"eslint-plugin-react": "^7.37.4",
84+
"eslint-plugin-prettier": "^5.5.4",
85+
"eslint-plugin-react": "^7.37.5",
8686
"eslint-plugin-react-hooks": "^4.6.2",
87-
"eslint-plugin-react-refresh": "^0.4.19",
87+
"eslint-plugin-react-refresh": "^0.4.20",
8888
"identity-obj-proxy": "^3.0.0",
8989
"jest": "^29.7.0",
9090
"jest-environment-jsdom": "^29.7.0",
9191
"jest-svg-transformer": "^1.0.0",
9292
"license-checker": "^25.0.1",
93-
"prettier": "^3.5.3",
93+
"prettier": "^3.6.2",
9494
"prettier-plugin-properties": "^0.3.0",
9595
"svgo": "^3.3.2",
9696
"ts-node": "^10.9.2",
97-
"type-fest": "^4.34.1",
98-
"typescript": "~5.1.6",
99-
"vite": "^6.2.1",
97+
"type-fest": "^4.41.0",
98+
"typescript": "~5.6.3",
99+
"vite": "^6.3.6",
100100
"vite-plugin-eslint": "^1.8.1",
101-
"vite-plugin-svgr": "^4.3.0",
101+
"vite-plugin-svgr": "^4.5.0",
102102
"vite-tsconfig-paths": "^5.1.4"
103103
}
104104
}
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
/*
1+
/**
22
* Copyright (c) 2024, RTE (http://www.rte-france.com)
33
* This Source Code Form is subject to the terms of the Mozilla Public
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
77

8-
export * from './router';
8+
export default function fetchMock() {
9+
return Promise.resolve({
10+
ok: true,
11+
json: () => ({ appsMetadataServerUrl: '' }), // just to remove the error logs when fetching env
12+
});
13+
}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
/*
1+
/**
22
* Copyright (c) 2024, RTE (http://www.rte-france.com)
33
* This Source Code Form is subject to the terms of the Mozilla Public
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
77

8-
import AppComponent from './app';
9-
export type App = typeof AppComponent;
8+
import { forwardRef, SVGProps } from 'react';
109

11-
export { AppWrapper } from './app-wrapper';
10+
const SvgrMock = forwardRef<SVGSVGElement, SVGProps<SVGSVGElement>>((props, ref) => <svg ref={ref} {...props} />);
11+
12+
export default SvgrMock;

src/components/App/App.tsx

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
/*
2+
* Copyright (c) 2020, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
import { useCallback, useEffect, useState } from 'react';
9+
import { useDispatch, useSelector } from 'react-redux';
10+
import { Grid } from '@mui/material';
11+
import {
12+
AnnouncementNotification,
13+
AuthenticationRouter,
14+
CardErrorBoundary,
15+
fetchConfigParameter,
16+
fetchConfigParameters,
17+
getComputedLanguage,
18+
getPreLoginPath,
19+
initializeAuthenticationProd,
20+
NotificationsUrlKeys,
21+
useNotificationsListener,
22+
UserManagerState,
23+
useSnackMessage,
24+
} from '@gridsuite/commons-ui';
25+
import { selectComputedLanguage, selectLanguage, selectTheme } from '../../redux/actions';
26+
import { AppState } from '../../redux/reducer';
27+
import { AppsMetadataSrv, ConfigParameters } from '../../services';
28+
import { APP_NAME, COMMON_APP_NAME, PARAM_LANGUAGE, PARAM_THEME } from '../../utils/config-params';
29+
import AppTopBar from './AppTopBar';
30+
import { useDebugRender } from '../../utils/hooks';
31+
import { AppDispatch } from '../../redux/store';
32+
import { Navigate, Route, Routes, useLocation, useMatch, useNavigate } from 'react-router';
33+
import PageNotFound from './PageNotFound';
34+
import { FormattedMessage } from 'react-intl';
35+
import { MainPaths } from './utils';
36+
import { Announcements, Groups, Profiles, Users } from '../../pages';
37+
import HomePage from './HomePage';
38+
39+
export default function App() {
40+
useDebugRender('app');
41+
const { snackError } = useSnackMessage();
42+
const dispatch = useDispatch<AppDispatch>();
43+
const user = useSelector((state: AppState) => state.user);
44+
45+
const updateParams = useCallback(
46+
(params: ConfigParameters) => {
47+
console.groupCollapsed('received UI parameters');
48+
console.table(params);
49+
console.groupEnd();
50+
params.forEach((param) => {
51+
switch (param.name) {
52+
case PARAM_THEME:
53+
dispatch(selectTheme(param.value));
54+
break;
55+
case PARAM_LANGUAGE:
56+
dispatch(selectLanguage(param.value));
57+
dispatch(selectComputedLanguage(getComputedLanguage(param.value)));
58+
break;
59+
default:
60+
break;
61+
}
62+
});
63+
},
64+
[dispatch]
65+
);
66+
67+
const updateConfig = useCallback(
68+
(event: MessageEvent) => {
69+
const eventData = JSON.parse(event.data);
70+
if (eventData?.headers?.parameterName) {
71+
fetchConfigParameter(APP_NAME, eventData.headers.parameterName)
72+
.then((param) => updateParams([param]))
73+
.catch((error) => snackError({ messageTxt: error.message, headerId: 'paramsRetrievingError' }));
74+
}
75+
},
76+
[updateParams, snackError]
77+
);
78+
79+
useNotificationsListener(NotificationsUrlKeys.CONFIG, { listenerCallbackMessage: updateConfig });
80+
81+
useEffect(() => {
82+
if (user !== null) {
83+
fetchConfigParameters(COMMON_APP_NAME)
84+
.then((params) => updateParams(params))
85+
.catch((error) =>
86+
snackError({
87+
messageTxt: error.message,
88+
headerId: 'paramsRetrievingError',
89+
})
90+
);
91+
92+
fetchConfigParameters(APP_NAME)
93+
.then((params) => updateParams(params))
94+
.catch((error) =>
95+
snackError({
96+
messageTxt: error.message,
97+
headerId: 'paramsRetrievingError',
98+
})
99+
);
100+
}
101+
}, [user, dispatch, updateParams, snackError]);
102+
103+
const signInCallbackError = useSelector((state: AppState) => state.signInCallbackError);
104+
const authenticationRouterError = useSelector((state: AppState) => state.authenticationRouterError);
105+
const showAuthenticationRouterLogin = useSelector((state: AppState) => state.showAuthenticationRouterLogin);
106+
const [userManager, setUserManager] = useState<UserManagerState>({
107+
instance: null,
108+
error: null,
109+
});
110+
const navigate = useNavigate();
111+
const location = useLocation();
112+
113+
// Can't use lazy initializer because useRouteMatch is a hook
114+
const [initialMatchSilentRenewCallbackUrl] = useState(
115+
useMatch({
116+
path: '/silent-renew-callback',
117+
})
118+
);
119+
120+
const [initialMatchSigninCallbackUrl] = useState(
121+
useMatch({
122+
path: '/sign-in-callback',
123+
})
124+
);
125+
126+
useEffect(() => {
127+
// need subfunction when async as suggested by rule react-hooks/exhaustive-deps
128+
(async function initializeAuthentication() {
129+
try {
130+
setUserManager({
131+
instance: await initializeAuthenticationProd(
132+
dispatch,
133+
initialMatchSilentRenewCallbackUrl != null,
134+
AppsMetadataSrv.fetchIdpSettings,
135+
initialMatchSigninCallbackUrl != null
136+
),
137+
error: null,
138+
});
139+
} catch (error: any) {
140+
setUserManager({ instance: null, error: error.message });
141+
}
142+
})();
143+
// Note: initialMatchSilentRenewCallbackUrl and dispatch don't change
144+
}, [initialMatchSilentRenewCallbackUrl, dispatch, initialMatchSigninCallbackUrl]);
145+
146+
return (
147+
<Grid
148+
container
149+
direction="column"
150+
spacing={0}
151+
justifyContent="flex-start"
152+
alignItems="stretch"
153+
sx={{ height: '100vh', width: '100vw' }}
154+
>
155+
<Grid item xs="auto">
156+
<AppTopBar userManagerInstance={userManager.instance} />
157+
</Grid>
158+
<Grid item xs="auto">
159+
<AnnouncementNotification user={user} />
160+
</Grid>
161+
<Grid item container xs component="main" height={'100%'}>
162+
<CardErrorBoundary>
163+
<div
164+
className="singlestretch-parent"
165+
style={{
166+
flexGrow: 1,
167+
}}
168+
>
169+
{user !== null ? (
170+
<Routes>
171+
<Route path={'/'} element={<HomePage />} />
172+
<Route path={`/${MainPaths.users}`} element={<Users />} />
173+
<Route path={`/${MainPaths.profiles}`} element={<Profiles />} />
174+
<Route path={`/${MainPaths.groups}`} element={<Groups />} />
175+
<Route path={`/${MainPaths.announcements}`} element={<Announcements />} />
176+
<Route
177+
path="/sign-in-callback"
178+
element={<Navigate replace to={getPreLoginPath() || '/'} />}
179+
/>
180+
<Route
181+
path="/logout-callback"
182+
element={<h1>Error: logout failed; you are still logged in.</h1>}
183+
/>
184+
<Route
185+
path="*"
186+
element={<PageNotFound message={<FormattedMessage id="PageNotFound" />} />}
187+
/>
188+
</Routes>
189+
) : (
190+
<AuthenticationRouter
191+
userManager={userManager}
192+
signInCallbackError={signInCallbackError}
193+
authenticationRouterError={authenticationRouterError}
194+
showAuthenticationRouterLogin={showAuthenticationRouterLogin}
195+
dispatch={dispatch}
196+
navigate={navigate}
197+
location={location}
198+
/>
199+
)}
200+
</div>
201+
</CardErrorBoundary>
202+
</Grid>
203+
</Grid>
204+
);
205+
}

0 commit comments

Comments
 (0)