diff --git a/public/components/common/search/__tests__/__snapshots__/search.test.tsx.snap b/public/components/common/search/__tests__/__snapshots__/search.test.tsx.snap index 67dbe9c1e..46cdaf870 100644 --- a/public/components/common/search/__tests__/__snapshots__/search.test.tsx.snap +++ b/public/components/common/search/__tests__/__snapshots__/search.test.tsx.snap @@ -46,274 +46,117 @@ exports[`Explorer Search component renders basic component 1`] = `
- - PPL - , - "value": "PPL", - }, - Object { - "inputDisplay": - DQL - , - "value": "DQL", - }, - ] + + PPL + } - valueOfSelected="PPL" + closePopover={[Function]} + display="inlineBlock" + hasArrow={true} + id="smallContextMenuExample" + isOpen={false} + ownFocus={true} + panelPaddingSize="none" > - - PPL - , - "value": "PPL", - }, - Object { - "inputDisplay": - DQL - , - "value": "DQL", - }, - ] - } - value="PPL" - /> - } - isOpen={false} - panelPaddingSize="none" +
- - [Function] - - } - buttonRef={[Function]} - className="euiInputPopover euiSuperSelect" - closePopover={[Function]} - display="block" - hasArrow={true} - isOpen={false} - ownFocus={false} - panelPaddingSize="none" - panelRef={[Function]} +
- -
-
- -
- - PPL - , - "value": "PPL", - }, - Object { - "inputDisplay": - DQL - , - "value": "DQL", - }, - ] - } - value="PPL" + + - - -
-
- - - - PPL - , - } - } - > - - PPL - - } - > - Select an option: - -
- PPL -
-
- , is selected -
-
-
-
- - -
- - - - - -
-
-
-
-
-
-
-
-
-
-
- - - + + + + + + PPL + + + + + + +
+
+
{ const sqlService = new SQLService(coreRefs.http); const { application } = coreRefs; const [nlqInput, setNlqInput] = useState(''); + const [isModalVisible, setIsModalVisible] = useState(false); + const closeModal = () => setIsModalVisible(false); + const showModal = () => setIsModalVisible(true); const showQueryArea = !appLogEvents && coreRefs.queryAssistEnabled; @@ -203,7 +206,7 @@ export const Search = (props: any) => { const handleQueryLanguageChange = (lang: string) => { if (lang === QUERY_LANGUAGE.DQL) { - application!.navigateToUrl('../app/data-explorer/discover'); + showModal(); return; } dispatch( @@ -220,9 +223,19 @@ export const Search = (props: any) => { setLanguagePopoverOpen(false); }; - const languageOptions: Array> = [ - { value: QUERY_LANGUAGE.PPL, inputDisplay: PPL }, - { value: QUERY_LANGUAGE.DQL, inputDisplay: DQL }, + const languagePopOverItems = [ + handleQueryLanguageChange(QUERY_LANGUAGE.PPL)} + > + PPL + , + handleQueryLanguageChange(QUERY_LANGUAGE.DQL)} + > + DQL - Opens in Discover + , ]; const onQuerySearch = () => { @@ -290,6 +303,50 @@ export const Search = (props: any) => { : undefined; const loading = indicesLoading || indexPatternsLoading; + const onLanguagePopoverClick = () => { + setLanguagePopoverOpen(!_isLanguagePopoverOpen); + }; + + const languagePopOverButton = ( + + {queryLang} + + ); + + const redirectToDiscover = () => { + application!.navigateToUrl('../app/data-explorer/discover'); + }; + + let redirectionModal = null; + if (isModalVisible) { + redirectionModal = ( + + + +

Open in Discover

+
+
+ + + The OpenSearch Dashboards Query Language (DQL) offers a simplified query syntax and + support for scripted fields. Selecting this option will open the Discover application. + + + + Cancel + { + redirectToDiscover(); + }} + fill + > + Open in Discover + + +
+ ); + } + return (
@@ -307,14 +364,16 @@ export const Search = (props: any) => { {!appLogEvents && ( <> - { - handleQueryLanguageChange(lang); - setQueryLang(lang); - }} - /> + + + { size="l" onClick={() => showFlyout()} color="#159D8D" - // onClickAriaLabel={'pplLinkShowFlyout'} /> {coreRefs.queryAssistEnabled && ( @@ -535,6 +593,7 @@ export const Search = (props: any) => { )} + {redirectionModal} {flyout}
); diff --git a/public/components/common/search/sql_search.tsx b/public/components/common/search/sql_search.tsx index a70746364..1d53e6af6 100644 --- a/public/components/common/search/sql_search.tsx +++ b/public/components/common/search/sql_search.tsx @@ -93,7 +93,6 @@ export const DirectSearch = (props: any) => { const [isLanguagePopoverOpen, setLanguagePopoverOpen] = useState(false); const [queryLang, setQueryLang] = useState(explorerSearchMetadata.lang || QUERY_LANGUAGE.SQL); const sqlService = new SQLService(coreRefs.http); - const { application } = coreRefs; const { data: pollingResult, @@ -140,10 +139,6 @@ export const DirectSearch = (props: any) => { ); const handleQueryLanguageChange = (lang: QUERY_LANGUAGE) => { - if (lang === 'DQL') { - application!.navigateToUrl('../app/data-explorer/discover'); - return; - } dispatch(updateSearchMetaData({ tabId, data: { lang } })); setQueryLang(lang); closeLanguagePopover(); diff --git a/public/components/event_analytics/explorer/datasources/datasources_selection.tsx b/public/components/event_analytics/explorer/datasources/datasources_selection.tsx index 122e7cc7f..1460a030e 100644 --- a/public/components/event_analytics/explorer/datasources/datasources_selection.tsx +++ b/public/components/event_analytics/explorer/datasources/datasources_selection.tsx @@ -50,6 +50,8 @@ import { SELECTED_TIMESTAMP, } from '../../../../../common/constants/explorer'; +const DATA_SOURCE_SELECTOR_CONFIGS = { customGroupTitleExtension: '' }; + const getDataSourceState = (selectedSourceState: SelectedDataSource[]) => { if (selectedSourceState.length === 0) return []; return [ @@ -241,6 +243,9 @@ export const DataSourceSelection = ({ tabId }: { tabId: string }) => { if (dsOption.label === DEFAULT_DATA_SOURCE_TYPE_NAME) { dsOption.label = DEFAULT_DATA_SOURCE_OBSERVABILITY_DISPLAY_NAME; } + if (dsOption.label === 'Index patterns') { + dsOption.label = 'Data connections'; + } return dsOption; }); }, [dataSourceOptionList]); @@ -255,6 +260,7 @@ export const DataSourceSelection = ({ tabId }: { tabId: string }) => { onDataSourceSelect={handleSourceChange} onFetchDataSetError={handleDataSetFetchError} singleSelection={{ asPlainText: true }} + dataSourceSelectorConfigs={DATA_SOURCE_SELECTOR_CONFIGS} /> ); };