Skip to content

Commit 5510563

Browse files
committed
fix(SA,SE,CC): reset export successful states when button is disabled which happen when results change or computation status change.
Remark: For other computation types (LF, State estim, Voltage init), we need more work in commons-ui on `CsvExport` component, to use `isDownloadLoading` and `isDownloadSuccessful` of the `ExportCsvButton` child component even if its direct export without backend requests Signed-off-by: sBouzols <[email protected]>
1 parent c0ef875 commit 5510563

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/components/results/securityanalysis/security-analysis-export-button.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ export const SecurityAnalysisExportButton: FunctionComponent<SecurityAnalysisExp
4141
setIsCsvExportSuccessful(false);
4242
}, [nodeUuid, resultType]);
4343

44+
useEffect(() => {
45+
if (disabled) {
46+
// reinit the success state when the button is disabled,
47+
// for example when the calcul status change or results change
48+
setIsCsvExportSuccessful(false);
49+
}
50+
}, [disabled]);
51+
4452
const enumValueTranslations = useMemo(() => {
4553
const returnedValue: Record<string, string> = {
4654
[PERMANENT_LIMIT_NAME]: intl.formatMessage({

src/components/results/sensitivity-analysis/sensitivity-analysis-result-tab.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
77

8-
import { SyntheticEvent, useCallback, useMemo, useState } from 'react';
8+
import { SyntheticEvent, useCallback, useEffect, useMemo, useState } from 'react';
99
import { Box, LinearProgress, Tab, Tabs } from '@mui/material';
1010
import SensitivityAnalysisTabs from './sensitivity-analysis-tabs.js';
1111
import PagedSensitivityAnalysisResult from './paged-sensitivity-analysis-result';
@@ -177,6 +177,14 @@ function SensitivityAnalysisResultTab({
177177
[voltageLevelsFilter, countriesFilter, propertiesFilter]
178178
);
179179

180+
useEffect(() => {
181+
if (isCsvButtonDisabled) {
182+
// reinit the success state when the button is disabled,
183+
// for example when the calcul status change or results change
184+
setIsCsvExportSuccessful(false);
185+
}
186+
}, [isCsvButtonDisabled]);
187+
180188
return (
181189
<>
182190
<SensitivityAnalysisTabs sensiTab={sensiTab} setSensiTab={handleSensiTabChange} />

src/components/results/shortcircuit/shortcircuit-analysis-export-button.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ export const ShortCircuitExportButton: FunctionComponent<ShortCircuitExportButto
4040
setIsCsvExportSuccessful(false);
4141
}, [nodeUuid, analysisType]);
4242

43+
useEffect(() => {
44+
if (disabled) {
45+
// reinit the success state when the button is disabled,
46+
// for example when the calcul status change or results change
47+
setIsCsvExportSuccessful(false);
48+
}
49+
}, [disabled]);
50+
4351
const enumValueTranslations = useMemo(() => {
4452
const returnedValue: Record<string, string> = {};
4553
const enumValuesToTranslate = [

0 commit comments

Comments
 (0)