diff --git a/src/plugins/dashboard/public/dashboard_container/state/dashboard_container_reducers.ts b/src/plugins/dashboard/public/dashboard_container/state/dashboard_container_reducers.ts index 51d7f4e42b782..fee2d80939686 100644 --- a/src/plugins/dashboard/public/dashboard_container/state/dashboard_container_reducers.ts +++ b/src/plugins/dashboard/public/dashboard_container/state/dashboard_container_reducers.ts @@ -246,4 +246,8 @@ export const dashboardContainerReducers = { setDisableQueryInput: (state: DashboardReduxState, action: PayloadAction) => { state.componentState.disableQueryInput = action.payload; }, + + setDisableAutoRefresh: (state: DashboardReduxState, action: PayloadAction) => { + state.componentState.disableAutoRefresh = action.payload; + }, }; diff --git a/src/plugins/dashboard/public/dashboard_container/state/diffing/dashboard_diffing_integration.ts b/src/plugins/dashboard/public/dashboard_container/state/diffing/dashboard_diffing_integration.ts index cb261c6a529af..e626c98c4321d 100644 --- a/src/plugins/dashboard/public/dashboard_container/state/diffing/dashboard_diffing_integration.ts +++ b/src/plugins/dashboard/public/dashboard_container/state/diffing/dashboard_diffing_integration.ts @@ -31,6 +31,7 @@ export const reducersToIgnore: Array = 'setExpandedPanelId', 'setHasUnsavedChanges', 'setDisableQueryInput', + 'setDisableAutoRefresh', ]; /** diff --git a/src/plugins/dashboard/public/dashboard_container/types.ts b/src/plugins/dashboard/public/dashboard_container/types.ts index f602e8d2fbc03..64dc9cee28497 100644 --- a/src/plugins/dashboard/public/dashboard_container/types.ts +++ b/src/plugins/dashboard/public/dashboard_container/types.ts @@ -54,6 +54,7 @@ export interface DashboardPublicState { focusedPanelId?: string; disableQueryInput?: boolean; + disableAutoRefresh?: boolean; } export type DashboardLoadType = diff --git a/src/plugins/dashboard/public/dashboard_top_nav/internal_dashboard_top_nav.tsx b/src/plugins/dashboard/public/dashboard_top_nav/internal_dashboard_top_nav.tsx index e3cb1b17c791a..0f07afde9339f 100644 --- a/src/plugins/dashboard/public/dashboard_top_nav/internal_dashboard_top_nav.tsx +++ b/src/plugins/dashboard/public/dashboard_top_nav/internal_dashboard_top_nav.tsx @@ -94,6 +94,7 @@ export function InternalDashboardTopNav({ (state) => state.componentState.hasRunClientsideMigrations ); const disableQueryInput = dashboard.select((state) => state.componentState.disableQueryInput); + const disableAutoRefresh = dashboard.select((state) => state.componentState.disableAutoRefresh); const hasUnsavedChanges = dashboard.select((state) => state.componentState.hasUnsavedChanges); const fullScreenMode = dashboard.select((state) => state.componentState.fullScreenMode); const savedQueryId = dashboard.select((state) => state.componentState.savedQueryId); @@ -340,6 +341,7 @@ export function InternalDashboardTopNav({ : setHeaderActionMenu } disableQueryInput={disableQueryInput} + disableAutoRefresh={disableAutoRefresh} className={fullScreenMode ? 'kbnTopNavMenu-isFullScreen' : undefined} config={ visibilityProps.showTopNavMenu diff --git a/src/plugins/discover/public/embeddable/components/editor/saved_search_editor_dataview.tsx b/src/plugins/discover/public/embeddable/components/editor/saved_search_editor_dataview.tsx index 37356847bb836..a3be7c7204edb 100644 --- a/src/plugins/discover/public/embeddable/components/editor/saved_search_editor_dataview.tsx +++ b/src/plugins/discover/public/embeddable/components/editor/saved_search_editor_dataview.tsx @@ -58,6 +58,7 @@ export function SavedSearchDataviewEditor({ useEffect(() => { (api.parentApi as DashboardContainer).ignoreUnifiedSearch = true; + (api.parentApi as DashboardContainer).dispatch.setDisableAutoRefresh(true); /** Handle query */ const originalQuery = services.data.query.queryString.getQuery(); @@ -103,6 +104,7 @@ export function SavedSearchDataviewEditor({ services.timefilter.setTime(originalTime); (api.parentApi as DashboardContainer).ignoreUnifiedSearch = false; + (api.parentApi as DashboardContainer).dispatch.setDisableAutoRefresh(false); querySubscription.unsubscribe(); filtersSubscription.unsubscribe(); timeRangeSubscription.unsubscribe(); diff --git a/src/plugins/discover/public/embeddable/components/editor/saved_search_editor_esql.tsx b/src/plugins/discover/public/embeddable/components/editor/saved_search_editor_esql.tsx index 4b647bfa8d198..6693198fff886 100644 --- a/src/plugins/discover/public/embeddable/components/editor/saved_search_editor_esql.tsx +++ b/src/plugins/discover/public/embeddable/components/editor/saved_search_editor_esql.tsx @@ -52,6 +52,7 @@ export function SavedSearchEsqlEditor({ useEffect(() => { (api.parentApi as DashboardContainer).ignoreUnifiedSearch = true; (api.parentApi as DashboardContainer).dispatch.setDisableQueryInput(true); + (api.parentApi as DashboardContainer).dispatch.setDisableAutoRefresh(true); /** Handle filters */ const originalFilters = services.filterManager.getFilters(); @@ -82,12 +83,12 @@ export function SavedSearchEsqlEditor({ }); return () => { - (api.parentApi as DashboardContainer).dispatch.setDisableQueryInput(false); - services.filterManager.setFilters(originalFilters); services.timefilter.setTime(originalTime); (api.parentApi as DashboardContainer).ignoreUnifiedSearch = false; + (api.parentApi as DashboardContainer).dispatch.setDisableQueryInput(false); + (api.parentApi as DashboardContainer).dispatch.setDisableAutoRefresh(false); filtersSubscription.unsubscribe(); timeRangeSubscription.unsubscribe(); }; diff --git a/src/plugins/unified_search/public/query_string_input/query_bar_top_row.tsx b/src/plugins/unified_search/public/query_string_input/query_bar_top_row.tsx index ff4fdf7beb33c..9bf0e5d3b975b 100644 --- a/src/plugins/unified_search/public/query_string_input/query_bar_top_row.tsx +++ b/src/plugins/unified_search/public/query_string_input/query_bar_top_row.tsx @@ -159,6 +159,7 @@ export interface QueryBarTopRowProps showDatePicker?: boolean; isDisabled?: boolean; disableQueryInput?: boolean; + disableAutoRefresh?: boolean; showAutoRefreshOnly?: boolean; timeHistory?: TimeHistoryContract; timeRangeForSuggestionsOverride?: boolean; @@ -505,7 +506,7 @@ export const QueryBarTopRow = React.memo( refreshInterval={props.refreshInterval} onTimeChange={onTimeChange} onRefresh={onRefresh} - onRefreshChange={props.onRefreshChange} + onRefreshChange={props.disableAutoRefresh ? undefined : props.onRefreshChange} showUpdateButton={false} recentlyUsedRanges={recentlyUsedRanges} locale={i18n.getLocale()} diff --git a/src/plugins/unified_search/public/search_bar/create_search_bar.tsx b/src/plugins/unified_search/public/search_bar/create_search_bar.tsx index 6be8d1be842aa..0c251ca2efed6 100644 --- a/src/plugins/unified_search/public/search_bar/create_search_bar.tsx +++ b/src/plugins/unified_search/public/search_bar/create_search_bar.tsx @@ -44,6 +44,7 @@ export type StatefulSearchBarProps = onSavedQueryIdChange?: (savedQueryId?: string) => void; onFiltersUpdated?: (filters: Filter[]) => void; disableQueryInput?: boolean; + disableAutoRefresh?: boolean; }; // Respond to user changing the filters @@ -228,6 +229,7 @@ export function createSearchBar({ submitButtonStyle={props.submitButtonStyle} isDisabled={props.isDisabled} disableQueryInput={props.disableQueryInput} + disableAutoRefresh={props.disableAutoRefresh} screenTitle={props.screenTitle} indexPatterns={props.indexPatterns} indicateNoData={props.indicateNoData} 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 c8955f252d7e0..2818fadcb1cb8 100644 --- a/src/plugins/unified_search/public/search_bar/search_bar.tsx +++ b/src/plugins/unified_search/public/search_bar/search_bar.tsx @@ -127,6 +127,7 @@ export interface SearchBarOwnProps { */ isDisabled?: boolean; disableQueryInput?: boolean; + disableAutoRefresh?: boolean; submitOnBlur?: boolean; @@ -617,6 +618,7 @@ class SearchBarUI extends C showQueryInput={this.props.showQueryInput} showAddFilter={this.props.showFilterBar} disableQueryInput={this.props.disableQueryInput} + disableAutoRefresh={this.props.disableAutoRefresh} isDisabled={this.props.isDisabled} onRefresh={this.props.onRefresh} onRefreshChange={this.props.onRefreshChange}