Skip to content

Commit

Permalink
Minor fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgenherje committed Sep 26, 2023
1 parent 51e08c8 commit cf9c0a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
28 changes: 16 additions & 12 deletions frontend/src/modules/SimulationTimeSeriesMatrix/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export function settings({ moduleContext, workbenchSession }: ModuleFCProps<Stat
setPreviousEnsembleSet(ensembleSet);
}

// Queries
const vectorListQueries = useVectorListQueries(selectedEnsembleIdents);
const ensembleVectorListsHelper = new EnsembleVectorListsHelper(selectedEnsembleIdents, vectorListQueries);
const selectedVectorNamesHasHistorical = ensembleVectorListsHelper.hasAnyHistoricalVector(selectedVectorNames);
Expand All @@ -101,8 +100,8 @@ export function settings({ moduleContext, workbenchSession }: ModuleFCProps<Stat
]);

// Await update of vectorSelectorData until all vector lists are retrieved
const hasVectorListQueriesErrorOrLoading = vectorListQueries.some((query) => query.isLoading || query.isError);
if (!hasVectorListQueriesErrorOrLoading && !isEqual(currentVectorSelectorData, vectorSelectorData)) {
const hasVectorListQueriesErrorOrFetching = vectorListQueries.some((query) => query.isFetching || query.isError);
if (!hasVectorListQueriesErrorOrFetching && !isEqual(currentVectorSelectorData, vectorSelectorData)) {
setVectorSelectorData(currentVectorSelectorData);
}

Expand Down Expand Up @@ -134,11 +133,17 @@ export function settings({ moduleContext, workbenchSession }: ModuleFCProps<Stat
return;
}

// Try/catch as ParameterIdent.fromString() can throw
try {
const newParameterIdent = ParameterIdent.fromString(selectedParameterIdentStr);
continuousAndNonConstantParametersUnion.some((parameter) => parameter.equals(newParameterIdent))
? setParameterIdent(newParameterIdent)
: setParameterIdent(null);
const isParameterInUnion = continuousAndNonConstantParametersUnion.some((parameter) =>
parameter.equals(newParameterIdent)
);
if (isParameterInUnion) {
setParameterIdent(newParameterIdent);
} else {
setParameterIdent(null);
}
} catch {
setParameterIdent(null);
}
Expand Down Expand Up @@ -300,12 +305,11 @@ export function settings({ moduleContext, workbenchSession }: ModuleFCProps<Stat
}}
/>
<div
className={resolveClassNames(
"mt-4 ml-6 mb-4",
colorRealizationsByParameter && visualizationMode === VisualizationMode.INDIVIDUAL_REALIZATIONS
? ""
: "pointer-events-none opacity-70"
)}
className={resolveClassNames("mt-4 ml-6 mb-4", {
["pointer-events-none opacity-70"]:
!colorRealizationsByParameter ||
visualizationMode !== VisualizationMode.INDIVIDUAL_REALIZATIONS,
})}
>
<Dropdown
options={continuousAndNonConstantParametersUnion.map((elm) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export class EnsembleVectorListsHelper {

// Add vector if name is not already in vectorUnion
for (const vector of query.data) {
if (!vectorUnion.some((v) => v === vector.name)) {
vectorUnion.push(vector.name);
}
if (vectorUnion.includes(vector.name)) continue;

vectorUnion.push(vector.name);
}
}
return vectorUnion;
Expand Down

0 comments on commit cf9c0a1

Please sign in to comment.