diff --git a/CHANGELOG.md b/CHANGELOG.md
index c395cad4054f..a77ee9fae023 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -104,6 +104,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Workspace] Add permission tab to workspace create update page ([#6378](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6378))
- [Workspace] Hide datasource and advanced settings menu in dashboard management when in workspace. ([#6455](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6455))
- [Multiple Datasource] Modify selectable picker to remove group label and close popover after selection ([#6515](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6515))
+- [Multiple Datasource] Extract the button component for datasource picker to avoid duplicate code ([#6559](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6559))
- [Workspace] Add workspaces filter to saved objects page. ([#6458](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6458))
### 🐛 Bug Fixes
diff --git a/src/plugins/data_source_management/public/components/data_source_aggregated_view/__snapshots__/data_source_aggregated_view.test.tsx.snap b/src/plugins/data_source_management/public/components/data_source_aggregated_view/__snapshots__/data_source_aggregated_view.test.tsx.snap
index ebc28a49153f..3df5b5be920d 100644
--- a/src/plugins/data_source_management/public/components/data_source_aggregated_view/__snapshots__/data_source_aggregated_view.test.tsx.snap
+++ b/src/plugins/data_source_management/public/components/data_source_aggregated_view/__snapshots__/data_source_aggregated_view.test.tsx.snap
@@ -5,14 +5,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou
}
closePopover={[Function]}
@@ -134,14 +129,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou
}
closePopover={[Function]}
@@ -269,14 +259,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou
}
closePopover={[Function]}
@@ -392,14 +377,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou
}
closePopover={[Function]}
@@ -521,14 +501,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou
}
closePopover={[Function]}
@@ -650,14 +625,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou
}
closePopover={[Function]}
@@ -785,14 +755,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou
}
closePopover={[Function]}
@@ -908,14 +873,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou
}
closePopover={[Function]}
@@ -1037,14 +997,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource
}
closePopover={[Function]}
@@ -1129,14 +1084,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource
}
closePopover={[Function]}
@@ -1221,14 +1171,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource
}
closePopover={[Function]}
@@ -1313,14 +1258,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource
}
closePopover={[Function]}
@@ -1405,14 +1345,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource
}
closePopover={[Function]}
@@ -1497,14 +1432,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource
}
closePopover={[Function]}
@@ -1589,14 +1519,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource
}
closePopover={[Function]}
@@ -1681,14 +1606,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource
}
closePopover={[Function]}
@@ -1773,14 +1693,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource
}
closePopover={[Function]}
@@ -1865,14 +1780,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource
}
closePopover={[Function]}
diff --git a/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.tsx b/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.tsx
index 775d5e5c3e67..16549afd480d 100644
--- a/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.tsx
+++ b/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.tsx
@@ -28,6 +28,7 @@ import { DataSourceOption } from '../data_source_menu/types';
import { DataSourceItem } from '../data_source_item';
import { DataSourceDropDownHeader } from '../drop_down_header';
import './data_source_aggregated_view.scss';
+import { PopoverButton } from '../popover_button/popover_button';
interface DataSourceAggregatedViewProps {
savedObjectsClient: SavedObjectsClientContract;
@@ -135,19 +136,6 @@ export class DataSourceAggregatedView extends React.Component<
if (this.state.showError) {
return ;
}
- const button = (
-
- );
let items: DataSourceOptionDisplay[] = [];
@@ -196,7 +184,12 @@ export class DataSourceAggregatedView extends React.Component<
<>
+ }
isOpen={this.state.isPopoverOpen}
closePopover={this.closePopover.bind(this)}
panelPaddingSize="none"
diff --git a/src/plugins/data_source_management/public/components/data_source_menu/__snapshots__/create_data_source_menu.test.tsx.snap b/src/plugins/data_source_management/public/components/data_source_menu/__snapshots__/create_data_source_menu.test.tsx.snap
index c705db9194b0..7ebf4e5a5f80 100644
--- a/src/plugins/data_source_management/public/components/data_source_menu/__snapshots__/create_data_source_menu.test.tsx.snap
+++ b/src/plugins/data_source_management/public/components/data_source_menu/__snapshots__/create_data_source_menu.test.tsx.snap
@@ -103,9 +103,9 @@ Object {
class="euiPopover__anchor"
>