Skip to content

Commit

Permalink
address dedup
Browse files Browse the repository at this point in the history
Signed-off-by: Eric <menwe@amazon.com>
  • Loading branch information
mengweieric committed Oct 5, 2023
1 parent 811347c commit e8f219b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 96 in src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx#L94-L96

Added lines #L94 - L96 were not covered by tests
);
existingGroup.options.push(...nonDuplicateOptions);

Check warning on line 98 in src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/data_sources/datasource_selector/datasource_selectable.tsx#L98

Added line #L98 was not covered by tests
} else {
finalList.push({
label: groupName,
Expand Down

0 comments on commit e8f219b

Please sign in to comment.