Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
73db878
use user Profile instead of user
ghazwarhili Jun 8, 2026
baeeed9
fix prettier
ghazwarhili Jun 8, 2026
9dd48f7
Avoid booting the full app inside the OIDC silent-renew iframe
ghazwarhili Jun 16, 2026
ef22603
Merge branch 'main' into cleanup-apache-config-requests
ghazwarhili Jun 16, 2026
a54b761
avoid loading full app bundle in silent renew iframe
ghazwarhili Jun 18, 2026
e4dd15c
Merge remote-tracking branch 'origin/cleanup-apache-config-requests' …
ghazwarhili Jun 18, 2026
c5763d4
Merge branch 'main' into cleanup-apache-config-requests
ghazwarhili Jun 18, 2026
cd6282a
serve a minimal HTML on the silent renew callback route
ghazwarhili Jun 18, 2026
1ce33c8
Revert "serve a minimal HTML on the silent renew callback route"
ghazwarhili Jun 23, 2026
e03e98f
Merge branch 'main' into cleanup-apache-config-requests
ghazwarhili Jun 23, 2026
b347286
rabbit remarks
ghazwarhili Jun 23, 2026
a29740d
typo fix
ghazwarhili Jun 23, 2026
cb0b3bf
Merge branch 'main' into cleanup-apache-config-requests
ghazwarhili Jun 24, 2026
044337b
code review remarks
ghazwarhili Jun 24, 2026
75bfe03
Merge branch 'main' into cleanup-apache-config-requests
ghazwarhili Jun 24, 2026
0f75bc9
code review remarks
ghazwarhili Jun 24, 2026
e36f369
Revert "code review remarks"
ghazwarhili Jun 24, 2026
44682cc
upgrade commons-ui version
ghazwarhili Jun 25, 2026
94e3d60
Merge branch 'main' into cleanup-apache-config-requests
ghazwarhili Jun 25, 2026
ee75d93
fix sonar issue
ghazwarhili Jun 25, 2026
782e607
Merge remote-tracking branch 'origin/cleanup-apache-config-requests' …
ghazwarhili Jun 25, 2026
445ac89
fix sonar issue
ghazwarhili Jun 25, 2026
132e553
fix sonar issue
ghazwarhili Jun 25, 2026
6e1b052
fix sonar issue
ghazwarhili Jun 25, 2026
7b9e186
Merge branch 'main' into cleanup-apache-config-requests
etiennehomer Jul 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<body class="singlestretch-parent singlestretch-child">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root" class="singlestretch-parent singlestretch-child"></div>
<script type="module" src="/src/index.jsx"></script>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
24 changes: 14 additions & 10 deletions src/components/parameters-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@
const ParametersTabs: FunctionComponent = () => {
const dispatch = useDispatch();
const attemptedLeaveParametersTabIndex = useSelector((state: AppState) => state.attemptedLeaveParametersTabIndex);
const user = useSelector((state: AppState) => state.user);
const userProfile = useSelector(
(state: AppState) => state.user?.profile ?? null,
(a, b) =>
a === b || (a?.sub === b?.sub && a?.name === b?.name && a?.email === b?.email && a?.profile === b?.profile)
);
Comment thread
ghazwarhili marked this conversation as resolved.
const studyUuid = useSelector((state: AppState) => state.studyUuid);
const currentNode = useSelector((state: AppState) => state.currentTreeNode ?? null);
const currentNodeUuid = useSelector((state: AppState) => state.currentTreeNode?.id ?? null);
Expand Down Expand Up @@ -147,7 +151,7 @@
}, [computationStatus, shortCircuitOneBusStatus, tabValue]);

