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;