From d2c6b35c11d9f77e61ccf6804e0eadff7e5314b5 Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Wed, 6 May 2026 18:39:18 +0200 Subject: [PATCH 1/5] remove tokenId from notificationsUrlKeys --- src/utils/notifications-provider.ts | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/utils/notifications-provider.ts b/src/utils/notifications-provider.ts index 77c64206..2ba0579e 100644 --- a/src/utils/notifications-provider.ts +++ b/src/utils/notifications-provider.ts @@ -6,31 +6,22 @@ */ import { useMemo } from 'react'; -import { useSelector } from 'react-redux'; -import type { AppState } from '../redux/reducer'; -import { getUrlWithToken, getWsBase } from './api-ws'; +import { getWsBase } from './api-ws'; import { APP_NAME } from './config-params'; import { NotificationsUrlKeys, PREFIX_CONFIG_NOTIFICATION_WS } from '@gridsuite/commons-ui'; export function useNotificationsUrlGenerator() { // The websocket API doesn't allow relative urls const wsBase = getWsBase(); - const tokenId = useSelector((state: AppState) => state.user?.id_token); - // return a mapper with NOTIFICATIONS_URL_KEYS and undefined value if URL is not yet buildable (tokenId) + // return a mapper with NOTIFICATIONS_URL_KEYS value // it will be used to register listeners as soon as possible. return useMemo( () => ({ - [NotificationsUrlKeys.CONFIG]: tokenId - ? getUrlWithToken( - `${wsBase}${PREFIX_CONFIG_NOTIFICATION_WS}/notify?${new URLSearchParams({ appName: APP_NAME })}` - ) - : undefined, - [NotificationsUrlKeys.GLOBAL_CONFIG]: tokenId - ? getUrlWithToken(`${wsBase}${PREFIX_CONFIG_NOTIFICATION_WS}/global`) - : undefined, - }) satisfies Partial>, - [wsBase, tokenId] + [NotificationsUrlKeys.CONFIG]:`${wsBase}${PREFIX_CONFIG_NOTIFICATION_WS}/notify?${new URLSearchParams({ appName: APP_NAME })}`, + [NotificationsUrlKeys.GLOBAL_CONFIG]: `${wsBase}${PREFIX_CONFIG_NOTIFICATION_WS}/global`, + }) satisfies Partial>, + [wsBase] ); } From 99dc67d129b56c7058940d04771221890be3fbad Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Thu, 7 May 2026 15:05:08 +0200 Subject: [PATCH 2/5] fix prettier --- src/utils/notifications-provider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/notifications-provider.ts b/src/utils/notifications-provider.ts index 2ba0579e..6e26ba69 100644 --- a/src/utils/notifications-provider.ts +++ b/src/utils/notifications-provider.ts @@ -19,7 +19,7 @@ export function useNotificationsUrlGenerator() { return useMemo( () => ({ - [NotificationsUrlKeys.CONFIG]:`${wsBase}${PREFIX_CONFIG_NOTIFICATION_WS}/notify?${new URLSearchParams({ appName: APP_NAME })}`, + [NotificationsUrlKeys.CONFIG]: `${wsBase}${PREFIX_CONFIG_NOTIFICATION_WS}/notify?${new URLSearchParams({ appName: APP_NAME })}`, [NotificationsUrlKeys.GLOBAL_CONFIG]: `${wsBase}${PREFIX_CONFIG_NOTIFICATION_WS}/global`, }) satisfies Partial>, [wsBase] From 0ca7bee3036a5c3ae5c81e7d0f7ed61d5c9e9b88 Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Tue, 12 May 2026 15:37:02 +0200 Subject: [PATCH 3/5] clean getUrlWithToken --- src/utils/api-ws.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/utils/api-ws.ts b/src/utils/api-ws.ts index 1689a76f..cf5360bf 100644 --- a/src/utils/api-ws.ts +++ b/src/utils/api-ws.ts @@ -5,13 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { getToken } from './api'; - export type * from './api'; export const getWsBase = () => document.baseURI.replace(/^http:\/\//, 'ws://').replace(/^https:\/\//, 'wss://'); - -export function getUrlWithToken(baseUrl: string): string { - const querySymbol = baseUrl.includes('?') ? '&' : '?'; - return `${baseUrl}${querySymbol}access_token=${getToken()}`; -} From 1d10518f4649c16f3fb4d3252f9ec0fc19b1408f Mon Sep 17 00:00:00 2001 From: Rehili Ghazwa Date: Fri, 22 May 2026 16:03:01 +0200 Subject: [PATCH 4/5] code review remarks --- src/components/App/App.tsx | 12 ++++++------ src/components/App/AppTopBar.tsx | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/App/App.tsx b/src/components/App/App.tsx index 0f7d29f3..f81b100a 100644 --- a/src/components/App/App.tsx +++ b/src/components/App/App.tsx @@ -6,7 +6,7 @@ */ import { useCallback, useEffect, useState } from 'react'; -import { useDispatch, useSelector } from 'react-redux'; +import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import { Grid } from '@mui/material'; import { AnnouncementNotification, @@ -42,7 +42,7 @@ export default function App() { useDebugRender('app'); const { snackError } = useSnackMessage(); const dispatch = useDispatch(); - const user = useSelector((state: AppState) => state.user); + const userProfile = useSelector((state: AppState) => state.user?.profile ?? null, shallowEqual); const updateParams = useCallback( (params: ConfigParameters) => { @@ -81,7 +81,7 @@ export default function App() { useNotificationsListener(NotificationsUrlKeys.CONFIG, { listenerCallbackMessage: updateConfig }); useEffect(() => { - if (user !== null) { + if (userProfile !== null) { fetchConfigParameters(COMMON_APP_NAME) .then((params) => updateParams(params)) .catch((error) => @@ -100,7 +100,7 @@ export default function App() { }) ); } - }, [user, dispatch, updateParams, snackError]); + }, [userProfile, dispatch, updateParams, snackError]); const signInCallbackError = useSelector((state: AppState) => state.signInCallbackError); const authenticationRouterError = useSelector((state: AppState) => state.authenticationRouterError); @@ -158,7 +158,7 @@ export default function App() { - + @@ -168,7 +168,7 @@ export default function App() { flexGrow: 1, }} > - {user !== null ? ( + {userProfile !== null ? ( } /> } /> diff --git a/src/components/App/AppTopBar.tsx b/src/components/App/AppTopBar.tsx index 47d25ff1..bd98858d 100644 --- a/src/components/App/AppTopBar.tsx +++ b/src/components/App/AppTopBar.tsx @@ -20,7 +20,7 @@ import { import { useParameterState } from '../parameters'; import { APP_NAME } from '../../utils/config-params'; import { NavLink, type To, useNavigate } from 'react-router'; -import { useDispatch, useSelector } from 'react-redux'; +import { shallowEqual, useDispatch, useSelector } from 'react-redux'; import { FormattedMessage } from 'react-intl'; import { AppsMetadataSrv, StudySrv } from '../../services'; import GridAdminLogoLight from '../../images/GridAdmin_logo_light.svg?react'; @@ -96,7 +96,7 @@ type AppTopBarProps = { export default function AppTopBar({ userManagerInstance }: Readonly) { const theme = useTheme(); const dispatch = useDispatch(); - const user = useSelector((state: AppState) => state.user); + const userProfile = useSelector((state: AppState) => state.user?.profile ?? null, shallowEqual); const navigate = useNavigate(); @@ -107,12 +107,12 @@ export default function AppTopBar({ userManagerInstance }: Readonly(false); useEffect(() => { - if (user !== null) { + if (userProfile !== null) { fetchAppsMetadata().then((res) => { setAppsAndUrls(res); }); } - }, [user]); + }, [userProfile]); const handleChange = (_: SyntheticEvent, newValue: number) => { setTabValue(newValue); @@ -127,7 +127,7 @@ export default function AppTopBar({ userManagerInstance }: Readonly logout(dispatch, userManagerInstance)} onLogoClick={() => navigate('/', { replace: true })} - user={user ?? undefined} + userProfile={userProfile ?? undefined} appsAndUrls={appsAndUrls} globalVersionPromise={() => AppsMetadataSrv.fetchVersion().then((res) => res?.deployVersion ?? 'unknown')} additionalModulesPromise={StudySrv.getServersInfos} @@ -143,7 +143,7 @@ export default function AppTopBar({ userManagerInstance }: Readonly Date: Fri, 22 May 2026 17:07:22 +0200 Subject: [PATCH 5/5] upgrade commons-ui version --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5060dd18..0b248101 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.1", - "@gridsuite/commons-ui": "0.211.0", + "@gridsuite/commons-ui": "0.214.0", "@hookform/resolvers": "^4.1.3", "@mui/icons-material": "^6.5.0", "@mui/lab": "6.0.1-beta.36", @@ -3099,9 +3099,9 @@ } }, "node_modules/@gridsuite/commons-ui": { - "version": "0.211.0", - "resolved": "https://registry.npmjs.org/@gridsuite/commons-ui/-/commons-ui-0.211.0.tgz", - "integrity": "sha512-6v2ZSeiqh8DQPvzXHj/fz80zHZwE+oMrO8K1YEson4coqCGA05HuDU8eVeYlaljjY22pc+vf9wtHqOAnPbOMWg==", + "version": "0.214.0", + "resolved": "https://registry.npmjs.org/@gridsuite/commons-ui/-/commons-ui-0.214.0.tgz", + "integrity": "sha512-I8IfmL+jbS3QjTzDs7bO1SnPPVW6XLjN2Il+WWhkRAxUhboLgO5IBI5QYkJEQmLRxNubFFyfPrHPQPOTIHqJUw==", "license": "MPL-2.0", "dependencies": { "@ag-grid-community/locale": "^33.3.2", diff --git a/package.json b/package.json index 853dd150..57ed67e9 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "dependencies": { "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.1", - "@gridsuite/commons-ui": "0.211.0", + "@gridsuite/commons-ui": "0.214.0", "@hookform/resolvers": "^4.1.3", "@mui/icons-material": "^6.5.0", "@mui/lab": "6.0.1-beta.36",