From 19946d278674e15c3b26f238836adc7ea677a28a Mon Sep 17 00:00:00 2001 From: Xavier Mouligneau Date: Fri, 5 May 2023 03:32:13 -0400 Subject: [PATCH] [RAM] Alert search bar only KQL (#155947) ## Summary Adding the props `showQueryInput` is fixing the layout of of the filters. We also wanted to make sure that our alert search bar can only work with KQL because we need to do some kind of validation on the field used in the search bar, therefore it will be easier to just use KueryNode for now. ### Before: Screenshot 2023-04-26 at 1 52 44 PM ### After: image --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit af7e34a2ba3c4d0bd4a2e46979f6b96bada439ef) --- .../unified_search/public/__stories__/search_bar.stories.tsx | 5 +++++ .../public/query_string_input/query_bar_menu.tsx | 3 +++ .../public/query_string_input/query_bar_menu_panels.tsx | 4 +++- src/plugins/unified_search/public/search_bar/search_bar.tsx | 2 ++ .../action_connector_form/action_alerts_filter_query.tsx | 1 + .../sections/alerts_search_bar/alerts_search_bar.tsx | 4 ++++ .../public/application/sections/alerts_search_bar/types.ts | 1 + 7 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/plugins/unified_search/public/__stories__/search_bar.stories.tsx b/src/plugins/unified_search/public/__stories__/search_bar.stories.tsx index 2c243814a82b7..bf2326604c308 100644 --- a/src/plugins/unified_search/public/__stories__/search_bar.stories.tsx +++ b/src/plugins/unified_search/public/__stories__/search_bar.stories.tsx @@ -446,6 +446,11 @@ storiesOf('SearchBar', module) }, } as unknown as SearchBarProps) ) + .add('without switch query language', () => + wrapSearchBarInContext({ + disableQueryLanguageSwitcher: true, + } as SearchBarProps) + ) .add('show only query bar without submit', () => wrapSearchBarInContext({ showDatePicker: false, diff --git a/src/plugins/unified_search/public/query_string_input/query_bar_menu.tsx b/src/plugins/unified_search/public/query_string_input/query_bar_menu.tsx index 9ba28c72c47e3..553354f7b4a34 100644 --- a/src/plugins/unified_search/public/query_string_input/query_bar_menu.tsx +++ b/src/plugins/unified_search/public/query_string_input/query_bar_menu.tsx @@ -47,6 +47,7 @@ export interface QueryBarMenuProps extends WithCloseFilterEditorConfirmModalProp toggleFilterBarMenuPopover: (value: boolean) => void; openQueryBarMenu: boolean; nonKqlMode?: 'lucene' | 'text'; + disableQueryLanguageSwitcher?: boolean; dateRangeFrom?: string; dateRangeTo?: string; savedQueryService: SavedQueryService; @@ -72,6 +73,7 @@ export interface QueryBarMenuProps extends WithCloseFilterEditorConfirmModalProp function QueryBarMenuComponent({ language, nonKqlMode, + disableQueryLanguageSwitcher, dateRangeFrom, dateRangeTo, onQueryChange, @@ -158,6 +160,7 @@ function QueryBarMenuComponent({ manageFilterSetComponent, hiddenPanelOptions, nonKqlMode, + disableQueryLanguageSwitcher, closePopover: plainClosePopover, onQueryBarSubmit, onFiltersUpdated, diff --git a/src/plugins/unified_search/public/query_string_input/query_bar_menu_panels.tsx b/src/plugins/unified_search/public/query_string_input/query_bar_menu_panels.tsx index d7c8bd8b64a45..4479be2c9281b 100644 --- a/src/plugins/unified_search/public/query_string_input/query_bar_menu_panels.tsx +++ b/src/plugins/unified_search/public/query_string_input/query_bar_menu_panels.tsx @@ -147,6 +147,7 @@ export interface QueryBarMenuPanelsProps { manageFilterSetComponent?: JSX.Element; hiddenPanelOptions?: FilterPanelOption[]; nonKqlMode?: 'lucene' | 'text'; + disableQueryLanguageSwitcher?: boolean; closePopover: () => void; onQueryBarSubmit: (payload: { dateRange: TimeRange; query?: Query }) => void; onFiltersUpdated?: (filters: Filter[]) => void; @@ -170,6 +171,7 @@ export function QueryBarMenuPanels({ manageFilterSetComponent, hiddenPanelOptions, nonKqlMode, + disableQueryLanguageSwitcher = false, closePopover, onQueryBarSubmit, onFiltersUpdated, @@ -384,7 +386,7 @@ export function QueryBarMenuPanels({ } // language menu appears when the showQueryInput is true - if (showQueryInput) { + if (showQueryInput && !disableQueryLanguageSwitcher) { items.push({ name: `Language: ${language === 'kuery' ? kqlLabel : luceneLabel}`, panel: 3, diff --git a/src/plugins/unified_search/public/search_bar/search_bar.tsx b/src/plugins/unified_search/public/search_bar/search_bar.tsx index 3326d81e29109..f95ed07c8d938 100644 --- a/src/plugins/unified_search/public/search_bar/search_bar.tsx +++ b/src/plugins/unified_search/public/search_bar/search_bar.tsx @@ -87,6 +87,7 @@ export interface SearchBarOwnProps { isClearable?: boolean; iconType?: EuiIconProps['type']; nonKqlMode?: 'lucene' | 'text'; + disableQueryLanguageSwitcher?: boolean; // defines padding and border; use 'inPage' to avoid any padding or border; // use 'detached' if the searchBar appears at the very top of the view, without any wrapper displayStyle?: 'inPage' | 'detached'; @@ -472,6 +473,7 @@ class SearchBarUI extends C const queryBarMenu = this.props.showQueryMenu ? ( = (