Skip to content

Commit

Permalink
Add a flag to disable the default auto refresh option in unified search
Browse files Browse the repository at this point in the history
  • Loading branch information
jennypavlova committed May 8, 2023
1 parent acce3cb commit 1aaff3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type StatefulSearchBarProps<QT extends Query | AggregateQuery = Query> =
savedQueryId?: string;
onSavedQueryIdChange?: (savedQueryId?: string) => void;
onFiltersUpdated?: (filters: Filter[]) => void;
isAutoRefreshDisabled?: boolean;
};

// Respond to user changing the filters
Expand All @@ -56,7 +57,10 @@ const defaultFiltersUpdated = (
};

// Respond to user changing the refresh settings
const defaultOnRefreshChange = (queryService: QueryStart) => {
const defaultOnRefreshChange = (queryService: QueryStart, isAutoRefreshDisabled?: boolean) => {
if (isAutoRefreshDisabled) {
return;
}
const { timefilter } = queryService.timefilter;
return (options: { isPaused: boolean; refreshInterval: number }) => {
timefilter.setRefreshInterval({
Expand Down Expand Up @@ -218,7 +222,7 @@ export function createSearchBar({
filters={filters}
query={query}
onFiltersUpdated={defaultFiltersUpdated(data.query, props.onFiltersUpdated)}
onRefreshChange={defaultOnRefreshChange(data.query)}
onRefreshChange={defaultOnRefreshChange(data.query, props.isAutoRefreshDisabled)}
savedQuery={savedQuery}
onQuerySubmit={defaultOnQuerySubmit(props, data.query, query)}
onClearSavedQuery={defaultOnClearSavedQuery(props, clearSavedQuery)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const UnifiedSearchBar = () => {
showQueryInput
showQueryMenu
useDefaultBehaviors
isAutoRefreshDisabled
/>
</EuiFlexItem>
<EuiFlexItem>
Expand Down

0 comments on commit 1aaff3d

Please sign in to comment.