Skip to content

Commit

Permalink
[Multiple Datasource] Add multi selectable data source component (ope…
Browse files Browse the repository at this point in the history
…nsearch-project#6211)

* add multi selectable data source component

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

* update change log

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

* add tests

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

* add more test

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

* refactor to add config

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

* fix typo

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

* update snapshot

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

* add missing interface

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

---------

Signed-off-by: Lu Yu <[email protected]>
  • Loading branch information
BionIT committed Apr 2, 2024
1 parent e0c3664 commit 290a778
Show file tree
Hide file tree
Showing 16 changed files with 1,494 additions and 0 deletions.

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 @@ -94,4 +94,18 @@ describe('DataSourceMenu', () => {
);
expect(container).toMatchSnapshot();
});

it('should render data source multi select component', () => {
const container = render(
<DataSourceMenu
showDataSourceMultiSelectable={true}
appName={'myapp'}
fullWidth={true}
className={'myclass'}
savedObjects={client}
notifications={notifications}
/>
);
expect(container).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import React, { ReactElement } from 'react';
import { DataSourceSelectable } from './data_source_selectable';
import { DataSourceAggregatedView } from '../data_source_aggregated_view';
import { DataSourceView } from '../data_source_view';
import { DataSourceMultiSelectable } from '../data_source_multi_selectable/data_source_multi_selectable';
import {
DataSourceAggregatedViewConfig,
DataSourceComponentType,
DataSourceMenuProps,
DataSourceMultiSelectableConfig,
DataSourceSelectableConfig,
DataSourceViewConfig,
} from './types';
Expand All @@ -29,6 +31,27 @@ export function DataSourceMenu<T>(props: DataSourceMenuProps<T>): ReactElement |
);
}

function renderDataSourceMultiSelectable(
config: DataSourceMultiSelectableConfig
): ReactElement | null {
const {
fullWidth,
hideLocalCluster,
savedObjects,
notifications,
onSelectedDataSources,
} = config;
return (
<DataSourceMultiSelectable
fullWidth={fullWidth}
hideLocalCluster={hideLocalCluster || false}
savedObjectsClient={savedObjects!}
notifications={notifications!.toasts}
onSelectedDataSources={onSelectedDataSources!}
/>
);
}

function renderDataSourceSelectable(config: DataSourceSelectableConfig): ReactElement | null {
const {
onSelectedDataSources,
Expand Down Expand Up @@ -87,6 +110,8 @@ export function DataSourceMenu<T>(props: DataSourceMenuProps<T>): ReactElement |
return renderDataSourceSelectable(componentConfig as DataSourceSelectableConfig);
case DataSourceComponentType.DataSourceView:
return renderDataSourceView(componentConfig as DataSourceViewConfig);
case DataSourceComponentType.DataSourceMultiSelectable:
return renderDataSourceMultiSelectable(componentConfig as DataSourceMultiSelectableConfig);
default:
return null;
}
Expand Down
Loading

0 comments on commit 290a778

Please sign in to comment.