From d2efc747dd76b06efa4145ca06a060d01a6ae018 Mon Sep 17 00:00:00 2001 From: "Yuanqi(Ella) Zhu" Date: Fri, 19 Apr 2024 18:52:55 +0000 Subject: [PATCH] Extract the button component for datasource picker to avoid duplicate code Signed-off-by: Yuanqi(Ella) Zhu --- CHANGELOG.md | 1 + .../data_source_aggregated_view.test.tsx.snap | 162 ++++-------------- .../data_source_aggregated_view.tsx | 21 +-- .../create_data_source_menu.test.tsx.snap | 18 +- .../data_source_menu.test.tsx.snap | 12 +- .../data_source_selectable.test.tsx.snap | 65 +++---- .../data_source_selectable.test.tsx | 12 +- .../data_source_selectable.tsx | 35 ++-- .../data_source_view.test.tsx.snap | 48 ++---- .../data_source_view/data_source_view.tsx | 29 +--- .../popover_button/popover_button.test.tsx | 29 ++++ .../popover_button/popover_button.tsx | 33 ++++ 12 files changed, 183 insertions(+), 282 deletions(-) create mode 100644 src/plugins/data_source_management/public/components/popover_button/popover_button.test.tsx create mode 100644 src/plugins/data_source_management/public/components/popover_button/popover_button.tsx 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 57ba243a476b..7c799c8d99bc 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]} @@ -142,14 +137,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou } closePopover={[Function]} @@ -285,14 +275,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou } closePopover={[Function]} @@ -416,14 +401,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou } closePopover={[Function]} @@ -553,14 +533,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou } closePopover={[Function]} @@ -690,14 +665,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou } closePopover={[Function]} @@ -833,14 +803,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou } closePopover={[Function]} @@ -964,14 +929,9 @@ exports[`DataSourceAggregatedView: read active view (displayAllCompatibleDataSou } closePopover={[Function]} @@ -1101,14 +1061,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource } closePopover={[Function]} @@ -1201,14 +1156,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource } closePopover={[Function]} @@ -1301,14 +1251,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource } closePopover={[Function]} @@ -1401,14 +1346,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource } closePopover={[Function]} @@ -1501,14 +1441,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource } closePopover={[Function]} @@ -1601,14 +1536,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource } closePopover={[Function]} @@ -1701,14 +1631,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource } closePopover={[Function]} @@ -1801,14 +1726,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource } closePopover={[Function]} @@ -1901,14 +1821,9 @@ exports[`DataSourceAggregatedView: read all view (displayAllCompatibleDataSource } closePopover={[Function]} @@ -2001,14 +1916,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 16b63d36d912..b9bb61a46efb 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" >