From 7c143478d395fe2d14596314e2901b1f1f46d900 Mon Sep 17 00:00:00 2001 From: Yngrid Coello Date: Fri, 26 Apr 2024 14:42:23 +0200 Subject: [PATCH] Fixing duplicated integrations entries --- .../public/hooks/use_dataset_quality_filters.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/observability_solution/dataset_quality/public/hooks/use_dataset_quality_filters.tsx b/x-pack/plugins/observability_solution/dataset_quality/public/hooks/use_dataset_quality_filters.tsx index f6dc0920a8813..56739c15c2616 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/public/hooks/use_dataset_quality_filters.tsx +++ b/x-pack/plugins/observability_solution/dataset_quality/public/hooks/use_dataset_quality_filters.tsx @@ -76,10 +76,18 @@ export const useDatasetQualityFilters = () => { ); const integrationItems: IntegrationItem[] = useMemo(() => { + const integrationsMap = datasets.reduce( + (acc, dataset) => ({ + ...acc, + ...(dataset.integration && !acc[dataset.integration.name] + ? { [dataset.integration.name]: dataset.integration } + : {}), + }), + {} as { [key: string]: Integration } + ); + const integrations = [ - ...datasets - .map((dataset) => dataset.integration) - .filter((integration): integration is Integration => !!integration), + ...Object.values(integrationsMap), ...(datasets.some((dataset) => !dataset.integration) ? [Integration.create({ name: 'none', title: 'None' })] : []),