diff --git a/public/components/query_compare/home.tsx b/public/components/query_compare/home.tsx
index 0ae50ae..ab0f8e6 100644
--- a/public/components/query_compare/home.tsx
+++ b/public/components/query_compare/home.tsx
@@ -5,7 +5,7 @@
import React, { useEffect, useMemo, useState } from 'react';
import { ChromeBreadcrumb, CoreStart, MountPoint, NotificationsStart } from '../../../../../src/core/public';
-import { DataSourceManagementPluginSetup, DataSourceMultiSelectableConfig } from '../../../../../src/plugins/data_source_management/public';
+import { DataSourceAggregatedViewConfig, DataSourceManagementPluginSetup } from '../../../../../src/plugins/data_source_management/public';
import { NavigationPublicPluginStart } from '../../../../../src/plugins/navigation/public';
import { QUERY_NUMBER_ONE, QUERY_NUMBER_TWO, ServiceEndpoints } from '../../../common';
import '../../ace-themes/sql_console';
@@ -86,6 +86,7 @@ export const Home = ({
if(dataConnectionId){
http.get(`${ServiceEndpoints.GetPipelines}/${dataConnectionId}`).then((res: {}) => {
if(queryNumber == QUERY_NUMBER_ONE){
+ console.log(res)
setFetchedPipelines1(res)
}
else{
@@ -105,15 +106,7 @@ export const Home = ({
}
}
- const selectedDatasources = (e) => {
- setDataSourceOptions([]);
- const selectedOptions = e.filter(item => item.checked === "on");
- if (selectedOptions.length >= 1) {
- setDataSourceOptions(selectedOptions);
- }
- };
-
- const DataSourceMenu = dataSourceManagement.ui.getDataSourceMenu();
+ const DataSourceMenu = dataSourceManagement.ui.getDataSourceMenu();
// Get Indexes and Pipelines
useEffect(() => {
@@ -128,21 +121,21 @@ export const Home = ({
return (
);
- }, [setActionMenu, savedObjects.client, notifications]);
+ }, [setActionMenu, savedObjects.client, notifications, datasource1, datasource2]);
return (
<>
{dataSourceEnabled && dataSourceMenuComponent}
- {documentsIndexes1.length || documentsIndexes2.length ? : }
+ {documentsIndexes1.length || documentsIndexes2.length ? : }
{showFlyout && }
>
diff --git a/public/components/query_compare/search_result/search_components/__tests__/__snapshots__/search_config.test.tsx.snap b/public/components/query_compare/search_result/search_components/__tests__/__snapshots__/search_config.test.tsx.snap
index 32c2edc..7549818 100644
--- a/public/components/query_compare/search_result/search_components/__tests__/__snapshots__/search_config.test.tsx.snap
+++ b/public/components/query_compare/search_result/search_components/__tests__/__snapshots__/search_config.test.tsx.snap
@@ -1,6 +1,793 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Flyout component Renders flyout component 1`] = `
+
+
+
+
+ Query
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Pipeline
+
+
+
+
+
+
+
+
+
+ Optional
+
+
+
+
+
+
+
+
+
+
+ Enter a query in
+
+
+ OpenSearch Query DSL
+
+ . Use %SearchText% to refer to the text in the search bar
+
+ }
+ isInvalid={false}
+ label="Query"
+ labelAppend={
+
+
+ Help
+
+
+ }
+ labelType="label"
+ >
+
+
+
+
+ Query
+
+
+
+
+
+
+
+
+
+
+ Help
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Press Enter to start editing.
+
+
+
+
+ When you're done, press Escape to stop editing.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`Flyout component Renders flyout component when multi-datasource is enabled 1`] = `
`;
+
+exports[`Flyout component Renders flyout component when multi dataSource enabled 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+ Query
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Pipeline
+
+
+
+
+
+
+
+
+
+ Optional
+
+
+
+
+
+
+
+
+
+
+ Enter a query in
+
+
+ OpenSearch Query DSL
+
+ . Use %SearchText% to refer to the text in the search bar
+
+ }
+ isInvalid={false}
+ label="Query"
+ labelAppend={
+
+
+ Help
+
+
+ }
+ labelType="label"
+ >
+
+
+
+
+ Query
+
+
+
+
+
+
+
+
+
+
+ Help
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Press Enter to start editing.
+
+
+
+
+ When you're done, press Escape to stop editing.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Query
+ 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Pipeline
+
+
+
+
+
+
+
+
+
+ Optional
+
+
+
+
+
+
+
+
+
+
+ Enter a query in
+
+
+ OpenSearch Query DSL
+
+ . Use %SearchText% to refer to the text in the search bar
+
+ }
+ isInvalid={false}
+ label="Query"
+ labelAppend={
+
+
+ Help
+
+
+ }
+ labelType="label"
+ >
+
+
+
+
+ Query
+
+
+
+
+
+
+
+
+
+
+ Help
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Press Enter to start editing.
+
+
+
+
+ When you're done, press Escape to stop editing.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/public/components/query_compare/search_result/search_components/__tests__/search_config.test.tsx b/public/components/query_compare/search_result/search_components/__tests__/search_config.test.tsx
index a91fb7f..76d4745 100644
--- a/public/components/query_compare/search_result/search_components/__tests__/search_config.test.tsx
+++ b/public/components/query_compare/search_result/search_components/__tests__/search_config.test.tsx
@@ -15,7 +15,7 @@ import { SearchConfig } from '../search_configs/search_config';
describe('Flyout component', () => {
configure({ adapter: new Adapter() });
- it('Renders flyout component', async () => {
+ it('Renders flyout component when multi-datasource is enabled', async () => {
const setQueryString = jest.fn();
const setSelectedIndex = jest.fn();
const setPipeline = jest.fn();
@@ -50,8 +50,48 @@ describe('Flyout component', () => {
});
});
expect(setQueryString).toHaveBeenCalledTimes(1);
- expect(setSelectedIndex).toHaveBeenCalledTimes(1);
- expect(setPipeline).toHaveBeenCalledTimes(2);
+ expect(setSelectedIndex).toHaveBeenCalledTimes(2);
+ expect(setPipeline).toHaveBeenCalledTimes(3);
+ expect(setQueryError).toHaveBeenCalledTimes(3);
+ });
+
+ it('Renders flyout component', async () => {
+ const setQueryString = jest.fn();
+ const setSelectedIndex = jest.fn();
+ const setPipeline = jest.fn();
+ const setQueryError = jest.fn();
+ const setDataSourceManagement = jest.fn();
+ const wrapper = mount(
+
+
+
+ );
+
+ wrapper.update();
+ await waitFor(() => {
+ expect(wrapper).toMatchSnapshot();
+ wrapper.find('EuiCodeEditor').prop('onChange')?.({ target: { value: '' } });
+ wrapper.find('EuiSelect').prop('onChange')?.({ target: {} });
+ wrapper.find('EuiSelect').prop('onBlur')?.({ target: {} });
+ wrapper.find('EuiComboBox').prop('onChange')?.({ target: { selectedPipelineOptions: [] } });
+ wrapper.find('EuiComboBox').prop('onChange')?.({
+ target: { selectedPipelineOptions: [{ label: '_none' }] },
+ });
+ });
+ expect(setQueryString).toHaveBeenCalledTimes(1);
+ expect(setSelectedIndex).toHaveBeenCalledTimes(2);
+ expect(setPipeline).toHaveBeenCalledTimes(3);
expect(setQueryError).toHaveBeenCalledTimes(3);
});
});
diff --git a/public/components/query_compare/search_result/search_components/__tests__/search_configs.test.tsx b/public/components/query_compare/search_result/search_components/__tests__/search_configs.test.tsx
index 5956924..d18ffad 100644
--- a/public/components/query_compare/search_result/search_components/__tests__/search_configs.test.tsx
+++ b/public/components/query_compare/search_result/search_components/__tests__/search_configs.test.tsx
@@ -34,6 +34,29 @@ describe('Flyout component', () => {
wrapper.update();
+ await waitFor(() => {
+ expect(wrapper).toMatchSnapshot();
+ });
+ });
+ it('Renders flyout component when multi dataSource enabled', async () => {
+ const wrapper = mount(
+
+ {}}
+ setQueryString2={() => {}}
+ queryError1={initialQueryErrorState}
+ queryError2={initialQueryErrorState}
+ setQueryError1={() => {}}
+ setQueryError2={() => {}}
+ dataSourceEnabled={false}
+ />
+
+ );
+
+ wrapper.update();
+
await waitFor(() => {
expect(wrapper).toMatchSnapshot();
});
diff --git a/public/components/query_compare/search_result/search_components/search_configs/search_config.tsx b/public/components/query_compare/search_result/search_components/search_configs/search_config.tsx
index 77b67fc..01ffd81 100644
--- a/public/components/query_compare/search_result/search_components/search_configs/search_config.tsx
+++ b/public/components/query_compare/search_result/search_components/search_configs/search_config.tsx
@@ -15,7 +15,7 @@ import {
EuiText,
EuiTitle,
} from '@elastic/eui';
-import React, { FunctionComponent } from 'react';
+import React, { FunctionComponent, useEffect } from 'react';
import { AppMountParameters, CoreStart, MountPoint, NotificationsStart, SavedObjectsStart, ToastsStart } from '../../../../../../../../src/core/public';
import { DataSourceManagementPluginSetup } from '../../../../../../../../src/plugins/data_source_management/public';
@@ -74,7 +74,7 @@ export const SearchConfig: FunctionComponent = ({
setActionMenu,
dataSourceOptions,
}) => {
- const { documentsIndexes1, setDataSource1, setDataSource2, documentsIndexes2, fetchedPipelines1, fetchedPipelines2, setShowFlyout} = useSearchRelevanceContext();
+ const { documentsIndexes1, setDataSource1, setDataSource2, documentsIndexes2, fetchedPipelines1, fetchedPipelines2, setShowFlyout, datasource1, datasource2} = useSearchRelevanceContext();
// On select index
const onChangeSelectedIndex: React.ChangeEventHandler = (e) => {
setSelectedIndex(e.target.value);
@@ -144,7 +144,16 @@ export const SearchConfig: FunctionComponent = ({
setDataSource2(dataConnectionId)
}
}
- const DataSourceSelector = dataSourceManagement.ui.DataSourceSelector;
+ useEffect(() => {
+ setSelectedIndex('')
+ setPipeline('')
+ }, [datasource1, datasource2]);
+
+ let DataSourceSelector;
+
+ if (dataSourceEnabled) {
+ DataSourceSelector = dataSourceManagement.ui.DataSourceSelector;
+ }
return (
<>
@@ -165,7 +174,7 @@ export const SearchConfig: FunctionComponent = ({
disabled={false}
fullWidth={false}
removePrepend={true}
- dataSourceFilter={(dataSource) => dataSourceOptions.some(item => item.id === dataSource.id)}
+ defaultOption= {[]}
/>
)}
diff --git a/server/routes/dsl_route.ts b/server/routes/dsl_route.ts
index 7365651..8ab6b8a 100644
--- a/server/routes/dsl_route.ts
+++ b/server/routes/dsl_route.ts
@@ -221,7 +221,7 @@ export function registerDslRoute(router: IRouter, openSearchServiceSetup: OpenS
if(dataSourceEnabled && dataSourceId){
let client = await context.dataSource.opensearch.legacy.getClient(dataSourceId);
- resp = await client.callAPI('search.pipeline');
+ resp = await client.callAPI('search_pipeline');
}
else{
resp = await context.core.opensearch.client.asCurrentUser.transport.request({