From 36c764ebf722455a412416d48d48c737feb30e71 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Wed, 12 Feb 2025 19:52:30 +0000 Subject: [PATCH] [ML] AIOps Hiding saved query controls (#210556) The AIOps pages in ML make use of the shared query bar component, but do not support saved queries. By having the load and save query options in the menu, it can give the impression that these options are generally available but for some reason cannot be used. This PR adds a new optional flag which allows the load and save options to be hidden from the menu. The flag defaults to always showing the options. Fixes https://github.com/elastic/kibana/issues/209152 **Before** ![image](https://github.com/user-attachments/assets/a26a73d0-63b4-47c1-bfa2-8579b08dfe24) **After** ![image](https://github.com/user-attachments/assets/4fe6937e-3c7d-4d15-98da-fdf472fc21ee) --- .../public/query_string_input/query_bar_menu.tsx | 3 +++ .../public/query_string_input/query_bar_menu_panels.tsx | 7 ++++++- .../shared/unified_search/public/search_bar/search_bar.tsx | 3 +++ .../components/search_panel/search_bar.tsx | 1 + .../components/change_point_detection/search_bar.tsx | 1 + .../aiops/public/components/search_panel/search_panel.tsx | 1 + 6 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/platform/plugins/shared/unified_search/public/query_string_input/query_bar_menu.tsx b/src/platform/plugins/shared/unified_search/public/query_string_input/query_bar_menu.tsx index 58e6baab2f88d..288b3f4130bed 100644 --- a/src/platform/plugins/shared/unified_search/public/query_string_input/query_bar_menu.tsx +++ b/src/platform/plugins/shared/unified_search/public/query_string_input/query_bar_menu.tsx @@ -75,6 +75,7 @@ export interface QueryBarMenuProps extends WithCloseFilterEditorConfirmModalProp showQueryInput?: boolean; showFilterBar?: boolean; showSaveQuery?: boolean; + showSavedQueryControls?: boolean; timeRangeForSuggestionsOverride?: boolean; filtersForSuggestions?: Filter[]; indexPatterns?: Array; @@ -110,6 +111,7 @@ function QueryBarMenuComponent({ showQueryInput, showFilterBar, showSaveQuery, + showSavedQueryControls, indexPatterns, timeRangeForSuggestionsOverride, filtersForSuggestions, @@ -176,6 +178,7 @@ function QueryBarMenuComponent({ timeFilter, query, showSaveQuery, + showSavedQueryControls, showFilterBar, showQueryInput, savedQueryService, diff --git a/src/platform/plugins/shared/unified_search/public/query_string_input/query_bar_menu_panels.tsx b/src/platform/plugins/shared/unified_search/public/query_string_input/query_bar_menu_panels.tsx index d20dc65fa72e6..7ba18af40533e 100644 --- a/src/platform/plugins/shared/unified_search/public/query_string_input/query_bar_menu_panels.tsx +++ b/src/platform/plugins/shared/unified_search/public/query_string_input/query_bar_menu_panels.tsx @@ -171,6 +171,7 @@ export interface QueryBarMenuPanelsProps { timeFilter?: SavedQueryTimeFilter; query?: Query; showSaveQuery?: boolean; + showSavedQueryControls?: boolean; showQueryInput?: boolean; showFilterBar?: boolean; savedQueryService: SavedQueryService; @@ -199,6 +200,7 @@ export function useQueryBarMenuPanels({ timeFilter, query, showSaveQuery, + showSavedQueryControls = true, showFilterBar, showQueryInput, savedQueryService, @@ -220,7 +222,10 @@ export function useQueryBarMenuPanels({ const { appName, usageCollection, uiSettings, http, storage, application } = kibana.services; const reportUiCounter = usageCollection?.reportUiCounter.bind(usageCollection, appName); const showSavedQueries = - showQueryInput && showFilterBar && application.capabilities.savedQueryManagement?.showQueries; + showSavedQueryControls && + showQueryInput && + showFilterBar && + application.capabilities.savedQueryManagement?.showQueries; const cancelPendingListingRequest = useRef<() => void>(() => {}); const [hasSavedQueries, setHasSavedQueries] = useState(false); diff --git a/src/platform/plugins/shared/unified_search/public/search_bar/search_bar.tsx b/src/platform/plugins/shared/unified_search/public/search_bar/search_bar.tsx index 04e90347c59db..e999b5e9ccabf 100644 --- a/src/platform/plugins/shared/unified_search/public/search_bar/search_bar.tsx +++ b/src/platform/plugins/shared/unified_search/public/search_bar/search_bar.tsx @@ -87,6 +87,8 @@ export interface SearchBarOwnProps { query?: QT | Query; // Show when user has privileges to save. See `canShowSavedQuery(...)` lib. showSaveQuery?: boolean; + // Show the controls to save and load saved queries + showSavedQueryControls?: boolean; savedQuery?: SavedQuery; onQueryChange?: (payload: { dateRange: TimeRange; query?: QT | Query }) => void; onQuerySubmit?: ( @@ -556,6 +558,7 @@ class SearchBarUI extends C showQueryInput={this.props.showQueryInput} showFilterBar={this.props.showFilterBar} showSaveQuery={this.props.showSaveQuery} + showSavedQueryControls={this.props.showSavedQueryControls} isDisabled={this.props.isDisabled} buttonProps={{ size: this.shouldShowDatePickerAsBadge() ? 's' : 'm' }} indexPatterns={this.props.indexPatterns} diff --git a/x-pack/platform/plugins/private/data_visualizer/public/application/index_data_visualizer/components/search_panel/search_bar.tsx b/x-pack/platform/plugins/private/data_visualizer/public/application/index_data_visualizer/components/search_panel/search_bar.tsx index 8c939c384b590..6d9f0cc5cd610 100644 --- a/x-pack/platform/plugins/private/data_visualizer/public/application/index_data_visualizer/components/search_panel/search_bar.tsx +++ b/x-pack/platform/plugins/private/data_visualizer/public/application/index_data_visualizer/components/search_panel/search_bar.tsx @@ -117,6 +117,7 @@ export const SearchPanelContent = ({ showFilterBar={true} showDatePicker={false} showQueryInput={true} + showSavedQueryControls={false} query={searchInput} onQuerySubmit={(params: { dateRange: TimeRange; query?: Query | undefined }) => searchHandler({ query: params.query }) diff --git a/x-pack/platform/plugins/shared/aiops/public/components/change_point_detection/search_bar.tsx b/x-pack/platform/plugins/shared/aiops/public/components/change_point_detection/search_bar.tsx index c8cb046561409..b3867c65bf065 100644 --- a/x-pack/platform/plugins/shared/aiops/public/components/change_point_detection/search_bar.tsx +++ b/x-pack/platform/plugins/shared/aiops/public/components/change_point_detection/search_bar.tsx @@ -80,6 +80,7 @@ export const SearchBarWrapper: FC = ({ showDatePicker={false} showQueryInput query={resultQuery} + showSavedQueryControls={false} filters={filters ?? []} onQuerySubmit={onQuerySubmit} indexPatterns={[dataView]} diff --git a/x-pack/platform/plugins/shared/aiops/public/components/search_panel/search_panel.tsx b/x-pack/platform/plugins/shared/aiops/public/components/search_panel/search_panel.tsx index b3c5adc7c4ed9..4419d382f08d0 100644 --- a/x-pack/platform/plugins/shared/aiops/public/components/search_panel/search_panel.tsx +++ b/x-pack/platform/plugins/shared/aiops/public/components/search_panel/search_panel.tsx @@ -98,6 +98,7 @@ export const SearchPanel: FC = ({ searchString, searchQueryLanguage, setS showFilterBar={true} showDatePicker={false} showQueryInput={true} + showSavedQueryControls={false} query={searchInput} onQuerySubmit={(params: { dateRange: TimeRange; query?: Query | undefined }) => searchHandler({ query: params.query })