Skip to content

Commit

Permalink
[Multiple Datasource] Fix style of data source option inside popover …
Browse files Browse the repository at this point in the history
…for data source selector, selectable, multi select components (opensearch-project#6438)

* adjust style

Signed-off-by: Lu Yu <[email protected]>

* fix style for data source components

Signed-off-by: Lu Yu <[email protected]>

* clean up

Signed-off-by: Lu Yu <[email protected]>

* add change log

Signed-off-by: Lu Yu <[email protected]>

* remove unused style prop

Signed-off-by: Lu Yu <[email protected]>

* fix snapshot

Signed-off-by: Lu Yu <[email protected]>

---------

Signed-off-by: Lu Yu <[email protected]>
  • Loading branch information
BionIT authored Apr 16, 2024
1 parent ce85706 commit eef417c
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 111 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
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,
};
const defaultDataSource = null;

const component = shallow(
<DataSourceOptionItem item={item} defaultDataSource={defaultDataSource} />
<DataSourceItem option={item} defaultDataSource={defaultDataSource} />
);

expect(component.find(EuiFlexGroup)).toHaveLength(1);
Expand All @@ -36,7 +36,7 @@ describe('Test on ShowDataSourceOption', () => {
const defaultDataSource = '1';

const component = shallow(
<DataSourceOptionItem item={item} defaultDataSource={defaultDataSource} />
<DataSourceItem option={item} defaultDataSource={defaultDataSource} />
);

expect(component.find(EuiFlexGroup)).toHaveLength(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<EuiFlexGroup justifyContent="spaceBetween" className={`${className}OuiFlexGroup`}>
<EuiFlexItem className={`${className}OuiFlexItem`} grow={false}>
{option.label || ''}
</EuiFlexItem>
{option.id === defaultDataSource && (
<EuiFlexItem grow={false}>
<EuiBadge iconSide="left">Default</EuiBadge>
</EuiFlexItem>
)}
</EuiFlexGroup>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export { DataSourceItem } from './data_source_item';
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { DataSourceAttributes } from '../../types';
export interface DataSourceOption {
id: string;
label?: string;
checked?: string;
}

export interface DataSourceGroupLabelOption extends DataSourceOption {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.dataSourceFilterGroupItems {
overflow: scroll;
max-width: 300px;

.dataSourceFilterGroupOuiFlexGroup {
.dataSourceFilterGroupOuiFlexItem {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
display: inline-block;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import {
EuiButtonGroup,
EuiButtonEmpty,
} from '@elastic/eui';
import { DataSourceOption } from '../data_source_selector/data_source_selector';
import { DataSourceOptionItem } from '../data_source_option';
import { DataSourceOption } from '../data_source_menu/types';
import { DataSourceItem } from '../data_source_item';
import './data_source_filter_group.scss';

export interface SelectedDataSourceOption extends DataSourceOption {
label: string;
Expand Down Expand Up @@ -138,7 +139,7 @@ export const DataSourceFilterGroup: React.FC<DataSourceFilterGroupProps> = ({
data-test-subj="dataSourceMultiSelectFieldSearch"
/>
</EuiPopoverTitle>
<div className="ouiFilterSelect__items" style={{ maxHeight: 400, overflow: 'scroll' }}>
<div className="dataSourceFilterGroupItems">
{selectedOptions.map((item, index) => {
const itemStyle: any = {};
itemStyle.display = !item.visible ? 'none' : itemStyle.display;
Expand All @@ -151,7 +152,11 @@ export const DataSourceFilterGroup: React.FC<DataSourceFilterGroupProps> = ({
showIcons={true}
style={itemStyle}
>
<DataSourceOptionItem item={item} defaultDataSource={defaultDataSource} />
<DataSourceItem
option={item}
defaultDataSource={defaultDataSource}
className={'dataSourceFilterGroup'}
/>
</EuiFilterSelectItem>
);
})}
Expand Down

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.dataSourceSelectableOuiPanel {
width: 300px;

.dataSourceSelectableOuiFlexGroup {
.dataSourceSelectableOuiFlexItem {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
display: inline-block;
}
}
}
Loading

0 comments on commit eef417c

Please sign in to comment.