Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Multiple Datasource] Fix style of data source option inside popover for data source selector, selectable, multi select components #6438

Merged
merged 7 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,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] 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;
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change the name to _data_source_selectable.cscc as a underscore _ shows this is a internal style file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should follow the dev guide Do not use the underscore _ SASS file naming pattern when importing directly into a javascript file. in https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/DEVELOPER_GUIDE.md#sass-files

Loading
Loading