Skip to content

Commit

Permalink
Merge branch 'main' into add_voltage_levels_to_the_request_when_getin…
Browse files Browse the repository at this point in the history
…g_equipment_infos
  • Loading branch information
AAJELLAL authored Jul 10, 2024
2 parents 654779b + 410a5db commit 4917a44
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 75 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@gridsuite/commons-ui": "0.61.0",
"@gridsuite/commons-ui": "0.62.0",
"@hookform/resolvers": "^3.3.4",
"@mui/icons-material": "^5.15.14",
"@mui/lab": "5.0.0-alpha.169",
Expand Down
33 changes: 16 additions & 17 deletions src/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ import {
fetchConfigParameters,
} from '../services/config';
import {
fetchAuthorizationCodeFlowFeatureFlag,
fetchDefaultParametersValues,
fetchIdpSettings,
} from '../services/utils';
Expand Down Expand Up @@ -406,23 +405,23 @@ const App = () => {
});

useEffect(() => {
fetchAuthorizationCodeFlowFeatureFlag()
.then((authorizationCodeFlowEnabled) => {
return initializeAuthenticationProd(
dispatch,
initialMatchSilentRenewCallbackUrl != null,
fetchIdpSettings(),
fetchValidateUser,
authorizationCodeFlowEnabled,
initialMatchSigninCallbackUrl != null
);
})
.then((userManager) => {
setUserManager({ instance: userManager, error: null });
})
.catch(function (error) {
// need subfunction when async as suggested by rule react-hooks/exhaustive-deps
(async function initializeAuthentication() {
try {
setUserManager({
instance: await initializeAuthenticationProd(
dispatch,
initialMatchSilentRenewCallbackUrl != null,
fetchIdpSettings,
fetchValidateUser,
initialMatchSigninCallbackUrl != null
),
error: null,
});
} catch (error) {
setUserManager({ instance: null, error: error.message });
});
}
})();
// Note: initialMatchSilentRenewCallbackUrl and dispatch don't change
}, [
initialMatchSilentRenewCallbackUrl,
Expand Down
17 changes: 5 additions & 12 deletions src/components/dialogs/export-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import IconButton from '@mui/material/IconButton';
import { CancelButton, FlatParameters } from '@gridsuite/commons-ui';
import { getAvailableExportFormats } from '../../services/study';
import { getExportUrl } from '../../services/study/network';
import { CGMES } from 'components/utils/constants';

const STRING_LIST = 'STRING_LIST';

Expand Down Expand Up @@ -167,17 +166,11 @@ const ExportDialog = ({
id: 'select-format',
}}
>
{Object.keys(formatsWithParameters)
.filter(
(format) =>
// Hide the CGMES item while waiting for the Fix of getIdentifiable on the back end
format !== CGMES
)
.map((formatKey) => (
<MenuItem key={formatKey} value={formatKey}>
{formatKey}
</MenuItem>
))}
{Object.keys(formatsWithParameters).map((formatKey) => (
<MenuItem key={formatKey} value={formatKey}>
{formatKey}
</MenuItem>
))}
</Select>
<Stack
marginTop="0.7em"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const VoltageLevelModificationDialog = ({
resolver: yupResolver(formSchema),
});

const { reset, resetField, getValues } = formMethods;
const { reset, getValues } = formMethods;

useEffect(() => {
if (editData) {
Expand Down Expand Up @@ -157,13 +157,8 @@ const VoltageLevelModificationDialog = ({
voltageLevel,
getValues
),
[SUBSTATION_ID]: voltageLevel?.substationId,
}));
//TODO We display the previous value of the substation id in the substation field because we can't change it
// To be removed when it is possible to change the substation of a voltage level in the backend (Powsybl)
// Note: we use resetField and a defaultValue instead of setValue to not trigger react hook form's dirty flag
resetField(SUBSTATION_ID, {
defaultValue: voltageLevel?.substationId,
});
}
})
.catch(() => {
Expand All @@ -176,7 +171,7 @@ const VoltageLevelModificationDialog = ({
reset(emptyFormData, { keepDefaultValues: true });
}
},
[studyUuid, currentNodeUuid, resetField, reset, getValues]
[studyUuid, currentNodeUuid, reset, getValues]
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,9 @@ export const SensitivityAnalysisParameters = ({
};
}) ?? [],
};
reset(values);
return values;
},
[reset]
[]
);

const initRowsCount = useCallback(() => {
Expand Down Expand Up @@ -514,6 +514,7 @@ export const SensitivityAnalysisParameters = ({
keepDefaultValues: true,
}
);
initRowsCount();
})
.catch((error) => {
console.error(error);
Expand All @@ -525,13 +526,20 @@ export const SensitivityAnalysisParameters = ({
}
setOpenSelectParameterDialog(false);
},
[snackError, fromSensitivityAnalysisParamsDataToFormValues, reset]
[
snackError,
fromSensitivityAnalysisParamsDataToFormValues,
reset,
initRowsCount,
]
);

useEffect(() => {
if (sensitivityAnalysisParams) {
fromSensitivityAnalysisParamsDataToFormValues(
sensitivityAnalysisParams
reset(
fromSensitivityAnalysisParamsDataToFormValues(
sensitivityAnalysisParams
)
);
!isSubmitAction && initRowsCount();
}
Expand All @@ -540,6 +548,7 @@ export const SensitivityAnalysisParameters = ({
sensitivityAnalysisParams,
initRowsCount,
isSubmitAction,
reset,
]);

const clear = useCallback(() => {
Expand Down
28 changes: 1 addition & 27 deletions src/services/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,33 +140,7 @@ function fetchEnv() {
}

export function fetchIdpSettings() {
return fetch('idpSettings.json');
}

export function fetchAuthorizationCodeFlowFeatureFlag() {
console.info(`Fetching authorization code flow feature flag...`);
return fetchEnv()
.then((env) =>
fetch(env.appsMetadataServerUrl + '/authentication.json')
)
.then((res) => res.json())
.then((res) => {
console.log(
`Authorization code flow is ${
res.authorizationCodeFlowFeatureFlag
? 'enabled'
: 'disabled'
}`
);
return res.authorizationCodeFlowFeatureFlag;
})
.catch((error) => {
console.error(error);
console.warn(
`Something wrong happened when retrieving authentication.json: authorization code flow will be disabled`
);
return false;
});
return fetch('idpSettings.json').then((res) => res.json());
}

export function fetchVersion() {
Expand Down
2 changes: 1 addition & 1 deletion src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@
"ConnectedComponent": "Composante connexe",
"SynchronousComponent": "Composante synchrone",
"Setpoints": "Consignes",
"EmptySelection": "Aucun équipement n'est sélectionné",
"EmptySelection": "Aucun ouvrage n'est sélectionné",
"Connectivity": "Connectivité",
"FieldAcceptNumeric": "Ce champ n'accepte que des valeurs numériques",
"FieldIsRequired": "Ce champ doit être renseigné",
Expand Down

0 comments on commit 4917a44

Please sign in to comment.