Skip to content

Commit

Permalink
front: reset stdcm state when hitting "new query" button
Browse files Browse the repository at this point in the history
Signed-off-by: Clara Ni <[email protected]>
  • Loading branch information
clarani committed Jan 3, 2025
1 parent 2d1a142 commit 4aec1d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions front/src/applications/stdcm/hooks/useStdcm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ const useStdcm = ({

const { speedLimitByTag } = useStoreDataForSpeedLimitByTagSelector({ isStdcm: true });

const resetStdcmState = () => {
setStdcmTrainResult(undefined);
setStdcmTrainConflicts(undefined);
setStdcmResponse(undefined);
setPathProperties(undefined);
setCurrentStdcmRequestStatus(STDCM_REQUEST_STATUS.idle);
};

const triggerShowFailureNotification = (error: Error) => {
if (showFailureNotification) {
dispatch(setFailure(error));
Expand Down Expand Up @@ -163,6 +171,7 @@ const useStdcm = ({
stdcmResults,
launchStdcmRequest,
cancelStdcmRequest,
resetStdcmState,
pathProperties,
setPathProperties,
isPending,
Expand Down
2 changes: 2 additions & 0 deletions front/src/applications/stdcm/views/StdcmView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const StdcmView = () => {
const {
launchStdcmRequest,
cancelStdcmRequest,
resetStdcmState,
isPending,
isRejected,
isCanceled,
Expand Down Expand Up @@ -63,6 +64,7 @@ const StdcmView = () => {

const handleStartNewQuery = () => {
setSimulationsList([]);
resetStdcmState();
setSelectedSimulationIndex(-1);
setRetainedSimulationIndex(-1);
dispatch(resetStdcmConfig());
Expand Down

0 comments on commit 4aec1d0

Please sign in to comment.