Skip to content

Commit

Permalink
Revert the cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Nov 4, 2024
1 parent 6f07afc commit ea3e443
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/plugins/unified_histogram/public/services/lens_vis_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,33 @@ export class LensVisService {
}
}

if (externalVisContext && queryParams.isPlainRecord) {
// externalVisContext can be based on an unfamiliar suggestion (not a part of allSuggestions), but it was saved before, so we try to restore it too
const derivedSuggestion = deriveLensSuggestionFromLensAttributes({
externalVisContext,
queryParams,
});

if (derivedSuggestion) {
availableSuggestionsWithType.push({
suggestion: derivedSuggestion,
type: UnifiedHistogramSuggestionType.lensSuggestion,
});
}
}

if (externalVisContext) {
// try to find a suggestion that is compatible with the external vis context
const matchingItem = availableSuggestionsWithType.find((item) =>
isSuggestionShapeAndVisContextCompatible(item.suggestion, externalVisContext)
);

if (matchingItem) {
currentSuggestion = matchingItem.suggestion;
type = matchingItem.type;
}
}

if (!currentSuggestion && availableSuggestionsWithType.length) {
// otherwise pick any first available suggestion
currentSuggestion = availableSuggestionsWithType[0].suggestion;
Expand Down

0 comments on commit ea3e443

Please sign in to comment.