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 <yujin.emma.work@gmail.com>

* update changelog

Signed-off-by: yujin-emma <yujin.emma.work@gmail.com>

* fix the failed test

Signed-off-by: yujin-emma <yujin.emma.work@gmail.com>

* fix comment

Signed-off-by: yujin-emma <yujin.emma.work@gmail.com>

* extract interface

Signed-off-by: yujin-emma <yujin.emma.work@gmail.com>

* revert yml

Signed-off-by: yujin-emma <yujin.emma.work@gmail.com>

* add more test

Signed-off-by: yujin-emma <yujin.emma.work@gmail.com>

* update snapshot

Signed-off-by: yujin-emma <yujin.emma.work@gmail.com>

* update snpshot

Signed-off-by: yujin-emma <yujin.emma.work@gmail.com>

* update change log

Signed-off-by: yujin-emma <yujin.emma.work@gmail.com>

* update change log and address other comments

Signed-off-by: yujin-emma <yujin.emma.work@gmail.com>

* Update CHANGELOG.md

Co-authored-by: Lu Yu <nluyu@amazon.com>
Signed-off-by: Yu Jin <112784385+yujin-emma@users.noreply.github.com>

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

Co-authored-by: Lu Yu <nluyu@amazon.com>
Signed-off-by: Yu Jin <112784385+yujin-emma@users.noreply.github.com>

---------

Signed-off-by: yujin-emma <yujin.emma.work@gmail.com>
Signed-off-by: Yu Jin <112784385+yujin-emma@users.noreply.github.com>
Co-authored-by: Lu Yu <nluyu@amazon.com>
(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.