Skip to content

Commit

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

* add multi selectable data source component



* update change log



* add tests



* add more test



* refactor to add config



* fix typo



* update snapshot



* add missing interface



---------

Signed-off-by: Lu Yu <[email protected]>
  • Loading branch information
BionIT authored Apr 3, 2024
1 parent 31d880e commit 49d696c
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 49d696c

Please sign in to comment.