From 6f262dfa814b01f2459b2158b48b1a531d1707f3 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 21:55:18 -0700 Subject: [PATCH] [Multiple Datasource] Fix style of data source option inside popover for data source selector, selectable, multi select components (#6438) (#6467) * 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 (cherry picked from commit eef417c03e7c4d34e85c70edb6c2079528ebc683) Signed-off-by: github-actions[bot] # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] --- .../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 +- 14 files changed, 122 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/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 17aa35d8b8d0..7c32cd3cd3df 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`] = ` />
-