diff --git a/src/platform/packages/private/kbn-controls-renderer/src/components/control_panel.test.tsx b/src/platform/packages/private/kbn-controls-renderer/src/components/control_panel.test.tsx index 20bfdd61276f4..b1620c4d7bb67 100644 --- a/src/platform/packages/private/kbn-controls-renderer/src/components/control_panel.test.tsx +++ b/src/platform/packages/private/kbn-controls-renderer/src/components/control_panel.test.tsx @@ -82,7 +82,7 @@ describe('render', () => { { const controlPanel = render( ) | null>(null); const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ - id: uid, + id, }); const [viewMode, disabledActionIds] = useBatchedPublishingSubjects( @@ -80,9 +80,9 @@ export const ControlPanel = ({ const setRefs = useCallback( (ref: HTMLElement | null) => { setNodeRef(ref); - setControlPanelRef(uid, ref); + setControlPanelRef(id, ref); }, - [uid, setNodeRef, setControlPanelRef] + [id, setNodeRef, setControlPanelRef] ); const onApiAvailable = useCallback( @@ -110,7 +110,7 @@ export const ControlPanel = ({ parentApi} onApiAvailable={onApiAvailable} diff --git a/src/platform/packages/private/kbn-controls-renderer/src/controls_renderer.tsx b/src/platform/packages/private/kbn-controls-renderer/src/controls_renderer.tsx index 845661731c444..12138709f1d57 100644 --- a/src/platform/packages/private/kbn-controls-renderer/src/controls_renderer.tsx +++ b/src/platform/packages/private/kbn-controls-renderer/src/controls_renderer.tsx @@ -130,7 +130,7 @@ export const ControlsRenderer = ({ parentApi={parentApi} control={{ ...control, - uid: control.id!, + id: control.id!, }} setControlPanelRef={setControlPanelRef} /> diff --git a/src/platform/packages/shared/controls/controls-schemas/src/controls_group_schema.ts b/src/platform/packages/shared/controls/controls-schemas/src/controls_group_schema.ts index ee0e74852a753..24529b1d6ae60 100644 --- a/src/platform/packages/shared/controls/controls-schemas/src/controls_group_schema.ts +++ b/src/platform/packages/shared/controls/controls-schemas/src/controls_group_schema.ts @@ -35,7 +35,7 @@ export const controlWidthSchema = schema.oneOf( ); export const pinnedControlSchema = schema.object({ - uid: schema.maybe(schema.string({ meta: { description: 'The unique ID of the control' } })), + id: schema.maybe(schema.string({ meta: { description: 'The unique ID of the control' } })), width: controlWidthSchema, grow: schema.boolean({ defaultValue: DEFAULT_PINNED_CONTROL_STATE.grow, diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/deserialize_layout.test.ts b/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/deserialize_layout.test.ts index 41c2bd90faaff..27782f9ad66ba 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/deserialize_layout.test.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/deserialize_layout.test.ts @@ -17,7 +17,7 @@ describe('deserializeLayout', () => { { grid: { x: 0, y: 0, w: 6, h: 6 }, config: { title: 'panel One' }, - uid: '1', + id: '1', type: 'testPanelType', }, { @@ -26,12 +26,12 @@ describe('deserializeLayout', () => { grid: { y: 6, }, - uid: 'section1', + id: 'section1', panels: [ { grid: { x: 0, y: 0, w: 6, h: 6 }, config: { title: 'panel Three' }, - uid: '3', + id: '3', type: 'testPanelType', }, ], @@ -39,14 +39,14 @@ describe('deserializeLayout', () => { ], [ { - uid: 'control1', + id: 'control1', type: 'someType', width: 'small', grow: true, config: { someValue: 'test' }, } as unknown as PinnedControlState, { - uid: 'control2', + id: 'control2', type: 'anotherType', config: { anotherValue: 1 }, } as unknown as PinnedControlState, diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/deserialize_layout.ts b/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/deserialize_layout.ts index cc7ecbd7e14c7..6058d36a0089c 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/deserialize_layout.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/deserialize_layout.ts @@ -21,7 +21,7 @@ export function deserializeLayout( panels: {}, sections: {}, pinnedPanels: (pinnedPanels ?? []).reduce((prev, panel, index) => { - const panelId = panel.uid ?? v4(); + const panelId = panel.id ?? v4(); const { width, grow, type, config } = panel; childState[panelId] = config; // push to child state return { ...prev, [panelId]: { type, width, grow, order: index } }; @@ -29,7 +29,7 @@ export function deserializeLayout( }; function pushPanel(panel: DashboardPanel, sectionId?: string) { - const panelId = panel.uid ?? v4(); + const panelId = panel.id ?? v4(); layout.panels[panelId] = { type: panel.type, grid: { @@ -44,8 +44,8 @@ export function deserializeLayout( panels?.forEach((widget) => { if (isDashboardSection(widget)) { - const { panels: sectionPanels, uid, ...restOfSection } = widget; - const sectionId = uid ?? v4(); + const { panels: sectionPanels, id, ...restOfSection } = widget; + const sectionId = id ?? v4(); layout.sections[sectionId] = restOfSection; sectionPanels.forEach((panel) => { pushPanel(panel, sectionId); diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/layout_manager.test.ts b/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/layout_manager.test.ts index 9661f5769df36..46442ba81e026 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/layout_manager.test.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/layout_manager.test.ts @@ -52,13 +52,13 @@ describe('layout manager', () => { grid: { w: 1, h: 1, x: 0, y: 0 }, type: 'testPanelType', config: { title: 'Panel One' }, - uid: PANEL_ONE_ID, + id: PANEL_ONE_ID, }; const pinnedControls: DashboardState['pinned_panels'] = [ { ...DEFAULT_PINNED_CONTROL_STATE, - uid: 'control1', + id: 'control1', type: 'options_list_control', config: { ...DEFAULT_DSL_OPTIONS_LIST_STATE, @@ -68,7 +68,7 @@ describe('layout manager', () => { }, { ...DEFAULT_PINNED_CONTROL_STATE, - uid: 'control2', + id: 'control2', type: 'options_list_control', config: { ...DEFAULT_DSL_OPTIONS_LIST_STATE, @@ -91,7 +91,7 @@ describe('layout manager', () => { const section1 = { title: 'Section one', collapsed: false, - uid: 'section1', + id: 'section1', grid: { y: 1, }, @@ -398,7 +398,7 @@ describe('layout manager', () => { [ panel1, { - uid: 'control3', + id: 'control3', type: 'options_list_control', config: {}, grid: { x: 0, y: 2, h: 1, w: 1 }, @@ -428,7 +428,7 @@ describe('layout manager', () => { }, }); expect(layoutManager.api.layout$.getValue().panels).toEqual({ - [panel1.uid]: pick(panel1, ['grid', 'type']), + [panel1.id]: pick(panel1, ['grid', 'type']), // control3 gets removed as a panel }); }); @@ -463,7 +463,7 @@ describe('layout manager', () => { }, }); expect(layoutManager.api.layout$.getValue().panels).toEqual({ - [panel1.uid]: { + [panel1.id]: { type: 'testPanelType', grid: { ...panel1.grid, y: 2 }, // push panel 1 down, }, @@ -482,7 +482,7 @@ describe('layout manager', () => { panel1, { ...pinnedControls[1], - uid: 'control2', + id: 'control2', grid: { x: 0, y: 0, w: 12, h: 12 }, config: { title: 'Control' }, }, diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/serialize_layout.test.ts b/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/serialize_layout.test.ts index 8b75841952498..9ad60558cb2ff 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/serialize_layout.test.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/serialize_layout.test.ts @@ -52,7 +52,7 @@ describe('serializeLayout', () => { grid: { y: 6, }, - uid: 'section1', + id: 'section1', title: 'Section One', }, }, @@ -85,14 +85,15 @@ describe('serializeLayout', () => { "x": 0, "y": 0, }, + "id": "1", "type": "testPanelType", - "uid": "1", }, Object { "collapsed": true, "grid": Object { "y": 6, }, + "id": "section1", "panels": Array [ Object { "config": Object { @@ -104,12 +105,11 @@ describe('serializeLayout', () => { "x": 0, "y": 0, }, + "id": "3", "type": "testPanelType", - "uid": "3", }, ], "title": "Section One", - "uid": "section1", }, ] `); @@ -119,16 +119,16 @@ describe('serializeLayout', () => { "config": Object { "anotherValue": "test", }, + "id": "control2", "type": "someOtherControl", - "uid": "control2", }, Object { "config": Object { "selection": "some value", }, "grow": true, + "id": "control1", "type": "someControl", - "uid": "control1", "width": "small", }, ] diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/serialize_layout.ts b/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/serialize_layout.ts index 23f7d7bd8d7a6..49d0ae3b4c947 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/serialize_layout.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_api/layout_manager/serialize_layout.ts @@ -18,7 +18,7 @@ export function serializeLayout( ): Pick { const sections: { [sectionId: string]: DashboardSection } = {}; Object.entries(layout.sections).forEach(([sectionId, sectionState]) => { - sections[sectionId] = { ...sectionState, uid: sectionId, panels: [] }; + sections[sectionId] = { ...sectionState, id: sectionId, panels: [] }; }); const panels: DashboardState['panels'] = []; @@ -29,7 +29,7 @@ export function serializeLayout( const panelState = { type, grid: restOfGridData, - uid: panelId, + id: panelId, config, }; @@ -46,7 +46,7 @@ export function serializeLayout( .sort(([, { order: orderA }], [, { order: orderB }]) => orderA - orderB) .map(([id, panel]) => { return { - uid: id, + id, ...omit(panel, 'order'), config: childState[id], } as Required['pinned_panels'][number]; diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_api/load_dashboard_api/transform_panels.test.ts b/src/platform/plugins/shared/dashboard/public/dashboard_api/load_dashboard_api/transform_panels.test.ts index 9ecbb9d671ce4..799474b65d051 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_api/load_dashboard_api/transform_panels.test.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_api/load_dashboard_api/transform_panels.test.ts @@ -35,7 +35,7 @@ describe('transformPanels', () => { { grid: { x: 0, y: 0, w: 6, h: 6 }, config: {}, - uid: '1', + id: '1', type: 'testPanelType', }, { @@ -44,12 +44,12 @@ describe('transformPanels', () => { grid: { y: 6, }, - uid: 'section1', + id: 'section1', panels: [ { grid: { x: 0, y: 0, w: 6, h: 6 }, config: {}, - uid: '3', + id: '3', type: 'testPanelType', }, ], @@ -84,7 +84,7 @@ describe('transformPanels', () => { { grid: { x: 0, y: 0, w: 6, h: 6 }, config: { title: 'panel One' }, - uid: '1', + id: '1', type: 'testPanelType', }, ]); diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_api/load_dashboard_api/transform_panels.ts b/src/platform/plugins/shared/dashboard/public/dashboard_api/load_dashboard_api/transform_panels.ts index 85f8d82d66563..a7e6968f27847 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_api/load_dashboard_api/transform_panels.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_api/load_dashboard_api/transform_panels.ts @@ -24,7 +24,7 @@ export async function transformPanels(panels: DashboardState['panels'], referenc return await asyncMap(panels ?? [], async (panel) => { if (isDashboardSection(panel)) { const panelsInSection = await asyncMap(panel.panels, async (panelInSection) => { - return await transformPanel(panelInSection, filterReferences(panelInSection.uid)); + return await transformPanel(panelInSection, filterReferences(panelInSection.id)); }); return { ...panel, @@ -32,7 +32,7 @@ export async function transformPanels(panels: DashboardState['panels'], referenc }; } - return await transformPanel(panel, filterReferences(panel.uid)); + return await transformPanel(panel, filterReferences(panel.id)); }); } @@ -59,7 +59,7 @@ async function transformPanel(legacyPanel: DashboardPanel, references?: Referenc } catch (transformOutError) { // eslint-disable-next-line no-console console.warn( - `Unable to transform panel state, panelId: ${panel.uid}, error: ${transformOutError}` + `Unable to transform panel state, panelId: ${panel.id}, error: ${transformOutError}` ); // do not prevent dashboard render on transform error return panel; 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 33bc47b36024d..b603710ea1c54 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 @@ -11,6 +11,73 @@ import { coreServices } from '../../../services/kibana_services'; import { extractPanelsState } from './extract_panels_state'; describe('extractPanelsState', () => { + describe('< 9.4 panels state', () => { + test('should switch `uid` to `id`', () => { + const { panels } = extractPanelsState({ + panels: [ + { + grid: { x: 0, y: 0, w: 24, h: 15 }, + type: 'lens', + uid: 'panel1', + config: {}, + }, + { + title: 'Section 1', + grid: { y: 1, i: 'section1' }, + uid: 'section1', + panels: [ + { + grid: { x: 0, y: 2, w: 24, h: 15 }, + type: 'lens', + config: { + savedObjectId: 'byReference', + }, + uid: 'panel2', + }, + ], + }, + ], + }); + expect(panels).toMatchInlineSnapshot(` + Array [ + Object { + "config": Object {}, + "grid": Object { + "h": 15, + "w": 24, + "x": 0, + "y": 0, + }, + "id": "panel1", + "type": "lens", + }, + Object { + "grid": Object { + "y": 1, + }, + "id": "section1", + "panels": Array [ + Object { + "config": Object { + "savedObjectId": "byReference", + }, + "grid": Object { + "h": 15, + "w": 24, + "x": 0, + "y": 2, + }, + "id": "panel2", + "type": "lens", + }, + ], + "title": "Section 1", + }, + ] + `); + }); + }); + describe('< 9.3 panels state', () => { test('should remove "i" from grid', () => { const { panels } = extractPanelsState({ @@ -43,13 +110,14 @@ describe('extractPanelsState', () => { "x": 0, "y": 0, }, + "id": "panel1", "type": "lens", - "uid": "panel1", }, Object { "grid": Object { "y": 1, }, + "id": "section1", "panels": Array [ Object { "config": Object {}, @@ -59,12 +127,11 @@ describe('extractPanelsState', () => { "x": 0, "y": 2, }, + "id": "panelInSection", "type": "lens", - "uid": "panelInSection", }, ], "title": "Section 1", - "uid": "section1", }, ] `); @@ -91,7 +158,7 @@ describe('extractPanelsState', () => { ]); }); - test('should move panelIndex to uid', () => { + test('should move panelIndex to id', () => { const { panels } = extractPanelsState({ panels: [ { @@ -107,7 +174,7 @@ describe('extractPanelsState', () => { config: {}, grid: { x: 0, y: 0, w: 24, h: 15 }, type: 'lens', - uid: 'fizz', + id: 'fizz', }, ]); }); @@ -238,7 +305,7 @@ describe('extractPanelsState', () => { }, grid: {}, type: 'map', - uid: 'c505cc42-fbde-451d-8720-302dc78d7e0d', + id: 'c505cc42-fbde-451d-8720-302dc78d7e0d', }, ]); }); @@ -271,7 +338,7 @@ describe('extractPanelsState', () => { }, grid: {}, type: 'map', - uid: 'c505cc42-fbde-451d-8720-302dc78d7e0d', + id: 'c505cc42-fbde-451d-8720-302dc78d7e0d', }, ]); }); 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 72b0aa8ae93d7..26c6a1faf5895 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,7 @@ export function extractPanelsState(state: { [key: string]: unknown }): { const panel = typeof legacyPanel === 'object' ? { ...legacyPanel } : {}; if (panel.panels) { + // this is a section, since it has its own panels const { panels: sectionPanels, savedObjectReferences: sectionPanelReferences } = extractPanelsState({ panels: panel.panels }); savedObjectReferences.push(...(sectionPanelReferences ?? [])); @@ -80,16 +81,21 @@ export function extractPanelsState(state: { [key: string]: unknown }): { delete panel.gridData; } - // < 9.2 uid stored as panelIndex + // < 9.2 id stored as panelIndex if (panel?.panelIndex) { - panel.uid = panel.panelIndex; - delete panel.panelIndex; - } + /** + * <8.19 'id' (saved object id) stored as siblings to config; + * this is checked as part of the `panelIndex` check because... + * - <8.19 `id` refers to saved object id + * - >9.3 `id` refers to the unique panel index + */ + if (panel.id && panel.config && typeof panel.config === 'object') { + panel.config.savedObjectId = panel.id; + delete panel.id; + } - // <8.19 'id' (saved object id) stored as siblings to config - if (panel.id && panel.config && typeof panel.config === 'object') { - panel.config.savedObjectId = panel.id; - delete panel.id; + panel.id = panel.panelIndex; + delete panel.panelIndex; } // <8.19 'title' stored as siblings to config @@ -98,13 +104,19 @@ export function extractPanelsState(state: { [key: string]: unknown }): { delete panel.title; } + // < 9.4 `id` is stored as `uid` + if (panel.uid) { + panel.id = panel.uid; + delete panel.uid; + } + // < 9.2 dashboard managed saved object refs for panels // Add saved object ref for panels that contain savedObjectId // TODO remove once all panels inject references in dashboard server api - const { config, uid, type } = panel; - if (uid && type && config?.savedObjectId && typeof config?.savedObjectId === 'string') { + const { config, id, type } = panel; + if (id && type && config?.savedObjectId && typeof config?.savedObjectId === 'string') { savedObjectReferences.push( - ...prefixReferencesFromPanel(uid, [ + ...prefixReferencesFromPanel(id, [ { id: config.savedObjectId, name: SAVED_OBJECT_REF_NAME, @@ -118,8 +130,8 @@ export function extractPanelsState(state: { [key: string]: unknown }): { if (panel.grid) { const { i, ...rest } = panel.grid; panel.grid = rest; - if (i && !panel.uid) { - panel.uid = i; + if (i && !panel.id) { + panel.id = i; } } diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_pinned_panels_state.test.ts b/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_pinned_panels_state.test.ts index 5fef7429fc063..b99bfc4ed174f 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_pinned_panels_state.test.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_pinned_panels_state.test.ts @@ -10,7 +10,7 @@ import { extractDashboardState } from './extract_dashboard_state'; describe('extractDashboardState', () => { - describe('>=9.4 state', () => { + describe('>9.4 state', () => { test('should extract controls', () => { const controlGroupInput94 = { controls: [ @@ -80,12 +80,55 @@ describe('extractDashboardState', () => { }); }); + describe('9.4 state', () => { + test('should switch `uid` to `id`', () => { + const controlGroupInput94 = { + controls: [ + { + config: {}, + uid: 'control1', + grow: true, + type: 'optionsListControl', + width: 'small', + }, + { + config: {}, + uid: 'control2', + grow: false, + type: 'optionsListControl', + width: 'medium', + }, + ], + }; + const dashboardState = extractDashboardState({ + controlGroupInput: controlGroupInput94, + }); + expect(dashboardState.pinned_panels).toEqual([ + { + config: {}, + id: 'control1', + grow: true, + type: 'options_list_control', + width: 'small', + }, + { + config: {}, + id: 'control2', + grow: false, + type: 'options_list_control', + width: 'medium', + }, + ]); + }); + }); + describe('>= 8.19 to <9.4 state', () => { test('should extract controls', () => { const dashboardState = extractDashboardState({ controlGroupInput: { controls: [ { + uid: 'control1', controlConfig: { dataViewId: '90943e30-9a47-11e8-b64d-95841ca0b247', fieldName: 'machine.os.keyword', @@ -100,6 +143,7 @@ describe('extractDashboardState', () => { }); expect(dashboardState.pinned_panels).toEqual([ { + id: 'control1', config: { data_view_id: '90943e30-9a47-11e8-b64d-95841ca0b247', field_name: 'machine.os.keyword', @@ -286,7 +330,7 @@ describe('extractDashboardState', () => { type: 'options_list_control', grow: true, width: 'small', - uid: 'd3d7af60-4c81-11e8-b3d7-01146121b73d', + id: 'd3d7af60-4c81-11e8-b3d7-01146121b73d', }, { config: { @@ -296,7 +340,7 @@ describe('extractDashboardState', () => { }, type: 'options_list_control', grow: false, - uid: '6c4f5ff4-92ff-4b40-bcc7-9aea6b06d693', + id: '6c4f5ff4-92ff-4b40-bcc7-9aea6b06d693', }, ]); }); @@ -334,7 +378,7 @@ describe('extractDashboardState', () => { use_global_filters: false, ignore_validations: false, }, - uid: '6c4f5ff4-92ff-4b40-bcc7-9aea6b06d693', + id: '6c4f5ff4-92ff-4b40-bcc7-9aea6b06d693', type: 'options_list_control', }, ]); @@ -366,7 +410,7 @@ describe('extractDashboardState', () => { field_name: 'machine.os.keyword', selected_options: ['win 7'], }, - uid: '8311639d-92e5-4aa5-99a4-9502b10eead5', + id: '8311639d-92e5-4aa5-99a4-9502b10eead5', grow: true, type: 'options_list_control', width: 'small', diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_pinned_panels_state.ts b/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_pinned_panels_state.ts index 399837492644b..ebcd39469a829 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_pinned_panels_state.ts +++ b/src/platform/plugins/shared/dashboard/public/dashboard_app/url/bwc/extract_pinned_panels_state.ts @@ -46,7 +46,12 @@ export function extractPinnedPanelsState(state: { [key: string]: unknown }): { if ('controlConfig' in control) { // >8.18 to <9.4 controls had `config` stored under `controlConfig` const { controlConfig, ...rest } = control; - return { ...rest, config: controlConfig }; + control = { ...rest, config: controlConfig }; + } + // < 9.4 `id` is stored as `uid` + if (control.uid) { + const { uid, ...rest } = control; + control = { id: uid, ...rest }; } return control; // otherwise, we are dealing with state >=9.4 }); @@ -61,7 +66,7 @@ export function extractPinnedPanelsState(state: { [key: string]: unknown }): { if ('explicitInput' in control) { const { explicitInput, order, ...restOfControlState } = control; return { - uid: controlId, + id: controlId, ...restOfControlState, config: explicitInput, }; @@ -69,7 +74,7 @@ export function extractPinnedPanelsState(state: { [key: string]: unknown }): { // >=8.16 to <=8.18 controls were exported as flat objects for all configs const { grow, order, type, width, ...config } = control; return { - uid: controlId, + id: controlId, type, ...(grow !== undefined && { grow }), ...(width !== undefined && { width }), diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_renderer/grid/dashboard_grid.test.tsx b/src/platform/plugins/shared/dashboard/public/dashboard_renderer/grid/dashboard_grid.test.tsx index a6fd0068102b4..0e7049e128833 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_renderer/grid/dashboard_grid.test.tsx +++ b/src/platform/plugins/shared/dashboard/public/dashboard_renderer/grid/dashboard_grid.test.tsx @@ -258,7 +258,7 @@ describe('DashboardGrid', () => { title: 'Empty section', collapsed: false, grid: { y: 8 }, - uid: 'emptySection', + id: 'emptySection', panels: [], }, ], diff --git a/src/platform/plugins/shared/dashboard/public/dashboard_renderer/grid/dashboard_grid_item.test.tsx b/src/platform/plugins/shared/dashboard/public/dashboard_renderer/grid/dashboard_grid_item.test.tsx index 789799d7bb2e9..fb459bf03a40a 100644 --- a/src/platform/plugins/shared/dashboard/public/dashboard_renderer/grid/dashboard_grid_item.test.tsx +++ b/src/platform/plugins/shared/dashboard/public/dashboard_renderer/grid/dashboard_grid_item.test.tsx @@ -41,13 +41,13 @@ const createAndMountDashboardGridItem = (props: DashboardGridItemProps) => { grid: { x: 0, y: 0, w: 6, h: 6, i: '1' }, type: TEST_EMBEDDABLE, config: {}, - uid: '1', + id: '1', }, { grid: { x: 6, y: 6, w: 6, h: 6, i: '2' }, type: TEST_EMBEDDABLE, config: {}, - uid: '2', + id: '2', }, ]; const { api, internalApi } = buildMockDashboardApi({ overrides: { panels } }); diff --git a/src/platform/plugins/shared/dashboard/public/mocks.tsx b/src/platform/plugins/shared/dashboard/public/mocks.tsx index b1132e0451f06..8114c1bf034f7 100644 --- a/src/platform/plugins/shared/dashboard/public/mocks.tsx +++ b/src/platform/plugins/shared/dashboard/public/mocks.tsx @@ -115,13 +115,13 @@ export function getMockPanels() { { grid: { x: 0, y: 0, w: 6, h: 6 }, config: { title: 'panel One' }, - uid: '1', + id: '1', type: 'testPanelType', }, { grid: { x: 6, y: 0, w: 6, h: 6 }, config: { title: 'panel Two' }, - uid: '2', + id: '2', type: 'testPanelType', }, ]; @@ -136,12 +136,12 @@ export function getMockPanelsWithSections() { grid: { y: 6, }, - uid: 'section1', + id: 'section1', panels: [ { grid: { x: 0, y: 0, w: 6, h: 6 }, config: { title: 'panel Three' }, - uid: '3', + id: '3', type: 'testPanelType', }, ], @@ -152,12 +152,12 @@ export function getMockPanelsWithSections() { grid: { y: 7, }, - uid: 'section2', + id: 'section2', panels: [ { grid: { x: 0, y: 0, w: 6, h: 6 }, config: { title: 'panel Four' }, - uid: '4', + id: '4', type: 'testPanelType', }, ], diff --git a/src/platform/plugins/shared/dashboard/server/api/dashboard_state_schemas.ts b/src/platform/plugins/shared/dashboard/server/api/dashboard_state_schemas.ts index 73c328f97ced1..e374323db9d47 100644 --- a/src/platform/plugins/shared/dashboard/server/api/dashboard_state_schemas.ts +++ b/src/platform/plugins/shared/dashboard/server/api/dashboard_state_schemas.ts @@ -54,12 +54,7 @@ export const panelGridSchema = schema.object( export function getPanelSchema(isDashboardAppRequest: boolean) { const basePanelProps = { grid: panelGridSchema, - /** - * `uid` was chosen as a name instead of `id` to avoid bwc issues with legacy dashboard URL state that used `id` to - * represent ids of library items in by-reference panels. This was previously called `panelIndex` in DashboardPanelState. - * In the stored object, `uid` continues to map to `panelIndex`. - */ - uid: schema.maybe( + id: schema.maybe( schema.string({ meta: { description: 'The unique ID of the panel.' }, }) @@ -106,7 +101,7 @@ export function getPanelSchema(isDashboardAppRequest: boolean) { panelSchemas as [ ObjectType<{ grid: ObjectType<{ x: Type; y: Type; w: Type; h: Type }>; - uid: Type; + id: Type; version: Type; type: Type; config: ObjectType<{}>; @@ -135,7 +130,7 @@ export function getSectionSchema(isDashboardAppRequest: boolean) { defaultValue: [], maxSize: MAX_PANELS, }), - uid: schema.maybe( + id: schema.maybe( schema.string({ meta: { description: 'The unique ID of the section.' }, }) diff --git a/src/platform/plugins/shared/dashboard/server/api/scope_tooling.test.ts b/src/platform/plugins/shared/dashboard/server/api/scope_tooling.test.ts index 18c5e9592b392..b372e39adbd90 100644 --- a/src/platform/plugins/shared/dashboard/server/api/scope_tooling.test.ts +++ b/src/platform/plugins/shared/dashboard/server/api/scope_tooling.test.ts @@ -48,7 +48,7 @@ describe('stripUnmappedKeys', () => { y: 0, }, type: 'typeWithSchema', - uid: 'panel1', + id: 'panel1', }, ], pinned_panels: [ @@ -58,7 +58,7 @@ describe('stripUnmappedKeys', () => { field_name: 'field1', }, grow: false, - uid: 'pinned1', + id: 'pinned1', type: 'pinnedTypeWithSchema', width: 'small', }, @@ -68,7 +68,7 @@ describe('stripUnmappedKeys', () => { field_name: 'field2', }, grow: false, - uid: 'pinned2', + id: 'pinned2', type: 'pinnedTypeWithoutSchema', width: 'small', }, @@ -90,8 +90,8 @@ describe('stripUnmappedKeys', () => { "x": 0, "y": 0, }, + "id": "panel1", "type": "typeWithSchema", - "uid": "panel1", }, ], "pinned_panels": Array [ @@ -101,8 +101,8 @@ describe('stripUnmappedKeys', () => { "field_name": "field1", }, "grow": false, + "id": "pinned1", "type": "pinnedTypeWithSchema", - "uid": "pinned1", "width": "small", }, ], @@ -187,7 +187,7 @@ describe('stripUnmappedKeys', () => { y: 0, }, type: 'typeWithoutSchema', - uid: '12345', + id: '12345', }, ], }; @@ -234,7 +234,7 @@ describe('stripUnmappedKeys', () => { y: 0, }, type: 'typeWithSchema', - uid: '12345', + id: '12345', }, ], }; diff --git a/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_dashboard_in.test.ts b/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_dashboard_in.test.ts index 53a72b3791dc7..85472b018575d 100644 --- a/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_dashboard_in.test.ts +++ b/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_dashboard_in.test.ts @@ -25,7 +25,7 @@ describe('transformDashboardIn', () => { { config: { anyKey: 'some value' }, grow: false, - uid: 'foo', + id: 'foo', type: 'type1', width: 'small', } as unknown as PinnedControlState, @@ -48,7 +48,7 @@ describe('transformDashboardIn', () => { enhancements: {}, savedObjectId: '1', }, - uid: '1', + id: '1', title: 'title1', type: 'type1', }, diff --git a/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_panels_in.test.ts b/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_panels_in.test.ts index 886df30ef2c40..13dad5f43fcb9 100644 --- a/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_panels_in.test.ts +++ b/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_panels_in.test.ts @@ -28,7 +28,7 @@ describe('transformPanelsIn', () => { y: 0, }, type: 'DASHBOARD_MARKDOWN', - uid: '2e814ac0-33c2-4676-9d29-e1f868cddebd', + id: '2e814ac0-33c2-4676-9d29-e1f868cddebd', }, { collapsed: true, @@ -47,11 +47,11 @@ describe('transformPanelsIn', () => { y: 0, }, type: 'DASHBOARD_MARKDOWN', - uid: 'd724d87b-2256-4c8b-8aa3-55bc0b8881c6', + id: 'd724d87b-2256-4c8b-8aa3-55bc0b8881c6', }, ], title: 'Section 1', - uid: 'bcebc09a-270f-42ef-8d45-daf5f5f4f511', + id: 'bcebc09a-270f-42ef-8d45-daf5f5f4f511', }, ]; const { panelsJSON, sections } = transformPanelsIn(panels); @@ -130,7 +130,7 @@ describe('transformPanelsIn', () => { y: 0, }, type: TEST_EMBEDDABLE_TYPE, - uid: 'panel1', + id: 'panel1', }, ]; expect(() => transformPanelsIn(panels, true)).toThrowErrorMatchingInlineSnapshot( diff --git a/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_panels_in.ts b/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_panels_in.ts index 0499b77fc9271..648e3d3ab692c 100644 --- a/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_panels_in.ts +++ b/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_panels_in.ts @@ -35,8 +35,8 @@ export function transformPanelsIn( widgets.forEach((widget) => { if (isDashboardSection(widget)) { - const { panels: sectionPanels, grid, uid, ...restOfSection } = widget as DashboardSection; - const idx = uid ?? uuidv4(); + const { panels: sectionPanels, grid, id, ...restOfSection } = widget as DashboardSection; + const idx = id ?? uuidv4(); sections.push({ ...restOfSection, gridData: { ...grid, i: idx } }); sectionPanels.forEach((panel) => { try { @@ -78,8 +78,8 @@ function transformPanelIn( storedPanel: SavedDashboardPanel; references: SavedObjectReference[]; } { - const { uid, grid, config, ...restPanel } = panel; - const idx = uid ?? uuidv4(); + const { id, grid, config, ...restPanel } = panel; + const idx = id ?? uuidv4(); // Temporary escape hatch for lens as code // TODO remove when lens as code transforms are ready for production diff --git a/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_pinned_panels_in.test.ts b/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_pinned_panels_in.test.ts index 3abff9286760d..51c2afcd67e8e 100644 --- a/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_pinned_panels_in.test.ts +++ b/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_pinned_panels_in.test.ts @@ -24,7 +24,7 @@ jest.mock('../../../kibana_services', () => ({ describe('transformPinnedPanelsIn', () => { const mockPinnedPanelsState: Required['pinned_panels'] = [ { - uid: 'control1', + id: 'control1', type: 'type1', width: CONTROL_WIDTH_SMALL, config: { bizz: 'buzz' }, diff --git a/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_pinned_panels_in.ts b/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_pinned_panels_in.ts index 8d844b64aa068..1d1ebee8cab40 100644 --- a/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_pinned_panels_in.ts +++ b/src/platform/plugins/shared/dashboard/server/api/transforms/in/transform_pinned_panels_in.ts @@ -29,7 +29,7 @@ export function transformPinnedPanelsIn(pinnedPanels?: PinnedPanelsState): { let references: Reference[] = []; const updatedPinnedPanels = Object.fromEntries( pinnedPanels.map((controlState, index) => { - const { uid = uuidv4(), type } = controlState; + const { id = uuidv4(), type } = controlState; const transforms = embeddableService.getTransforms(type); let transformedControlState = { ...controlState } as Partial< @@ -41,7 +41,7 @@ export function transformPinnedPanelsIn(pinnedPanels?: PinnedPanelsState): { // prefix all the reference names with their IDs so that they are unique references = [ ...references, - ...prefixReferencesFromPanel(uid, transformed.references ?? []), + ...prefixReferencesFromPanel(id, transformed.references ?? []), ]; // update the reference names in the SO so that we can inject the references later const transformedState = transformed.state as Writable; @@ -50,7 +50,7 @@ export function transformPinnedPanelsIn(pinnedPanels?: PinnedPanelsState): { ...transformedControlState, config: { ...transformedState, - dataViewRefName: `${uid}:${transformedState.dataViewRefName}`, + dataViewRefName: `${id}:${transformedState.dataViewRefName}`, }, }; } @@ -69,7 +69,7 @@ export function transformPinnedPanelsIn(pinnedPanels?: PinnedPanelsState): { const { width, grow, config } = transformedControlState; return [ - uid, + id, { order: index, type, diff --git a/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_dashboard_out.test.ts b/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_dashboard_out.test.ts index 0e54d93a84872..e9cbf9bbd21fa 100644 --- a/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_dashboard_out.test.ts +++ b/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_dashboard_out.test.ts @@ -133,8 +133,8 @@ describe('transformDashboardOut', () => { "x": 0, "y": 0, }, + "id": "1", "type": "type1", - "uid": "1", }, ], "pinned_panels": Array [ @@ -143,8 +143,8 @@ describe('transformDashboardOut', () => { "anyKey": "some value", }, "grow": false, + "id": "foo", "type": "type1", - "uid": "foo", "width": "small", }, ], @@ -230,8 +230,8 @@ describe('transformDashboardOut', () => { "x": 0, "y": 0, }, + "id": "1", "type": "type1", - "uid": "1", }, ], "pinned_panels": Array [ @@ -240,8 +240,8 @@ describe('transformDashboardOut', () => { "anyKey": "some value", }, "grow": false, + "id": "foo", "type": "type1", - "uid": "foo", "width": "small", }, ], diff --git a/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_panels_out.test.ts b/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_panels_out.test.ts index 8e6efeb2a3140..c65dca558d95f 100644 --- a/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_panels_out.test.ts +++ b/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_panels_out.test.ts @@ -127,14 +127,15 @@ describe('transformPanelsOut', () => { "x": 0, "y": 0, }, + "id": "2e814ac0-33c2-4676-9d29-e1f868cddebd", "type": "markdown", - "uid": "2e814ac0-33c2-4676-9d29-e1f868cddebd", }, Object { "collapsed": true, "grid": Object { "y": 15, }, + "id": "bcebc09a-270f-42ef-8d45-daf5f5f4f511", "panels": Array [ Object { "config": Object { @@ -146,12 +147,11 @@ describe('transformPanelsOut', () => { "x": 0, "y": 0, }, + "id": "d724d87b-2256-4c8b-8aa3-55bc0b8881c6", "type": "markdown", - "uid": "d724d87b-2256-4c8b-8aa3-55bc0b8881c6", }, ], "title": "Section 1", - "uid": "bcebc09a-270f-42ef-8d45-daf5f5f4f511", }, ], "warnings": Array [], diff --git a/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_panels_out.ts b/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_panels_out.ts index 7fe19d3a3ed0f..8382089913e87 100644 --- a/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_panels_out.ts +++ b/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_panels_out.ts @@ -34,7 +34,7 @@ export function transformPanelsOut( collapsed: restOfSection.collapsed ?? false, grid: restOfGrid, panels: [], - uid: sectionId, + id: sectionId, }; }); @@ -111,7 +111,7 @@ function transformPanel( return { grid: restOfGrid, config: transformedPanelConfig, - uid: panelIndex, + id: panelIndex, type, }; } diff --git a/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_pinned_panels_out.test.ts b/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_pinned_panels_out.test.ts index dee84146d312e..8b609a440fe74 100644 --- a/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_pinned_panels_out.test.ts +++ b/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_pinned_panels_out.test.ts @@ -56,7 +56,7 @@ describe('pinned panels', () => { const transformedPinnedPanels = [ { - uid: 'control1', + id: 'control1', type: OPTIONS_LIST_CONTROL, width: DEFAULT_PINNED_CONTROL_STATE.width, config: { @@ -64,7 +64,7 @@ describe('pinned panels', () => { }, }, { - uid: 'control2', + id: 'control2', type: RANGE_SLIDER_CONTROL, width: 'small', config: { @@ -72,7 +72,7 @@ describe('pinned panels', () => { }, }, { - uid: 'control3', + id: 'control3', type: ESQL_CONTROL, grow: true, config: { diff --git a/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_pinned_panels_out.ts b/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_pinned_panels_out.ts index b98f59138adef..6a1d750a14104 100644 --- a/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_pinned_panels_out.ts +++ b/src/platform/plugins/shared/dashboard/server/api/transforms/out/transform_pinned_panels_out.ts @@ -106,7 +106,7 @@ export function transformPinnedPanelProperties( .sort(({ order: orderA = 0 }, { order: orderB = 0 }) => orderA - orderB) .map(({ id, type, grow, width, ...rest }) => { return { - uid: id, + id, type: transformType(type), ...(grow !== undefined && { grow }), ...(width !== undefined && { width }), @@ -130,7 +130,7 @@ function injectPinnedPanelReferences( try { transformedControls.push({ ...rest, - config: transforms.transformOut(config, [], containerReferences, control.uid), + config: transforms.transformOut(config, [], containerReferences, control.id), } as DashboardControlsState[number]); } catch (transformOutError) { // do not prevent read on transformOutError diff --git a/src/platform/plugins/shared/discover/common/embeddable/search_embeddable_transforms.test.ts b/src/platform/plugins/shared/discover/common/embeddable/search_embeddable_transforms.test.ts index d7f27005d159b..77347dd467883 100644 --- a/src/platform/plugins/shared/discover/common/embeddable/search_embeddable_transforms.test.ts +++ b/src/platform/plugins/shared/discover/common/embeddable/search_embeddable_transforms.test.ts @@ -164,6 +164,24 @@ describe('searchEmbeddableTransforms', () => { discover_session_id: 'session-xyz', }); }); + + it('transforms by-reference state', () => { + const state: StoredSearchEmbeddableState = { + title: 'Test Title', + description: 'Test Description', + }; + const result = getSearchEmbeddableTransforms( + mockDrilldownTransforms, + whenDisabled + ).transformOut?.(state, [ + { + id: '2f360f30-ea74-11eb-b4c6-3d2afc1cb389', + name: 'savedObjectRef', + type: 'search', + }, + ]); + expect(result).toEqual({ ...state, savedObjectId: '2f360f30-ea74-11eb-b4c6-3d2afc1cb389' }); + }); }); describe('transformIn', () => { diff --git a/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/converters/from_attachment.ts b/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/converters/from_attachment.ts index d5eee7ace814e..b992c52a86063 100644 --- a/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/converters/from_attachment.ts +++ b/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/converters/from_attachment.ts @@ -26,7 +26,7 @@ const LENS_EMBEDDABLE_TYPE = 'lens'; * Converts an AttachmentPanel to a DashboardPanel. * For Lens panels with API format attributes, converts to internal format. */ -const buildPanelFromConfig = ({ config, type, uid, grid }: AttachmentPanel): DashboardPanel => { +const buildPanelFromConfig = ({ config, type, id, grid }: AttachmentPanel): DashboardPanel => { let configObject = config; if (type === LENS_EMBEDDABLE_TYPE && config.attributes && isLensAPIFormat(config.attributes)) { const lensAttributes = new LensConfigBuilder().fromAPIFormat(config.attributes); @@ -37,7 +37,7 @@ const buildPanelFromConfig = ({ config, type, uid, grid }: AttachmentPanel): Das } return { type, - uid, + id, grid, config: configObject, }; @@ -50,7 +50,7 @@ type DashboardWidget = DashboardPanel | DashboardSection; * Converts an AgentDashboardSection to a DashboardSection. */ const normalizeSection = (section: AgentDashboardSection): DashboardSection => ({ - uid: section.uid, + id: section.id, title: section.title, collapsed: section.collapsed, grid: { y: section.grid.y }, diff --git a/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/converters/normalize_panel.ts b/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/converters/normalize_panel.ts index 1ab88f45e085f..1e2e5f8139392 100644 --- a/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/converters/normalize_panel.ts +++ b/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/converters/normalize_panel.ts @@ -15,22 +15,22 @@ export interface VisualizationContent { config: Record; } -/** Panel input that may or may not have a uid assigned yet */ -export type DashboardPanelInput = Omit & { uid?: string }; +/** Panel input that may or may not have a id assigned yet */ +export type DashboardPanelInput = Omit & { id?: string }; /** * Converts panel input to a full AttachmentPanel (embeddable format). - * - Generates a uid if not provided + * - Generates a id if not provided * - Wraps Lens config in `attributes` if needed */ export const toEmbeddablePanel = ({ - uid, + id, grid, type, config, }: DashboardPanelInput): AttachmentPanel => { return { - uid: uid ?? uuidv4(), + id: id ?? uuidv4(), grid, type, config: diff --git a/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/converters/to_attachment.ts b/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/converters/to_attachment.ts index 0e589bd27d2a1..6aec7f3e57f2b 100644 --- a/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/converters/to_attachment.ts +++ b/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/converters/to_attachment.ts @@ -48,7 +48,7 @@ export const toAttachmentPanel = (panel: DashboardPanel): AttachmentPanel | unde return { type: 'lens', - uid: panel.uid ?? '', + id: panel.id ?? '', config: { ...panelConfig, attributes: apiFormatAttributes, @@ -63,7 +63,7 @@ export const toAttachmentPanel = (panel: DashboardPanel): AttachmentPanel | unde return { type: panel.type, - uid: panel.uid ?? '', + id: panel.id ?? '', config: (panel.config as Record | undefined) ?? {}, grid: panel.grid, }; @@ -73,7 +73,7 @@ export const toAttachmentPanel = (panel: DashboardPanel): AttachmentPanel | unde * Converts a DashboardSection to a DashboardAttachmentSection. */ export const toAttachmentSection = (section: DashboardSection): DashboardAttachmentSection => ({ - uid: section.uid ?? '', + id: section.id ?? '', title: section.title, collapsed: section.collapsed ?? false, grid: { y: section.grid.y }, diff --git a/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/dashboard_schema_types.ts b/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/dashboard_schema_types.ts index 00eed3b6008cd..fd01885565ddf 100644 --- a/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/dashboard_schema_types.ts +++ b/x-pack/platform/packages/shared/dashboard-agent/dashboard-agent-common/dashboard_schema_types.ts @@ -33,7 +33,7 @@ export const panelGridSchema = z.object({ */ const attachmentPanelSchema = z.object({ type: z.string(), - uid: z.string(), + id: z.string(), config: z.record(z.string(), z.unknown()), grid: panelGridSchema, }); @@ -49,7 +49,7 @@ export const sectionGridSchema = z.object({ }); const dashboardSectionSchema = z.object({ - uid: z.string(), + id: z.string(), title: z.string(), collapsed: z.boolean(), grid: sectionGridSchema, diff --git a/x-pack/platform/plugins/shared/dashboard_agent/server/attachment_types/dashboard.test.ts b/x-pack/platform/plugins/shared/dashboard_agent/server/attachment_types/dashboard.test.ts index ce0f0f0e0ba3b..49917b9758190 100644 --- a/x-pack/platform/plugins/shared/dashboard_agent/server/attachment_types/dashboard.test.ts +++ b/x-pack/platform/plugins/shared/dashboard_agent/server/attachment_types/dashboard.test.ts @@ -25,7 +25,7 @@ const dashboardAttachmentData: DashboardAttachmentData = { panels: [ { type: 'lens', - uid: 'panel-1', + id: 'panel-1', grid: { x: 0, y: 0, w: 24, h: 15 }, config: { attributes: { diff --git a/x-pack/platform/plugins/shared/dashboard_agent/server/skills/dashboard_management_skill.ts b/x-pack/platform/plugins/shared/dashboard_agent/server/skills/dashboard_management_skill.ts index ac28402f67c48..62f70ad3b6639 100644 --- a/x-pack/platform/plugins/shared/dashboard_agent/server/skills/dashboard_management_skill.ts +++ b/x-pack/platform/plugins/shared/dashboard_agent/server/skills/dashboard_management_skill.ts @@ -57,7 +57,7 @@ For a new dashboard: For an existing dashboard: - Reuse \`data.dashboardAttachment.id\` from the latest dashboard tool result as \`dashboardAttachmentId\`. -- Use \`remove_panels\` to remove existing panels by \`uid\`. +- Use \`remove_panels\` to remove existing panels by \`id\`. - Use \`create_visualization_panels\` to add new Lens visualization panels inline. - Use \`edit_visualization_panels\` only to change existing ES|QL-backed Lens visualization panels in place by \`panelId\`. - If a requested change targets a DSL, form-based, or other non-ES|QL panel, explicitly tell the user direct editing is not supported and ask for confirmation before replacing that panel with a newly created ES|QL-based Lens panel. @@ -75,13 +75,13 @@ Supported operations: - \`edit_visualization_panels\`: update existing ES|QL-backed Lens visualization panels by \`panelId\`, preserving their current placement. - \`update_panel_layouts\`: resize, reposition, or move existing panels by \`panelId\` by updating \`grid\` and optionally changing \`sectionId\`. - \`add_section\`: create a new section with its own \`grid.y\`, and optionally create that section's initial inline Lens visualization panels with \`panels\`. Those nested panel grids are section-relative and do not need a \`sectionId\`. -- \`remove_section\`: remove a section by \`uid\` with \`panelAction: "promote" | "delete"\`. -- \`remove_panels\`: remove existing panels by \`uid\`. +- \`remove_section\`: remove a section by \`id\` with \`panelAction: "promote" | "delete"\`. +- \`remove_panels\`: remove existing panels by \`id\`. After a successful call: - Render the dashboard attachment inline so the user can see and interact with the dashboard card. Do NOT render individual visualization attachments inline during dashboard composition - only the final dashboard attachment should be rendered. - Remember \`data.dashboardAttachment.id\` for follow-up updates. -- Use returned \`uid\` values for future panel removals. +- Use returned \`id\` values for future panel removals. - Use returned \`sectionId\` values for future section-targeted changes. - If \`data.failures\` is present, explain which attachments failed and why. @@ -92,7 +92,7 @@ After a successful call: - \`create_visualization_panels\` and \`edit_visualization_panels\` work directly on dashboard panels and do not create standalone visualization attachments. - A successful dashboard call returns a dashboard attachment in \`data.dashboardAttachment\`. - Use \`data.dashboardAttachment.id\` as \`dashboardAttachmentId\` when updating that dashboard later. -- Never invent \`dashboardAttachmentId\`, \`uid\`, or \`sectionId\`. Reuse the values returned by prior tool results. +- Never invent \`dashboardAttachmentId\`, \`id\`, or \`sectionId\`. Reuse the values returned by prior tool results. ${dashboardCompositionPrompt} diff --git a/x-pack/platform/plugins/shared/dashboard_agent/server/sml_types/dashboard.test.ts b/x-pack/platform/plugins/shared/dashboard_agent/server/sml_types/dashboard.test.ts index 9e08fa5b22808..0a007120f2bcd 100644 --- a/x-pack/platform/plugins/shared/dashboard_agent/server/sml_types/dashboard.test.ts +++ b/x-pack/platform/plugins/shared/dashboard_agent/server/sml_types/dashboard.test.ts @@ -20,7 +20,7 @@ const dashboardAttachmentData: DashboardAttachmentData = { panels: [ { type: 'lens', - uid: 'panel-1', + id: 'panel-1', grid: { x: 0, y: 0, w: 24, h: 15 }, config: { attributes: { @@ -37,14 +37,14 @@ const dashboardAttachmentData: DashboardAttachmentData = { }, }, { - uid: 'section-1', + id: 'section-1', title: 'Operations', collapsed: false, grid: { y: 20 }, panels: [ { type: 'markdown', - uid: 'panel-2', + id: 'panel-2', grid: { x: 24, y: 0, w: 24, h: 10 }, config: { title: 'Summary', @@ -62,7 +62,7 @@ const dashboardStateWithLensApi = { panels: [ { type: 'lens', - uid: 'panel-3', + id: 'panel-3', grid: { x: 0, y: 0, w: 24, h: 12 }, config: { attributes: { @@ -233,13 +233,13 @@ describe('dashboardSmlType', () => { expect(attachmentData?.panels).toEqual( expect.arrayContaining([ expect.objectContaining({ - uid: 'panel-1', + id: 'panel-1', type: 'lens', }), expect.objectContaining({ - uid: 'section-1', + id: 'section-1', title: 'Operations', - panels: [expect.objectContaining({ uid: 'panel-2', type: 'markdown' })], + panels: [expect.objectContaining({ id: 'panel-2', type: 'markdown' })], }), ]) ); @@ -292,7 +292,7 @@ describe('dashboardSmlType', () => { expect(attachmentData?.panels).toEqual([ expect.objectContaining({ - uid: 'panel-3', + id: 'panel-3', type: 'lens', config: expect.objectContaining({ attributes: expect.objectContaining({ diff --git a/x-pack/platform/plugins/shared/dashboard_agent/server/sml_types/dashboard.ts b/x-pack/platform/plugins/shared/dashboard_agent/server/sml_types/dashboard.ts index 9304d1f3f7d69..62b65d4d61bc5 100644 --- a/x-pack/platform/plugins/shared/dashboard_agent/server/sml_types/dashboard.ts +++ b/x-pack/platform/plugins/shared/dashboard_agent/server/sml_types/dashboard.ts @@ -29,7 +29,7 @@ const toPanelSummary = (panel: DashboardPanel): string[] => { (panel.config as { title?: string } | undefined)?.title ?? (panel.config as { attributes?: { title?: string } } | undefined)?.attributes?.title; - return [title, panel.type, panel.uid ? `panel:${panel.uid}` : undefined].filter( + return [title, panel.type, panel.id ? `panel:${panel.id}` : undefined].filter( (value): value is string => Boolean(value) ); }; @@ -47,7 +47,7 @@ const toDashboardSearchContent = (state: DashboardState): string => { } for (const section of sections) { - contentParts.push(section.title, `section:${section.uid}`); + contentParts.push(section.title, `section:${section.id}`); for (const panel of section.panels) { contentParts.push(...toPanelSummary(panel)); } diff --git a/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/dashboard_state.ts b/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/dashboard_state.ts index 43ac162fd86fe..d79e93733528f 100644 --- a/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/dashboard_state.ts +++ b/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/dashboard_state.ts @@ -20,14 +20,14 @@ export const findPanelById = ( ): AttachmentPanel | undefined => { for (const widget of widgets) { if (isSection(widget)) { - const sectionPanel = widget.panels.find((panel) => panel.uid === panelId); + const sectionPanel = widget.panels.find((panel) => panel.id === panelId); if (sectionPanel) { return sectionPanel; } continue; } - if (widget.uid === panelId) { + if (widget.id === panelId) { return widget; } } @@ -53,7 +53,7 @@ export const getWidgetsBottomY = (widgets: DashboardWidget[]): number => { }; export const findSectionIndex = (panels: DashboardWidget[], sectionId: string): number => { - return panels.findIndex((widget) => isSection(widget) && widget.uid === sectionId); + return panels.findIndex((widget) => isSection(widget) && widget.id === sectionId); }; export const appendPanelsToDashboard = ({ @@ -84,7 +84,7 @@ export const appendPanelsToDashboard = ({ return { ...dashboardData, panels: dashboardData.panels.map((widget) => { - if (!isSection(widget) || widget.uid !== sectionId) { + if (!isSection(widget) || widget.id !== sectionId) { return widget; } @@ -115,7 +115,7 @@ export const updatePanelInDashboard = ({ if (isSection(widget)) { let sectionUpdated = false; const nextSectionPanels = widget.panels.map((panel) => { - if (panel.uid !== panelId) { + if (panel.id !== panelId) { return panel; } @@ -127,7 +127,7 @@ export const updatePanelInDashboard = ({ return sectionUpdated ? { ...widget, panels: nextSectionPanels } : widget; } - if (widget.uid !== panelId) { + if (widget.id !== panelId) { return widget; } @@ -159,7 +159,7 @@ export const removePanelsFromDashboard = ({ if (isSection(widget)) { const sectionPanelsToKeep: AttachmentPanel[] = []; for (const panel of widget.panels) { - if (panelIdsToRemoveSet.has(panel.uid)) { + if (panelIdsToRemoveSet.has(panel.id)) { removedPanels.push(panel); } else { sectionPanelsToKeep.push(panel); @@ -169,7 +169,7 @@ export const removePanelsFromDashboard = ({ continue; } - if (panelIdsToRemoveSet.has(widget.uid)) { + if (panelIdsToRemoveSet.has(widget.id)) { removedPanels.push(widget); } else { nextPanels.push(widget); diff --git a/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/inline_visualization.test.ts b/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/inline_visualization.test.ts index 6c25e81e0f056..19209df303139 100644 --- a/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/inline_visualization.test.ts +++ b/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/inline_visualization.test.ts @@ -93,7 +93,7 @@ describe('createVisualizationResolver', () => { identifier: 'panel-1', nlQuery: 'turn this into a line chart', existingPanel: { - uid: 'panel-1', + id: 'panel-1', type: 'lens', config: { attributes: { type: 'bar' } }, grid: { w: 24, h: 12, x: 0, y: 0 }, @@ -121,7 +121,7 @@ describe('createVisualizationResolver', () => { identifier: 'panel-1', nlQuery: 'refine this analysis', existingPanel: { - uid: 'panel-1', + id: 'panel-1', type: 'aiOpsLogRateAnalysis', config: { seriesType: 'log_rate' }, grid: { w: 24, h: 12, x: 0, y: 0 }, diff --git a/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/manage_dashboard.ts b/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/manage_dashboard.ts index eb815aaa4205f..93f449e15f88d 100644 --- a/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/manage_dashboard.ts +++ b/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/manage_dashboard.ts @@ -144,20 +144,20 @@ Use operations[] to: panels: updatedDashboardData.panels.map((widget) => { if (isSection(widget)) { return { - uid: widget.uid, + id: widget.id, title: widget.title, collapsed: widget.collapsed, grid: widget.grid, panels: widget.panels.map((panel) => ({ type: panel.type, - uid: panel.uid, + id: panel.id, grid: panel.grid, })), }; } return { type: widget.type, - uid: widget.uid, + id: widget.id, grid: widget.grid, }; }), diff --git a/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/operations.test.ts b/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/operations.test.ts index 0c61fdf62bec5..f52331fd2ead9 100644 --- a/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/operations.test.ts +++ b/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/operations.test.ts @@ -44,20 +44,20 @@ const getPanelsOnly = (panels: DashboardAttachmentData['panels']): AttachmentPan describe('executeDashboardOperations', () => { const logger = createMockLogger(); - const createLensPanel = (uid: string, gridY = 0): AttachmentPanel => ({ + const createLensPanel = (id: string, gridY = 0): AttachmentPanel => ({ type: 'lens', - uid, + id, config: { type: 'metric' }, grid: { x: 0, y: gridY, w: 24, h: 9 }, }); const createSection = ( - uid: string, + id: string, title: string, gridY: number, panels: AttachmentPanel[] = [] ): DashboardSection => ({ - uid, + id, title, collapsed: false, grid: { y: gridY }, @@ -116,7 +116,7 @@ describe('executeDashboardOperations', () => { expect(result.dashboardData.title).toBe('Updated title'); expect(result.dashboardData.panels).toEqual([ expect.objectContaining({ - uid: 'from-attachment-panel', + id: 'from-attachment-panel', grid: { x: 0, y: 0, w: 24, h: 9 }, }), expect.objectContaining({ @@ -166,7 +166,7 @@ describe('executeDashboardOperations', () => { }); expect(result.dashboardData.panels).toEqual([ - expect.objectContaining({ uid: 'from-attachment' }), + expect.objectContaining({ id: 'from-attachment' }), ]); expect(result.failures).toEqual([ expect.objectContaining({ @@ -207,7 +207,7 @@ describe('executeDashboardOperations', () => { const sections = getSections(result.dashboardData.panels); expect(sections).toEqual([ { - uid: 'section-1', + id: 'section-1', title: 'Section 1', collapsed: false, grid: { y: 10 }, @@ -241,7 +241,7 @@ describe('executeDashboardOperations', () => { const sections = getSections(result.dashboardData.panels); expect(sections).toHaveLength(1); expect(sections[0]).toEqual({ - uid: expect.any(String), + id: expect.any(String), title: 'Overview', collapsed: false, grid: { y: 12 }, @@ -293,7 +293,7 @@ describe('executeDashboardOperations', () => { expect(panelsOnly).toEqual([]); expect(sections).toHaveLength(1); expect(sections[0]).toEqual({ - uid: expect.any(String), + id: expect.any(String), title: 'Overview', collapsed: false, grid: { y: 12 }, @@ -632,7 +632,7 @@ describe('executeDashboardOperations', () => { expect(panelsOnly).toEqual([]); expect(sections[0].panels).toEqual([ expect.objectContaining({ - uid: 'section-routed-panel', + id: 'section-routed-panel', grid: { x: 12, y: 0, w: 12, h: 5 }, }), ]); @@ -651,16 +651,16 @@ describe('executeDashboardOperations', () => { ]), ], }, - operations: [{ operation: 'remove_section', uid: 'section-a', panelAction: 'promote' }], + operations: [{ operation: 'remove_section', id: 'section-a', panelAction: 'promote' }], logger, resolvePanelsFromAttachments: () => ({ panels: [], failures: [] }), }); const sections = getSections(result.dashboardData.panels); expect(sections).toHaveLength(0); expect(result.dashboardData.panels).toEqual([ - expect.objectContaining({ uid: 'top-1', grid: { x: 0, y: 0, w: 24, h: 9 } }), - expect.objectContaining({ uid: 'section-a-1', grid: { x: 0, y: 9, w: 24, h: 9 } }), - expect.objectContaining({ uid: 'section-a-2', grid: { x: 0, y: 18, w: 24, h: 9 } }), + expect.objectContaining({ id: 'top-1', grid: { x: 0, y: 0, w: 24, h: 9 } }), + expect.objectContaining({ id: 'section-a-1', grid: { x: 0, y: 9, w: 24, h: 9 } }), + expect.objectContaining({ id: 'section-a-2', grid: { x: 0, y: 18, w: 24, h: 9 } }), ]); }); @@ -674,14 +674,14 @@ describe('executeDashboardOperations', () => { createSection('section-a', 'Section A', 10, [createLensPanel('section-a-1', 0)]), ], }, - operations: [{ operation: 'remove_section', uid: 'section-a', panelAction: 'delete' }], + operations: [{ operation: 'remove_section', id: 'section-a', panelAction: 'delete' }], logger, resolvePanelsFromAttachments: () => ({ panels: [], failures: [] }), }); const sections = getSections(result.dashboardData.panels); expect(sections).toHaveLength(0); - expect(result.dashboardData.panels).toEqual([expect.objectContaining({ uid: 'top-1' })]); + expect(result.dashboardData.panels).toEqual([expect.objectContaining({ id: 'top-1' })]); }); it('removes matching panelIds from top-level and section panels', async () => { @@ -707,11 +707,11 @@ describe('executeDashboardOperations', () => { expect(panelsOnly).toEqual([]); expect(sections).toEqual([ { - uid: 'section-a', + id: 'section-a', title: 'Section A', collapsed: false, grid: { y: 8 }, - panels: [expect.objectContaining({ uid: 'section-a-2' })], + panels: [expect.objectContaining({ id: 'section-a-2' })], }, ]); }); @@ -775,7 +775,7 @@ describe('executeDashboardOperations', () => { const sections = getSections(result.dashboardData.panels); expect(sections[0].panels).toEqual([ expect.objectContaining({ - uid: 'section-panel-1', + id: 'section-panel-1', grid: { x: 12, y: 4, w: 12, h: 6 }, config: { type: 'metric' }, }), @@ -811,7 +811,7 @@ describe('executeDashboardOperations', () => { expect(panelsOnly).toEqual([]); expect(sections[0].panels).toEqual([ expect.objectContaining({ - uid: 'top-1', + id: 'top-1', grid: { x: 24, y: 0, w: 24, h: 9 }, config: { type: 'metric' }, }), @@ -849,7 +849,7 @@ describe('executeDashboardOperations', () => { expect(sections[0].panels).toEqual([]); expect(panelsOnly).toEqual([ expect.objectContaining({ - uid: 'section-panel-1', + id: 'section-panel-1', grid: { x: 0, y: 20, w: 24, h: 9 }, config: { type: 'metric' }, }), @@ -940,7 +940,7 @@ describe('executeDashboardOperations', () => { ]); }); - it('edits inline visualization panels while preserving uid and grid', async () => { + it('edits inline visualization panels while preserving id and grid', async () => { const result = await executeDashboardOperations({ dashboardData: { title: 'Test', @@ -975,14 +975,14 @@ describe('executeDashboardOperations', () => { expect(topLevelPanels[0]).toEqual( expect.objectContaining({ - uid: 'panel-1', + id: 'panel-1', grid: { x: 0, y: 5, w: 24, h: 9 }, config: { attributes: { type: 'bar' } }, }) ); expect(sections[0].panels[0]).toEqual( expect.objectContaining({ - uid: 'section-panel-1', + id: 'section-panel-1', grid: { x: 0, y: 0, w: 24, h: 9 }, config: { attributes: { type: 'line' } }, }) @@ -1038,7 +1038,7 @@ describe('executeDashboardOperations', () => { expect(seenConfigSteps).toEqual(['initial', 'after-first-edit']); expect(getPanelsOnly(result.dashboardData.panels)[0]).toEqual( expect.objectContaining({ - uid: 'panel-1', + id: 'panel-1', config: { attributes: { type: 'metric', testStep: 'after-second-edit' } }, grid: { x: 0, y: 5, w: 24, h: 9 }, }) @@ -1138,7 +1138,7 @@ describe('executeDashboardOperations', () => { panels: [ { type: 'aiOpsLogRateAnalysis', - uid: 'panel-1', + id: 'panel-1', config: { seriesType: 'log_rate' }, grid: { x: 0, y: 5, w: 24, h: 9 }, }, @@ -1167,7 +1167,7 @@ describe('executeDashboardOperations', () => { expect(getPanelsOnly(result.dashboardData.panels)).toEqual([ expect.objectContaining({ - uid: 'panel-1', + id: 'panel-1', type: 'aiOpsLogRateAnalysis', config: { seriesType: 'log_rate' }, grid: { x: 0, y: 5, w: 24, h: 9 }, diff --git a/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/operations.ts b/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/operations.ts index 0a54b3d1e841b..5f4fefb2cd188 100644 --- a/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/operations.ts +++ b/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/operations.ts @@ -45,7 +45,7 @@ export const addMarkdownOperationSchema = z.object({ .string() .optional() .describe( - 'UID of an existing section to add this panel into. The section must already exist (use add_section first). If omitted, panel is added at the top level.' + 'ID of an existing section to add this panel into. The section must already exist (use add_section first). If omitted, panel is added at the top level.' ), }); @@ -65,7 +65,7 @@ export const addPanelsFromAttachmentsOperationSchema = z.object({ .string() .optional() .describe( - 'UID of an existing section to add this panel into. The section must already exist (use add_section first). If omitted, panel is added at the top level.' + 'ID of an existing section to add this panel into. The section must already exist (use add_section first). If omitted, panel is added at the top level.' ), }) ) @@ -113,7 +113,7 @@ export const addSectionOperationSchema = z.object({ export const removeSectionOperationSchema = z.object({ operation: z.literal('remove_section'), - uid: z.string().describe('Section uid to remove.'), + id: z.string().describe('Section id to remove.'), panelAction: z .enum(['promote', 'delete']) .describe('How to handle section panels: promote to top-level or delete them.'), @@ -129,7 +129,7 @@ const createVisualizationPanelSchema = visualizationPanelInputSchema.extend({ .string() .optional() .describe( - 'UID of an existing section to add this panel into. The section must already exist (use add_section first). If omitted, panel is added at the top level.' + 'ID of an existing section to add this panel into. The section must already exist (use add_section first). If omitted, panel is added at the top level.' ), }); @@ -139,7 +139,7 @@ export const createVisualizationPanelsOperationSchema = z.object({ }); const editVisualizationPanelSchema = z.object({ - panelId: z.string().describe('Existing panel uid to update.'), + panelId: z.string().describe('Existing panel id to update.'), query: z .string() .describe('A natural language query describing how to update the visualization.'), @@ -171,7 +171,7 @@ export const updatePanelLayoutsOperationSchema = z.object({ panels: z .array( z.object({ - panelId: z.string().describe('UID of the panel to update.'), + panelId: z.string().describe('ID of the panel to update.'), grid: panelGridSchema .optional() .describe('New grid position/size. Omit to keep the current grid.'), @@ -180,7 +180,7 @@ export const updatePanelLayoutsOperationSchema = z.object({ .nullable() .optional() .describe( - 'Move panel to an existing section by its uid. The section must already exist (use add_section first). null promotes to top level. Omit to keep the current location.' + 'Move panel to an existing section by its id. The section must already exist (use add_section first). null promotes to top level. Omit to keep the current location.' ), }) ) @@ -591,7 +591,7 @@ export const executeDashboardOperations = async ({ case 'add_section': { let nextSection: DashboardSection = { - uid: uuidv4(), + id: uuidv4(), title: operation.title, collapsed: false, grid: operation.grid, @@ -622,9 +622,9 @@ export const executeDashboardOperations = async ({ } case 'remove_section': { - const sectionIndex = findSectionIndex(nextDashboardData.panels, operation.uid); + const sectionIndex = findSectionIndex(nextDashboardData.panels, operation.id); if (sectionIndex === -1) { - throw new Error(`Section "${operation.uid}" not found.`); + throw new Error(`Section "${operation.id}" not found.`); } const sectionToRemove = nextDashboardData.panels[sectionIndex] as DashboardSection; diff --git a/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/utils.ts b/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/utils.ts index 28c1cf119d0dd..2a165024f6f15 100644 --- a/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/utils.ts +++ b/x-pack/platform/plugins/shared/dashboard_agent/server/tools/manage_dashboard/utils.ts @@ -132,7 +132,7 @@ export const getRemovedPanels = ( const panelsToKeep: AttachmentPanel[] = []; for (const panel of panels) { - if (removeSet.has(panel.uid)) { + if (removeSet.has(panel.id)) { panelsToRemove.push(panel); } else { panelsToKeep.push(panel); diff --git a/x-pack/solutions/observability/plugins/observability/server/services/referenced_panel_manager.ts b/x-pack/solutions/observability/plugins/observability/server/services/referenced_panel_manager.ts index 1826fd2222995..ea43eefd574a8 100644 --- a/x-pack/solutions/observability/plugins/observability/server/services/referenced_panel_manager.ts +++ b/x-pack/solutions/observability/plugins/observability/server/services/referenced_panel_manager.ts @@ -56,7 +56,7 @@ export class ReferencedPanelManager { references: Reference[]; panel: DashboardPanel; }) { - const { uid, type } = panel; + const { id: uid, type } = panel; if (!uid) return; const panelReference = references.find((r) => r.name.includes(uid) && r.type === type); diff --git a/x-pack/solutions/observability/plugins/observability/server/services/related_dashboards_client.test.ts b/x-pack/solutions/observability/plugins/observability/server/services/related_dashboards_client.test.ts index 1b02efc835c03..e03cb6b15d754 100644 --- a/x-pack/solutions/observability/plugins/observability/server/services/related_dashboards_client.test.ts +++ b/x-pack/solutions/observability/plugins/observability/server/services/related_dashboards_client.test.ts @@ -321,7 +321,7 @@ describe('RelatedDashboardsClient', () => { { id: 'dashboard1', title: 'Dashboard 1', - panels: [{ config: {}, uid: PANEL_UID, type: PANEL_TYPE }], + panels: [{ config: {}, id: PANEL_UID, type: PANEL_TYPE }], references: [{ name: PANEL_UID, type: PANEL_TYPE, id: PANEL_SO_ID }], }, ], @@ -356,8 +356,8 @@ describe('RelatedDashboardsClient', () => { id: 'dashboard1', title: 'Dashboard 1', panels: [ - { config: {}, uid: PANEL_UID, type: PANEL_TYPE }, - { config: {}, uid: OTHER_PANEL_UID, type: PANEL_TYPE }, + { config: {}, id: PANEL_UID, type: PANEL_TYPE }, + { config: {}, id: OTHER_PANEL_UID, type: PANEL_TYPE }, ], references: [ { name: PANEL_UID, type: PANEL_TYPE, id: PANEL_SO_ID }, @@ -451,7 +451,7 @@ describe('RelatedDashboardsClient', () => { panels: [ { type: 'lens', - uid: PANEL_UID, + id: PANEL_UID, config: {}, }, ], @@ -504,7 +504,7 @@ describe('RelatedDashboardsClient', () => { panels: [ { type: 'lens', - uid: PANEL_UID, + id: PANEL_UID, config: {}, }, ], diff --git a/x-pack/solutions/observability/plugins/observability/server/services/related_dashboards_client.ts b/x-pack/solutions/observability/plugins/observability/server/services/related_dashboards_client.ts index a7c67637fd123..345af5cdf9306 100644 --- a/x-pack/solutions/observability/plugins/observability/server/services/related_dashboards_client.ts +++ b/x-pack/solutions/observability/plugins/observability/server/services/related_dashboards_client.ts @@ -79,8 +79,8 @@ export class RelatedDashboardsClient { let references = this.isLensVizAttributes(panel.type, panel.config) ? panel.config.attributes.references : undefined; - if (!references && panel.uid) { - references = this.referencedPanelManager.getByUid(panel.uid)?.references; + if (!references && panel.id) { + references = this.referencedPanelManager.getByUid(panel.id)?.references; } if (references?.length) { return new Set( @@ -98,8 +98,8 @@ export class RelatedDashboardsClient { let state: unknown = this.isLensVizAttributes(panel.type, panel.config) ? panel.config.attributes.state : undefined; - if (!state && panel.uid) { - state = this.referencedPanelManager.getByUid(panel.uid)?.state; + if (!state && panel.id) { + state = this.referencedPanelManager.getByUid(panel.id)?.state; } if (this.isLensAttributesState(state)) { const fields = new Set();