From e8f219b3febaaa5d5d7ce21cd9c39dc560268e0e Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 5 Oct 2023 03:34:39 +0000 Subject: [PATCH] address dedup Signed-off-by: Eric --- .../datasource_selector/datasource_selectable.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx b/src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx index 57e6d86ece12..7256ee56fb8b 100644 --- a/src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx +++ b/src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx @@ -91,7 +91,11 @@ export const DataSourceSelectable = ({ // check if add new datasource group or add to existing one if (existingGroup) { - existingGroup.options.push(...mappedOptions); + const existingOptionIds = new Set(existingGroup.options.map((opt) => opt.label)); + const nonDuplicateOptions = mappedOptions.filter( + (opt) => !existingOptionIds.has(opt.label) + ); + existingGroup.options.push(...nonDuplicateOptions); } else { finalList.push({ label: groupName,