Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into copy
Browse files Browse the repository at this point in the history
  • Loading branch information
gaobinlong committed Apr 11, 2024
2 parents 55b902d + 7e1d940 commit 42242bb
Show file tree
Hide file tree
Showing 27 changed files with 1,281 additions and 234 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,16 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Multiple Datasource] Enhanced data source selector with default datasource shows as first choice ([#6293](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6293))
- [Multiple Datasource] Add multi data source support to sample vega visualizations ([#6218](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6218))
- [Multiple Datasource] Fetch data source title for DataSourceView when only id is provided ([#6315](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6315)
- [Multiple Datasource] Get data source label when only id is provided in DataSourceSelectable ([#6358](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6358)
- [Workspace] Add permission control logic ([#6052](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6052))
- [Multiple Datasource] Add default icon for selectable component and make sure the default datasource shows automatically ([#6327](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6327))
- [Multiple Datasource] Pass selected data sources to plugin consumers when the multi-select component initially loads ([#6333](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6333))
- [Multiple Datasource] Add installedPlugins list to data source saved object ([#6348](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6348))
- [Multiple Datasource] Add default icon in multi-selectable picker ([#6357](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6357))
- [Workspace] Add APIs to support plugin state in request ([#6303](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6303))
- [Workspace] Filter left nav menu items according to the current workspace ([#6234](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6234))
- [Multiple Datasource] Refactor data source selector component to include placeholder and add tests ([#6372](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6372))
- [MD] Add OpenSearch cluster group label to top of single selectable dropdown ([#6400](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6400))

### 🐛 Bug Fixes

Expand All @@ -106,6 +111,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [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]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))

### 🚞 Infrastructure

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
Expand Up @@ -74,8 +74,7 @@ describe('create data source menu', () => {
perPage: 10000,
type: 'data-source',
});
expect(notifications.toasts.addWarning).toBeCalledTimes(0);
expect(getByText(component.container, 'Local cluster')).toBeInTheDocument();
expect(notifications.toasts.addWarning).toBeCalledTimes(2);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function DataSourceMenu<T>(props: DataSourceMenuProps<T>): ReactElement |
savedObjectsClient={savedObjects!}
notifications={notifications!.toasts}
onSelectedDataSources={onSelectedDataSources!}
uiSettings={uiSettings}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export interface DataSourceOption {
label?: string;
}

export interface DataSourceGroupLabelOption extends DataSourceOption {
label: string;
isGroupLabel: true;
}

export interface DataSourceBaseConfig {
fullWidth: boolean;
disabled?: boolean;
Expand Down

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

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
Expand Up @@ -17,6 +17,7 @@ describe('DataSourceFilterGroup', () => {
<DataSourceFilterGroup
selectedOptions={[{ id: '1', label: 'name1', checked: 'on', visible: true }]}
setSelectedOptions={(items) => mockCallBack(items)}
defaultDataSource="1"
/>
);
expect(component).toMatchSnapshot();
Expand All @@ -28,6 +29,7 @@ describe('DataSourceFilterGroup', () => {
<DataSourceFilterGroup
selectedOptions={[{ id: '1', label: 'name1', checked: 'on', visible: true }]}
setSelectedOptions={(items) => mockCallBack(items)}
defaultDataSource="1"
/>
);
const button = await container.findByTestId('dataSourceFilterGroupButton');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
EuiButtonEmpty,
} from '@elastic/eui';
import { DataSourceOption } from '../data_source_selector/data_source_selector';
import { DataSourceOptionItem } from '../data_source_option';

export interface SelectedDataSourceOption extends DataSourceOption {
label: string;
Expand All @@ -27,6 +28,7 @@ export interface SelectedDataSourceOption extends DataSourceOption {
export interface DataSourceFilterGroupProps {
selectedOptions: SelectedDataSourceOption[];
setSelectedOptions: (options: SelectedDataSourceOption[]) => void;
defaultDataSource: string | null;
}

type SelectionToggleOptionIds = 'select_all' | 'deselect_all';
Expand All @@ -45,6 +47,7 @@ const selectionToggleButtons = [
export const DataSourceFilterGroup: React.FC<DataSourceFilterGroupProps> = ({
selectedOptions,
setSelectedOptions,
defaultDataSource,
}) => {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const [selectionToggleSelectedId, setSelectionToggleSelectedId] = useState<
Expand Down Expand Up @@ -148,7 +151,7 @@ export const DataSourceFilterGroup: React.FC<DataSourceFilterGroupProps> = ({
showIcons={true}
style={itemStyle}
>
{item.label}
<DataSourceOptionItem item={item} defaultDataSource={defaultDataSource} />
</EuiFilterSelectItem>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

import { SavedObjectsClientContract } from 'opensearch-dashboards/public';
import { notificationServiceMock } from '../../../../../core/public/mocks';
import { getDataSourcesWithFieldsResponse, mockResponseForSavedObjectsCalls } from '../../mocks';
import {
getDataSourcesWithFieldsResponse,
mockResponseForSavedObjectsCalls,
mockManagementPlugin,
} from '../../mocks';
import { ShallowWrapper, shallow } from 'enzyme';
import { DataSourceMultiSelectable } from './data_source_multi_selectable';
import React from 'react';
Expand All @@ -17,8 +21,12 @@ describe('DataSourceMultiSelectable', () => {
let client: SavedObjectsClientContract;
const { toasts } = notificationServiceMock.createStartContract();
const nextTick = () => new Promise((res) => process.nextTick(res));
const mockedContext = mockManagementPlugin.createDataSourceManagementContext();
const uiSettings = mockedContext.uiSettings;

beforeEach(() => {
jest.clearAllMocks();

client = {
find: jest.fn().mockResolvedValue([]),
} as any;
Expand Down Expand Up @@ -102,4 +110,40 @@ describe('DataSourceMultiSelectable', () => {

expect(callbackMock).toBeCalledWith([]);
});

it('should retrun correct state when ui Settings provided', async () => {
spyOn(uiSettings, 'get').and.returnValue('test1');
component = shallow(
<DataSourceMultiSelectable
savedObjectsClient={client}
notifications={toasts}
onSelectedDataSources={jest.fn()}
hideLocalCluster={true}
fullWidth={false}
uiSettings={uiSettings}
/>
);
await component.instance().componentDidMount!();
expect(uiSettings.get).toBeCalledWith('defaultDataSource', null);
expect(component.state('defaultDataSource')).toEqual('test1');
expect(component.state('selectedOptions')).toHaveLength(3);
});

it('should retrun correct state when ui Settings provided and hide cluster is false', async () => {
spyOn(uiSettings, 'get').and.returnValue('test1');
component = shallow(
<DataSourceMultiSelectable
savedObjectsClient={client}
notifications={toasts}
onSelectedDataSources={jest.fn()}
hideLocalCluster={false}
fullWidth={false}
uiSettings={uiSettings}
/>
);
await component.instance().componentDidMount!();
expect(uiSettings.get).toBeCalledWith('defaultDataSource', null);
expect(component.state('defaultDataSource')).toEqual('test1');
expect(component.state('selectedOptions')).toHaveLength(4);
});
});
Loading

0 comments on commit 42242bb

Please sign in to comment.