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 (opensearch-project#6315)

* 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]>
  • Loading branch information
yujin-emma and BionIT authored Apr 3, 2024
1 parent c0e8d4a commit cf43af3
Show file tree
Hide file tree
Showing 8 changed files with 528 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Workspace] Add workspace list page ([#6182](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6182))
- [Workspace] Add workspaces column to saved objects page ([#6225](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6225))
- [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)
- [Workspace] Add permission control logic ([#6052](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6052))

### 🐛 Bug Fixes
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 @@ -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 cf43af3

Please sign in to comment.