const loadFlowParametersBackend = useParametersBackend(
user,
userProfile,

Check failure on line 154 in src/components/parameters-tabs.tsx

View workflow job for this annotation

GitHub Actions / build / build

Argument of type 'IdTokenClaims | null' is not assignable to parameter of type 'User | null'.
studyUuid,
ComputingType.LOAD_FLOW,
OptionalServicesStatus.Up,
Expand All @@ -162,7 +166,7 @@
useParametersNotification(ComputingType.LOAD_FLOW, OptionalServicesStatus.Up, loadFlowParametersBackend);

const securityAnalysisParametersBackend = useParametersBackend(
user,
userProfile,

Check failure on line 169 in src/components/parameters-tabs.tsx

View workflow job for this annotation

GitHub Actions / build / build

Argument of type 'IdTokenClaims | null' is not assignable to parameter of type 'User | null'.
studyUuid,
ComputingType.SECURITY_ANALYSIS,
securityAnalysisAvailability,
Expand Down Expand Up @@ -192,7 +196,7 @@
);

const sensitivityAnalysisBackend = useParametersBackend(
user,
userProfile,

Check failure on line 199 in src/components/parameters-tabs.tsx

View workflow job for this annotation

GitHub Actions / build / build

Argument of type 'IdTokenClaims | null' is not assignable to parameter of type 'User | null'.
studyUuid,
ComputingType.SENSITIVITY_ANALYSIS,
sensitivityAnalysisAvailability,
Expand All @@ -208,7 +212,7 @@
);

const shortCircuitParametersBackend = useParametersBackend(
user,
userProfile,

Check failure on line 215 in src/components/parameters-tabs.tsx

View workflow job for this annotation

GitHub Actions / build / build

Argument of type 'IdTokenClaims | null' is not assignable to parameter of type 'User | null'.
studyUuid,
ComputingType.SHORT_CIRCUIT,
shortCircuitAvailability,
Expand All @@ -221,7 +225,7 @@
useParametersNotification(ComputingType.SHORT_CIRCUIT, shortCircuitAvailability, shortCircuitParametersBackend);

const dynamicSimulationParametersBackend = useParametersBackend(
user,
userProfile,

Check failure on line 228 in src/components/parameters-tabs.tsx

View workflow job for this annotation

GitHub Actions / build / build

Argument of type 'IdTokenClaims | null' is not assignable to parameter of type 'User | null'.
studyUuid,
ComputingType.DYNAMIC_SIMULATION,
dynamicSimulationAvailability,
Expand All @@ -238,7 +242,7 @@
);

const dynamicSecurityAnalysisParametersBackend = useParametersBackend(
user,
userProfile,

Check failure on line 245 in src/components/parameters-tabs.tsx

View workflow job for this annotation

GitHub Actions / build / build

Argument of type 'IdTokenClaims | null' is not assignable to parameter of type 'User | null'.
studyUuid,
ComputingType.DYNAMIC_SECURITY_ANALYSIS,
dynamicSecurityAnalysisAvailability,
Expand All @@ -255,7 +259,7 @@
);

const dynamicMarginCalculationParametersBackend = useParametersBackend(
user,
userProfile,

Check failure on line 262 in src/components/parameters-tabs.tsx

View workflow job for this annotation

GitHub Actions / build / build

Argument of type 'IdTokenClaims | null' is not assignable to parameter of type 'User | null'.
studyUuid,
ComputingType.DYNAMIC_MARGIN_CALCULATION,
dynamicMarginCalculationAvailability,
Expand Down Expand Up @@ -444,7 +448,7 @@
<NetworkVisualizationParametersInline
studyUuid={studyUuid}
setHaveDirtyFields={setDirtyFields}
user={user}
userProfile={userProfile}

Check failure on line 451 in src/components/parameters-tabs.tsx

View workflow job for this annotation

GitHub Actions / build / build

Type '{ studyUuid: `${string}-${string}-${string}-${string}-${string}` | null; setHaveDirtyFields: (isDirty: boolean) => void; userProfile: IdTokenClaims | null; parameters: NetworkVisualizationParameters | null; }' is not assignable to type 'IntrinsicAttributes & Readonly<{ studyUuid: `${string}-${string}-${string}-${string}-${string}` | null; setHaveDirtyFields: (isDirty: boolean) => void; user: User | null; parameters: NetworkVisualizationParameters | null; }>'.
parameters={networkVisualizationsParameters}
/>
);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Expand All @@ -467,7 +471,7 @@
currentNode?.type,
shortCircuitParametersBackend,
pccMinParameters,
user,
userProfile,
dynamicSimulationParametersBackend,
dynamicSecurityAnalysisParametersBackend,
dynamicMarginCalculationParametersBackend,
Expand Down
42 changes: 42 additions & 0 deletions src/components/silent-renew-app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Copyright (c) 2026, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { useCallback, useEffect, useState } from 'react';
import type { UserManager } from 'oidc-client-ts';
import {
handleSilentRenewCallback,
initializeAuthenticationProd,
SilentRenewCallbackHandler,
} from '@gridsuite/commons-ui';
import { getCachedIdpSettings } from 'services/utils';

export default function SilentRenewApp() {
Comment thread
ghazwarhili marked this conversation as resolved.
Outdated
const [userManager, setUserManager] = useState<UserManager | null>(null);

useEffect(() => {
initializeAuthenticationProd(
() => undefined /* dispatch: unused when isSilentRenew=true */,
true /* isSilentRenew */,
getCachedIdpSettings /* reads the cache instead of fetching idpSettings.json */,
false /* isSigningCallback */
)
.then(setUserManager)
.catch((e) => console.error('Silent renew init failed:', e));
}, []);

const handleSilentRenewCallbackClosure = useCallback(() => {
if (userManager) {
handleSilentRenewCallback(userManager);
}
}, [userManager]);

return (
<SilentRenewCallbackHandler
userManager={userManager}
handleSilentRenewCallback={handleSilentRenewCallbackClosure}
/>
);
}
22 changes: 0 additions & 22 deletions src/index.jsx

This file was deleted.

27 changes: 27 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (c) 2020, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { createRoot } from 'react-dom/client';
import SilentRenewApp from './components/silent-renew-app';

const container = document.getElementById('root');
const root = createRoot(container!);

async function renderApp() {
if (window.location.pathname.endsWith('/silent-renew-callback')) {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
Comment thread
ghazwarhili marked this conversation as resolved.
Outdated
root.render(<SilentRenewApp />);
return;
}
await import('core-js/es/array/flat-map');
await import('typeface-roboto');
Comment thread
ghazwarhili marked this conversation as resolved.
Outdated
await import('@xyflow/react/dist/base.css');
await import('./index.css');
await import('./configure-yup-init');
const { default: AppWrapper } = await import('./components/app-wrapper');
root.render(<AppWrapper />);
}
renderApp().catch((error) => console.error(error));
29 changes: 25 additions & 4 deletions src/services/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { catchErrorHandler, fetchStudyMetadata, StudyMetadata } from '@gridsuite/commons-ui';
import { catchErrorHandler, fetchStudyMetadata, IdpSettings, StudyMetadata } from '@gridsuite/commons-ui';
export const FetchStatus = {
SUCCEED: 'SUCCEED',
FAILED: 'FAILED',
Expand All @@ -13,7 +13,7 @@ export const FetchStatus = {
};

export const MAX_INT32: number = 2147483647;

const IDP_SETTINGS_CACHE_KEY = 'gridsuite-idp-settings';
type DefaultParameters = StudyMetadata['defaultParametersValues'];
export const getWsBase = () => document.baseURI.replace(/^http:\/\//, 'ws://').replace(/^https:\/\//, 'wss://');

Expand Down Expand Up @@ -49,8 +49,29 @@ function fetchEnv() {
return fetch('env.json').then((res) => res.json());
}

export function fetchIdpSettings() {
return fetch('idpSettings.json').then((res) => res.json());
// Always hits the network: picks up config changes on each full app load
// AND refreshes the cache read by the silent-renew iframe.
export function fetchIdpSettings(): Promise<IdpSettings> {
return fetch('idpSettings.json')
.then((res) => res.json())
.then((settings: IdpSettings) => {
localStorage.setItem(IDP_SETTINGS_CACHE_KEY, JSON.stringify(settings));
return settings;
});
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// Used only on the silent-renew path: reads the cache (no network),
// falls back to a real fetch if the cache is missing/corrupted.
export function getCachedIdpSettings(): Promise<IdpSettings> {
const cached = localStorage.getItem(IDP_SETTINGS_CACHE_KEY);
if (cached) {
try {
return Promise.resolve(JSON.parse(cached) as IdpSettings);
} catch {
// corrupted cache -> fall back to a fresh fetch
}
}
return fetchIdpSettings();
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

export function fetchVersion() {
Expand Down
2 changes: 2 additions & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@

/// <reference types="vite-plugin-svgr/client" />
/// <reference types="vite/client" />
declare module 'typeface-roboto';
Comment thread
ghazwarhili marked this conversation as resolved.
Outdated
declare module 'core-js/es/array/flat-map';
Loading