diff --git a/src/plugins/dashboard/public/dashboard_container/embeddable/integrations/diff_state/dashboard_diffing_functions.ts b/src/plugins/dashboard/public/dashboard_container/embeddable/integrations/diff_state/dashboard_diffing_functions.ts index c96424e44b38..e4cc338f15dd 100644 --- a/src/plugins/dashboard/public/dashboard_container/embeddable/integrations/diff_state/dashboard_diffing_functions.ts +++ b/src/plugins/dashboard/public/dashboard_container/embeddable/integrations/diff_state/dashboard_diffing_functions.ts @@ -99,6 +99,11 @@ export const dashboardDiffingFunctions: DashboardDiffFunctions = { return true; }, + refreshInterval: ({ currentValue, lastValue, currentInput }) => { + if (!currentInput.timeRestore) return true; // if time restore is set to false, refresh interval doesn't count as a change. + return fastIsEqual(currentValue, lastValue); + }, + controlGroupInput: ({ currentValue, lastValue }) => persistableControlGroupInputIsEqual(currentValue, lastValue), diff --git a/src/plugins/dashboard/public/dashboard_container/embeddable/integrations/unified_search/sync_dashboard_unified_search_state.ts b/src/plugins/dashboard/public/dashboard_container/embeddable/integrations/unified_search/sync_dashboard_unified_search_state.ts index 71e6cb411804..c3dc5f616330 100644 --- a/src/plugins/dashboard/public/dashboard_container/embeddable/integrations/unified_search/sync_dashboard_unified_search_state.ts +++ b/src/plugins/dashboard/public/dashboard_container/embeddable/integrations/unified_search/sync_dashboard_unified_search_state.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { merge, Subject } from 'rxjs'; +import { Subject } from 'rxjs'; import { distinctUntilChanged, finalize, switchMap, tap } from 'rxjs/operators'; import type { Filter, Query } from '@kbn/es-query'; @@ -35,7 +35,7 @@ export function syncUnifiedSearchState( getState, dispatch, onStateChange, - actions: { setFiltersAndQuery, setTimeRange }, + actions: { setFiltersAndQuery, setTimeRange, setRefreshInterval }, } = this.getReduxEmbeddableTools(); // get Observable for when the dashboard's saved filters or query change. @@ -76,10 +76,13 @@ export function syncUnifiedSearchState( } ); - const timeRefreshSubscription = merge( - timefilterService.getRefreshIntervalUpdate$(), - timefilterService.getTimeUpdate$() - ).subscribe(() => dispatch(setTimeRange(timefilterService.getTime()))); + const timeUpdateSubscription = timefilterService + .getTimeUpdate$() + .subscribe(() => dispatch(setTimeRange(timefilterService.getTime()))); + + const refreshIntervalSubscription = timefilterService + .getRefreshIntervalUpdate$() + .subscribe(() => dispatch(setRefreshInterval(timefilterService.getRefreshInterval()))); const autoRefreshSubscription = timefilterService .getAutoRefreshFetch$() @@ -96,7 +99,8 @@ export function syncUnifiedSearchState( const stopSyncingUnifiedSearchState = () => { autoRefreshSubscription.unsubscribe(); - timeRefreshSubscription.unsubscribe(); + timeUpdateSubscription.unsubscribe(); + refreshIntervalSubscription.unsubscribe(); unsubscribeFromSavedFilterChanges(); stopSyncingAppFilters(); }; 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 9ebfdebc410a..4c47b41ad67d 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 @@ -39,10 +39,15 @@ export const dashboardContainerReducers = { state.explicitInput.tags = action.payload.tags; state.explicitInput.title = action.payload.title; - state.explicitInput.timeRange = action.payload.timeRange; state.explicitInput.description = action.payload.description; state.explicitInput.timeRestore = action.payload.timeRestore; - state.explicitInput.refreshInterval = action.payload.refreshInterval; + + if (action.payload.refreshInterval) { + state.explicitInput.refreshInterval = action.payload.refreshInterval; + } + if (action.payload.timeRange) { + state.explicitInput.timeRange = action.payload.timeRange; + } }, setDescription: ( @@ -174,6 +179,13 @@ export const dashboardContainerReducers = { state.explicitInput.timeRange = action.payload; }, + setRefreshInterval: ( + state: DashboardReduxState, + action: PayloadAction + ) => { + state.explicitInput.refreshInterval = action.payload; + }, + setTimeslice: ( state: DashboardReduxState, action: PayloadAction diff --git a/x-pack/test/functional/apps/lens/group2/show_underlying_data_dashboard.ts b/x-pack/test/functional/apps/lens/group2/show_underlying_data_dashboard.ts index 64a319b9467d..4cdc584e571e 100644 --- a/x-pack/test/functional/apps/lens/group2/show_underlying_data_dashboard.ts +++ b/x-pack/test/functional/apps/lens/group2/show_underlying_data_dashboard.ts @@ -27,8 +27,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const browser = getService('browser'); const retry = getService('retry'); - // Failing: See https://github.com/elastic/kibana/issues/147625 - describe.skip('lens show underlying data from dashboard', () => { + describe('lens show underlying data from dashboard', () => { it('should show the open button for a compatible saved visualization', async () => { await PageObjects.visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis');