From eef417c03e7c4d34e85c70edb6c2079528ebc683 Mon Sep 17 00:00:00 2001 From: Lu Yu Date: Mon, 15 Apr 2024 19:09:46 -0700 Subject: [PATCH] [Multiple Datasource] Fix style of data source option inside popover for data source selector, selectable, multi select components (#6438) * adjust style Signed-off-by: Lu Yu * fix style for data source components Signed-off-by: Lu Yu * clean up Signed-off-by: Lu Yu * add change log Signed-off-by: Lu Yu * remove unused style prop Signed-off-by: Lu Yu * fix snapshot Signed-off-by: Lu Yu --------- Signed-off-by: Lu Yu --- CHANGELOG.md | 1 + .../data_source_item.test.tsx} | 10 +++--- .../data_source_item/data_source_item.tsx | 28 +++++++++++++++ .../components/data_source_item/index.ts | 6 ++++ .../components/data_source_menu/types.ts | 1 + .../data_source_filter_group.test.tsx.snap | 27 ++++++-------- .../data_source_filter_group.scss | 13 +++++++ .../data_source_filter_group.tsx | 13 ++++--- .../public/components/data_source_option.tsx | 29 --------------- .../data_source_selectable.test.tsx.snap | 21 +++-------- .../data_source_selectable.scss | 12 +++++++ .../data_source_selectable.tsx | 36 ++++++++----------- .../data_source_selector.scss | 8 +++++ .../data_source_selector.tsx | 27 ++++++-------- .../public/components/utils.ts | 2 +- 15 files changed, 123 insertions(+), 111 deletions(-) rename src/plugins/data_source_management/public/components/{data_source_option.test.tsx => data_source_item/data_source_item.test.tsx} (74%) create mode 100644 src/plugins/data_source_management/public/components/data_source_item/data_source_item.tsx create mode 100644 src/plugins/data_source_management/public/components/data_source_item/index.ts create mode 100644 src/plugins/data_source_management/public/components/data_source_multi_selectable/data_source_filter_group.scss delete mode 100644 src/plugins/data_source_management/public/components/data_source_option.tsx create mode 100644 src/plugins/data_source_management/public/components/data_source_selectable/data_source_selectable.scss create mode 100644 src/plugins/data_source_management/public/components/data_source_selector/data_source_selector.scss diff --git a/CHANGELOG.md b/CHANGELOG.md index 1440915fa3a2..cc9b07e96655 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -114,6 +114,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - [Workspace] Add base path when parse url in http service ([#6233](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6233)) - [Multiple Datasource] Fix sslConfig for multiple datasource to handle when certificateAuthorities is unset ([#6282](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6282)) - [BUG][Multiple Datasource]Fix bug in data source aggregated view to change it to depend on displayAllCompatibleDataSources property to show the badge value ([#6291](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6291)) +- [BUG][Multiple Datasource] Fix style of data source option inside popover for data source selector, selectable, multi select components ([#6438](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6438)) - [BUG][Multiple Datasource]Read hideLocalCluster setting from yml and set in data source selector and data source menu ([#6361](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6361)) - [BUG][Multiple Datasource] Refactor read-only component to cover more edge cases ([#6416](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6416)) - [BUG] Fix for checkForFunctionProperty so that order does not matter ([#6248](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6248)) diff --git a/src/plugins/data_source_management/public/components/data_source_option.test.tsx b/src/plugins/data_source_management/public/components/data_source_item/data_source_item.test.tsx similarity index 74% rename from src/plugins/data_source_management/public/components/data_source_option.test.tsx rename to src/plugins/data_source_management/public/components/data_source_item/data_source_item.test.tsx index 7d6375f47d29..8cb736f2fb61 100644 --- a/src/plugins/data_source_management/public/components/data_source_option.test.tsx +++ b/src/plugins/data_source_management/public/components/data_source_item/data_source_item.test.tsx @@ -6,12 +6,12 @@ import { shallow } from 'enzyme'; import React from 'react'; import { EuiBadge, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { DataSourceOptionItem } from './data_source_option'; -import { SelectedDataSourceOption } from './data_source_multi_selectable/data_source_filter_group'; +import { DataSourceItem } from '.'; +import { DataSourceOption } from '../data_source_menu/types'; describe('Test on ShowDataSourceOption', () => { it('should render the component with label', () => { - const item: SelectedDataSourceOption = { + const item: DataSourceOption = { id: '1', label: 'DataSource 1', visible: true, @@ -19,7 +19,7 @@ describe('Test on ShowDataSourceOption', () => { const defaultDataSource = null; const component = shallow( - + ); expect(component.find(EuiFlexGroup)).toHaveLength(1); @@ -36,7 +36,7 @@ describe('Test on ShowDataSourceOption', () => { const defaultDataSource = '1'; const component = shallow( - + ); expect(component.find(EuiFlexGroup)).toHaveLength(1); diff --git a/src/plugins/data_source_management/public/components/data_source_item/data_source_item.tsx b/src/plugins/data_source_management/public/components/data_source_item/data_source_item.tsx new file mode 100644 index 000000000000..06064ccd1836 --- /dev/null +++ b/src/plugins/data_source_management/public/components/data_source_item/data_source_item.tsx @@ -0,0 +1,28 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ +import React from 'react'; +import { EuiBadge, EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; +import { DataSourceOption } from '../data_source_menu/types'; + +interface DataSourceItemProps { + className: string; + option: DataSourceOption[]; + defaultDataSource: string | null; +} + +export const DataSourceItem = ({ className, option, defaultDataSource }: DataSourceItemProps) => { + return ( + + + {option.label || ''} + + {option.id === defaultDataSource && ( + + Default + + )} + + ); +}; diff --git a/src/plugins/data_source_management/public/components/data_source_item/index.ts b/src/plugins/data_source_management/public/components/data_source_item/index.ts new file mode 100644 index 000000000000..92148b4ce5b5 --- /dev/null +++ b/src/plugins/data_source_management/public/components/data_source_item/index.ts @@ -0,0 +1,6 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export { DataSourceItem } from './data_source_item'; diff --git a/src/plugins/data_source_management/public/components/data_source_menu/types.ts b/src/plugins/data_source_management/public/components/data_source_menu/types.ts index ca589b0ccb4b..a37d7d0dd0c3 100644 --- a/src/plugins/data_source_management/public/components/data_source_menu/types.ts +++ b/src/plugins/data_source_management/public/components/data_source_menu/types.ts @@ -14,6 +14,7 @@ import { DataSourceAttributes } from '../../types'; export interface DataSourceOption { id: string; label?: string; + checked?: string; } export interface DataSourceGroupLabelOption extends DataSourceOption { diff --git a/src/plugins/data_source_management/public/components/data_source_multi_selectable/__snapshots__/data_source_filter_group.test.tsx.snap b/src/plugins/data_source_management/public/components/data_source_multi_selectable/__snapshots__/data_source_filter_group.test.tsx.snap index fe89b1409510..6dd693913865 100644 --- a/src/plugins/data_source_management/public/components/data_source_multi_selectable/__snapshots__/data_source_filter_group.test.tsx.snap +++ b/src/plugins/data_source_management/public/components/data_source_multi_selectable/__snapshots__/data_source_filter_group.test.tsx.snap @@ -43,13 +43,7 @@ exports[`DataSourceFilterGroup should render normally 1`] = ` />
-