From eaba110cfe17285be3eef071a3fd799c80e07585 Mon Sep 17 00:00:00 2001 From: Ruben Thoms <69145689+rubenthoms@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:09:02 +0100 Subject: [PATCH] Bug fix: Keeping the newly selected ensembles in dialog when loading from backend (#480) --- .../framework/internal/components/NavBar/navBar.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/framework/internal/components/NavBar/navBar.tsx b/frontend/src/framework/internal/components/NavBar/navBar.tsx index 65c4e75d9..309589020 100644 --- a/frontend/src/framework/internal/components/NavBar/navBar.tsx +++ b/frontend/src/framework/internal/components/NavBar/navBar.tsx @@ -28,6 +28,7 @@ const NavBarDivider: React.FC = () => { export const NavBar: React.FC = (props) => { const [ensembleDialogOpen, setEnsembleDialogOpen] = React.useState(false); + const [newSelectedEnsembles, setNewSelectedEnsembles] = React.useState([]); const [layoutEmpty, setLayoutEmpty] = React.useState(props.workbench.getLayout().length === 0); const [expanded, setExpanded] = React.useState(localStorage.getItem("navBarExpanded") === "true"); const loadingEnsembleSet = useIsEnsembleSetLoading(props.workbench.getWorkbenchSession()); @@ -108,19 +109,25 @@ export const NavBar: React.FC = (props) => { localStorage.setItem("navBarExpanded", (!expanded).toString()); } - const selectedEnsembles = ensembleSet.getEnsembleArr().map((ens) => ({ + const selectedEnsembles: EnsembleItem[] = ensembleSet.getEnsembleArr().map((ens) => ({ caseUuid: ens.getCaseUuid(), caseName: ens.getCaseName(), ensembleName: ens.getEnsembleName(), })); function loadAndSetupEnsembles(selectedEnsembles: EnsembleItem[]): Promise { + setNewSelectedEnsembles(selectedEnsembles); const selectedEnsembleIdents = selectedEnsembles.map( (ens) => new EnsembleIdent(ens.caseUuid, ens.ensembleName) ); return props.workbench.loadAndSetupEnsembleSetInSession(queryClient, selectedEnsembleIdents); } + let fixedSelectedEnsembles = selectedEnsembles; + if (loadingEnsembleSet) { + fixedSelectedEnsembles = newSelectedEnsembles; + } + return (
= (props) => { {ensembleDialogOpen && ( )}