diff --git a/src/plugins/data_source_management/public/components/data_source_aggregated_view/__snapshots__/data_source_aggregated_view.test.tsx.snap b/src/plugins/data_source_management/public/components/data_source_aggregated_view/__snapshots__/data_source_aggregated_view.test.tsx.snap
index 2c789f04da12..e4f4b1f67c67 100644
--- a/src/plugins/data_source_management/public/components/data_source_aggregated_view/__snapshots__/data_source_aggregated_view.test.tsx.snap
+++ b/src/plugins/data_source_management/public/components/data_source_aggregated_view/__snapshots__/data_source_aggregated_view.test.tsx.snap
@@ -1,7 +1,49 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`DataSourceAggregatedView should render normally with data source filter 1`] = `
-
+
- Data sources
+
+
+
+
+
+
+
+ Data sources
+
+
+
+
- All
+
+ All
+
-
+
-
+
`;
exports[`DataSourceAggregatedView should render normally with local cluster and actice selections 1`] = `
-
+
- Data sources
+
+
+
+
+
+
+
+ Data sources
+
+
+
+
- 1
+
+ 1
+
-
+
-
+
`;
exports[`DataSourceAggregatedView should render normally with local cluster hidden and all options 1`] = `
-
+
- Data sources
+
+
+
+
+
+
+
+ Data sources
+
+
+
+
- All
+
+ 0
+
-
+
-
+
`;
exports[`DataSourceAggregatedView should render normally with local cluster not hidden and all options 1`] = `
diff --git a/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.test.tsx b/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.test.tsx
index 3f44bac61e5b..5bb518af2d06 100644
--- a/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.test.tsx
+++ b/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.test.tsx
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import { ShallowWrapper, shallow } from 'enzyme';
+import { ShallowWrapper, mount, shallow } from 'enzyme';
import React from 'react';
import { DataSourceAggregatedView } from './data_source_aggregated_view';
import { SavedObjectsClientContract } from '../../../../../core/public';
@@ -43,26 +43,29 @@ describe('DataSourceAggregatedView', () => {
});
it('should render normally with local cluster hidden and all options', () => {
- component = shallow(
+ const container = mount(
);
- expect(component).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
expect(client.find).toBeCalledWith({
fields: ['id', 'title', 'auth.type'],
perPage: 10000,
type: 'data-source',
});
expect(toasts.addWarning).toBeCalledTimes(0);
+ const badge = container.find('EuiNotificationBadge').text();
+ expect(badge).toEqual('0');
});
it('should render normally with local cluster and actice selections', () => {
- component = shallow(
+ const container = mount(
{
activeDataSourceIds={['test1']}
/>
);
- expect(component).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
expect(client.find).toBeCalledWith({
fields: ['id', 'title', 'auth.type'],
perPage: 10000,
type: 'data-source',
});
expect(toasts.addWarning).toBeCalledTimes(0);
+ const badge = container.find('EuiNotificationBadge').text();
+ expect(badge).toEqual('1');
});
it('should render normally with data source filter', () => {
- component = shallow(
+ const container = mount(
ds.attributes.auth.type !== 'no_auth'}
/>
);
- expect(component).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
expect(client.find).toBeCalledWith({
fields: ['id', 'title', 'auth.type'],
perPage: 10000,
type: 'data-source',
});
expect(toasts.addWarning).toBeCalledTimes(0);
+ const badge = container.find('EuiNotificationBadge').text();
+ expect(badge).toEqual('All');
});
it('should render popup when clicking on info icon', async () => {
diff --git a/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.tsx b/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.tsx
index 015441773600..7c039c2f64f3 100644
--- a/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.tsx
+++ b/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.tsx
@@ -111,17 +111,17 @@ export class DataSourceAggregatedView extends React.Component<
let items = [];
// only display active data sources
- if (this.props.activeDataSourceIds && this.props.activeDataSourceIds.length > 0) {
- items = this.props.activeDataSourceIds.map((id) => {
+ if (this.props.displayAllCompatibleDataSources) {
+ items = [...this.state.allDataSourcesIdToTitleMap.values()].map((title) => {
return {
- name: this.state.allDataSourcesIdToTitleMap.get(id),
+ name: title,
disabled: true,
};
});
} else {
- items = [...this.state.allDataSourcesIdToTitleMap.values()].map((title) => {
+ items = this.props.activeDataSourceIds!.map((id) => {
return {
- name: title,
+ name: this.state.allDataSourcesIdToTitleMap.get(id),
disabled: true,
};
});
@@ -155,7 +155,8 @@ export class DataSourceAggregatedView extends React.Component<
{'Data sources'}
- {this.props.activeDataSourceIds?.length || 'All'}
+ {(this.props.displayAllCompatibleDataSources && 'All') ||
+ this.props.activeDataSourceIds!.length}