From 27cdc10978ce39fcf704ddd6eb4ff806d2ba0504 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Fri, 3 Oct 2025 10:48:52 -0600 Subject: [PATCH] [dashboards] fix panels in sections from URL state are not transformed (#237382) Fixes https://github.com/elastic/kibana/issues/237375 PR closes the issue by adding logic to extract BWC state from panels in sections Steps * in 9.1 cloud instance - create a dashboard * add a section * add a panel to the section * Before saving dashboard, click share icon and click copy link * Go to saved object page and export goto link * Start kibana instance locally * import goto link exported from cloud instance. * Open goto link. Dashboard should open as expected with panel in section (cherry picked from commit 02c20927162259f8665d35abc3e46f4fa74122d3) --- .../url/bwc/extract_panels_state.test.ts | 43 +++++++++++++++++++ .../url/bwc/extract_panels_state.ts | 7 +++ 2 files changed, 50 insertions(+) diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_panels_state.test.ts b/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_panels_state.test.ts index 11f6245744fc1..75aa5cdc929e9 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_panels_state.test.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_panels_state.test.ts @@ -103,6 +103,49 @@ describe('extractPanelsState', () => { }); }); + describe('8.19', () => { + test('should migrate panels in sections', () => { + const { panels } = extractPanelsState({ + panels: [ + { + title: 'Section 1', + gridData: {}, + panels: [ + { + embeddableConfig: { + timeRange: { + from: 'now-7d/d', + to: 'now', + }, + }, + gridData: {}, + type: 'map', + }, + ], + }, + ], + }); + expect(panels).toEqual([ + { + title: 'Section 1', + grid: {}, + panels: [ + { + config: { + timeRange: { + from: 'now-7d/d', + to: 'now', + }, + }, + grid: {}, + type: 'map', + }, + ], + }, + ]); + }); + }); + describe('< 8.19 panels state', () => { test('should move id and title to config', () => { const { panels } = extractPanelsState({ diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_panels_state.ts b/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_panels_state.ts index 0d6b16ed7114d..75f65e0d9d0fe 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_panels_state.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_panels_state.ts @@ -56,6 +56,13 @@ export function extractPanelsState(state: { [key: string]: unknown }): { const standardizedPanels: DashboardState['panels'] = panels.map((legacyPanel) => { const panel = typeof legacyPanel === 'object' ? { ...legacyPanel } : {}; + if (panel.panels) { + const { panels: sectionPanels, savedObjectReferences: sectionPanelReferences } = + extractPanelsState({ panels: panel.panels }); + savedObjectReferences.push(...(sectionPanelReferences ?? [])); + panel.panels = sectionPanels; + } + // < 8.17 panels state stored panelConfig as embeddableConfig if (panel?.embeddableConfig) { panel.config = panel.embeddableConfig;