Skip to content

Commit

Permalink
[Multiple DataSource]Add datasource query for DataSourceView componen…
Browse files Browse the repository at this point in the history
…t to add label when only pass id (#6315) (#6332)

* Add datasource query for DataSourceView component to add label when only pass id

Signed-off-by: yujin-emma <[email protected]>

* update changelog

Signed-off-by: yujin-emma <[email protected]>

* fix the failed test

Signed-off-by: yujin-emma <[email protected]>

* fix comment

Signed-off-by: yujin-emma <[email protected]>

* extract interface

Signed-off-by: yujin-emma <[email protected]>

* revert yml

Signed-off-by: yujin-emma <[email protected]>

* add more test

Signed-off-by: yujin-emma <[email protected]>

* update snapshot

Signed-off-by: yujin-emma <[email protected]>

* update snpshot

Signed-off-by: yujin-emma <[email protected]>

* update change log

Signed-off-by: yujin-emma <[email protected]>

* update change log and address other comments

Signed-off-by: yujin-emma <[email protected]>

* Update CHANGELOG.md

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

* Update src/plugins/data_source_management/public/components/data_source_menu/data_source_menu.tsx

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

---------

Signed-off-by: yujin-emma <[email protected]>
Signed-off-by: Yu Jin <[email protected]>
Co-authored-by: Lu Yu <[email protected]>
(cherry picked from commit cf43af3)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 6c7a823 commit 6df8e62
Show file tree
Hide file tree
Showing 7 changed files with 527 additions and 20 deletions.

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 @@ -59,7 +59,58 @@ describe('DataSourceMenu', () => {
component = shallow(
<DataSourceMenu
componentType={DataSourceComponentType.DataSourceView}
componentConfig={{ fullWidth: true, hideLocalCluster: true }}
componentConfig={{
fullWidth: true,
hideLocalCluster: true,
savedObjects: client,
notifications,
}}
/>
);
expect(component).toMatchSnapshot();
});

it('should render data source view if not pass saved object or notification', () => {
component = shallow(
<DataSourceMenu
componentType={DataSourceComponentType.DataSourceView}
componentConfig={{
fullWidth: true,
hideLocalCluster: true,
notifications,
}}
/>
);
expect(component).toMatchSnapshot();
});

it('can render data source view when provide activeOption', () => {
component = shallow(
<DataSourceMenu
componentType={DataSourceComponentType.DataSourceView}
componentConfig={{
fullWidth: true,
hideLocalCluster: true,
savedObjects: client,
notifications,
activeOption: [{ id: 'test', label: 'test-label' }],
}}
/>
);
expect(component).toMatchSnapshot();
});

it('can render data source view when only pass id in the activeOption', () => {
component = shallow(
<DataSourceMenu
componentType={DataSourceComponentType.DataSourceView}
componentConfig={{
fullWidth: true,
hideLocalCluster: true,
savedObjects: client,
notifications,
activeOption: [{ id: 'test' }],
}}
/>
);
expect(component).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ export function DataSourceMenu<T>(props: DataSourceMenuProps<T>): ReactElement |
const { componentType, componentConfig } = props;

function renderDataSourceView(config: DataSourceViewConfig): ReactElement | null {
const { activeOption, fullWidth } = config;
const { activeOption, fullWidth, savedObjects, notifications } = config;
return (
<DataSourceView
selectedOption={activeOption && activeOption.length > 0 ? activeOption : undefined}
fullWidth={fullWidth}
selectedOption={activeOption}
savedObjectsClient={savedObjects}
notifications={notifications?.toasts}
/>
);
}
Expand Down
Loading

0 comments on commit 6df8e62

Please sign in to comment.