From 80ddeff0f7ca05e11f393e33b1e79f92e120a4e1 Mon Sep 17 00:00:00 2001 From: Devon Thomson Date: Wed, 4 Jan 2023 13:00:43 -0500 Subject: [PATCH 1/3] fix bug that caused timeRange to be set to undefined on dashboard rename --- .../state/dashboard_container_reducers.ts | 9 +++++++-- .../apps/lens/group2/show_underlying_data_dashboard.ts | 3 +-- 2 files changed, 8 insertions(+), 4 deletions(-) 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..1ab9a51d05a0 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: ( 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'); From fc6eced8d16fa04207572da11a64ce6ba8d63216 Mon Sep 17 00:00:00 2001 From: Devon Thomson Date: Wed, 4 Jan 2023 16:30:43 -0500 Subject: [PATCH 2/3] treat refresh interval as first class piece of state. --- .../diff_state/dashboard_diffing_functions.ts | 5 +++++ .../sync_dashboard_unified_search_state.ts | 16 ++++++++++------ .../state/dashboard_container_reducers.ts | 7 +++++++ 3 files changed, 22 insertions(+), 6 deletions(-) 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..3412c9ef7f73 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 @@ -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 1ab9a51d05a0..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 @@ -179,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 From 0ca10bee1fefc71384dabca11ecebae25535a21b Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 4 Jan 2023 21:35:37 +0000 Subject: [PATCH 3/3] [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' --- .../unified_search/sync_dashboard_unified_search_state.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3412c9ef7f73..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';