Skip to content

Commit

Permalink
[ML] AIOps Hiding saved query controls (#210556)
Browse files Browse the repository at this point in the history
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 #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)
  • Loading branch information
jgowdyelastic authored Feb 12, 2025
1 parent 9cad587 commit 36c764e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export interface QueryBarMenuProps extends WithCloseFilterEditorConfirmModalProp
showQueryInput?: boolean;
showFilterBar?: boolean;
showSaveQuery?: boolean;
showSavedQueryControls?: boolean;
timeRangeForSuggestionsOverride?: boolean;
filtersForSuggestions?: Filter[];
indexPatterns?: Array<DataView | string>;
Expand Down Expand Up @@ -110,6 +111,7 @@ function QueryBarMenuComponent({
showQueryInput,
showFilterBar,
showSaveQuery,
showSavedQueryControls,
indexPatterns,
timeRangeForSuggestionsOverride,
filtersForSuggestions,
Expand Down Expand Up @@ -176,6 +178,7 @@ function QueryBarMenuComponent({
timeFilter,
query,
showSaveQuery,
showSavedQueryControls,
showFilterBar,
showQueryInput,
savedQueryService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export interface QueryBarMenuPanelsProps {
timeFilter?: SavedQueryTimeFilter;
query?: Query;
showSaveQuery?: boolean;
showSavedQueryControls?: boolean;
showQueryInput?: boolean;
showFilterBar?: boolean;
savedQueryService: SavedQueryService;
Expand Down Expand Up @@ -199,6 +200,7 @@ export function useQueryBarMenuPanels({
timeFilter,
query,
showSaveQuery,
showSavedQueryControls = true,
showFilterBar,
showQueryInput,
savedQueryService,
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export interface SearchBarOwnProps<QT extends AggregateQuery | Query = Query> {
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?: (
Expand Down Expand Up @@ -556,6 +558,7 @@ class SearchBarUI<QT extends (Query | AggregateQuery) | Query = Query> 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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const SearchBarWrapper: FC<SearchBarProps> = ({
showDatePicker={false}
showQueryInput
query={resultQuery}
showSavedQueryControls={false}
filters={filters ?? []}
onQuerySubmit={onQuerySubmit}
indexPatterns={[dataView]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const SearchPanel: FC<Props> = ({ searchString, searchQueryLanguage, setS
showFilterBar={true}
showDatePicker={false}
showQueryInput={true}
showSavedQueryControls={false}
query={searchInput}
onQuerySubmit={(params: { dateRange: TimeRange; query?: Query | undefined }) =>
searchHandler({ query: params.query })
Expand Down

0 comments on commit 36c764e

Please sign in to comment.