From 3dff92f00a2ba9768408d103677a973ef48a4088 Mon Sep 17 00:00:00 2001 From: Nick Peihl Date: Wed, 13 Nov 2024 11:55:07 -0500 Subject: [PATCH] Revert "Do not generate random values from CM schema" This reverts commit 0f3bde4814f7e926f254a587db1aec0bfab34447. --- oas_docs/bundle.json | 60 +++++++++++++++++-- oas_docs/bundle.serverless.json | 60 +++++++++++++++++-- .../content_management/v3/cm_services.ts | 28 ++++----- 3 files changed, 123 insertions(+), 25 deletions(-) diff --git a/oas_docs/bundle.json b/oas_docs/bundle.json index 49068a590f14d..4c37c5c467010 100644 --- a/oas_docs/bundle.json +++ b/oas_docs/bundle.json @@ -5915,11 +5915,12 @@ "type": "object" }, "grow": { - "default": false, + "default": true, "description": "Expand width of the control panel to fit available space.", "type": "boolean" }, "id": { + "default": "32b28ffe-4df3-4257-a976-71ff7ba811b2", "description": "The unique ID of the control.", "type": "string" }, @@ -6228,6 +6229,7 @@ "type": "number" }, "i": { + "default": "199505bf-cee4-4ba4-bf12-8dfff6d57d2e", "description": "The unique identifier of the panel", "type": "string" }, @@ -6288,6 +6290,14 @@ "type": "object" }, "panelIndex": { + "default": { + "ref": { + "path": [ + "gridData", + "i" + ] + } + }, "description": "The unique ID of the panel.", "type": "string" }, @@ -6579,11 +6589,12 @@ "type": "object" }, "grow": { - "default": false, + "default": true, "description": "Expand width of the control panel to fit available space.", "type": "boolean" }, "id": { + "default": "32b28ffe-4df3-4257-a976-71ff7ba811b2", "description": "The unique ID of the control.", "type": "string" }, @@ -6892,6 +6903,7 @@ "type": "number" }, "i": { + "default": "199505bf-cee4-4ba4-bf12-8dfff6d57d2e", "description": "The unique identifier of the panel", "type": "string" }, @@ -6952,6 +6964,14 @@ "type": "object" }, "panelIndex": { + "default": { + "ref": { + "path": [ + "gridData", + "i" + ] + } + }, "description": "The unique ID of the panel.", "type": "string" }, @@ -7117,11 +7137,12 @@ "type": "object" }, "grow": { - "default": false, + "default": true, "description": "Expand width of the control panel to fit available space.", "type": "boolean" }, "id": { + "default": "32b28ffe-4df3-4257-a976-71ff7ba811b2", "description": "The unique ID of the control.", "type": "string" }, @@ -7430,6 +7451,7 @@ "type": "number" }, "i": { + "default": "199505bf-cee4-4ba4-bf12-8dfff6d57d2e", "description": "The unique identifier of the panel", "type": "string" }, @@ -7490,6 +7512,14 @@ "type": "object" }, "panelIndex": { + "default": { + "ref": { + "path": [ + "gridData", + "i" + ] + } + }, "description": "The unique ID of the panel.", "type": "string" }, @@ -7753,11 +7783,12 @@ "type": "object" }, "grow": { - "default": false, + "default": true, "description": "Expand width of the control panel to fit available space.", "type": "boolean" }, "id": { + "default": "32b28ffe-4df3-4257-a976-71ff7ba811b2", "description": "The unique ID of the control.", "type": "string" }, @@ -8066,6 +8097,7 @@ "type": "number" }, "i": { + "default": "199505bf-cee4-4ba4-bf12-8dfff6d57d2e", "description": "The unique identifier of the panel", "type": "string" }, @@ -8126,6 +8158,14 @@ "type": "object" }, "panelIndex": { + "default": { + "ref": { + "path": [ + "gridData", + "i" + ] + } + }, "description": "The unique ID of the panel.", "type": "string" }, @@ -8285,11 +8325,12 @@ "type": "object" }, "grow": { - "default": false, + "default": true, "description": "Expand width of the control panel to fit available space.", "type": "boolean" }, "id": { + "default": "32b28ffe-4df3-4257-a976-71ff7ba811b2", "description": "The unique ID of the control.", "type": "string" }, @@ -8598,6 +8639,7 @@ "type": "number" }, "i": { + "default": "199505bf-cee4-4ba4-bf12-8dfff6d57d2e", "description": "The unique identifier of the panel", "type": "string" }, @@ -8658,6 +8700,14 @@ "type": "object" }, "panelIndex": { + "default": { + "ref": { + "path": [ + "gridData", + "i" + ] + } + }, "description": "The unique ID of the panel.", "type": "string" }, diff --git a/oas_docs/bundle.serverless.json b/oas_docs/bundle.serverless.json index 51bd143ddb5c9..01e92675f82e8 100644 --- a/oas_docs/bundle.serverless.json +++ b/oas_docs/bundle.serverless.json @@ -5915,11 +5915,12 @@ "type": "object" }, "grow": { - "default": false, + "default": true, "description": "Expand width of the control panel to fit available space.", "type": "boolean" }, "id": { + "default": "edc483da-2dcf-4469-8d36-c99ca8f699a7", "description": "The unique ID of the control.", "type": "string" }, @@ -6228,6 +6229,7 @@ "type": "number" }, "i": { + "default": "49de787f-528f-47bd-a3f5-616351ccbc43", "description": "The unique identifier of the panel", "type": "string" }, @@ -6288,6 +6290,14 @@ "type": "object" }, "panelIndex": { + "default": { + "ref": { + "path": [ + "gridData", + "i" + ] + } + }, "description": "The unique ID of the panel.", "type": "string" }, @@ -6579,11 +6589,12 @@ "type": "object" }, "grow": { - "default": false, + "default": true, "description": "Expand width of the control panel to fit available space.", "type": "boolean" }, "id": { + "default": "edc483da-2dcf-4469-8d36-c99ca8f699a7", "description": "The unique ID of the control.", "type": "string" }, @@ -6892,6 +6903,7 @@ "type": "number" }, "i": { + "default": "49de787f-528f-47bd-a3f5-616351ccbc43", "description": "The unique identifier of the panel", "type": "string" }, @@ -6952,6 +6964,14 @@ "type": "object" }, "panelIndex": { + "default": { + "ref": { + "path": [ + "gridData", + "i" + ] + } + }, "description": "The unique ID of the panel.", "type": "string" }, @@ -7117,11 +7137,12 @@ "type": "object" }, "grow": { - "default": false, + "default": true, "description": "Expand width of the control panel to fit available space.", "type": "boolean" }, "id": { + "default": "edc483da-2dcf-4469-8d36-c99ca8f699a7", "description": "The unique ID of the control.", "type": "string" }, @@ -7430,6 +7451,7 @@ "type": "number" }, "i": { + "default": "49de787f-528f-47bd-a3f5-616351ccbc43", "description": "The unique identifier of the panel", "type": "string" }, @@ -7490,6 +7512,14 @@ "type": "object" }, "panelIndex": { + "default": { + "ref": { + "path": [ + "gridData", + "i" + ] + } + }, "description": "The unique ID of the panel.", "type": "string" }, @@ -7753,11 +7783,12 @@ "type": "object" }, "grow": { - "default": false, + "default": true, "description": "Expand width of the control panel to fit available space.", "type": "boolean" }, "id": { + "default": "edc483da-2dcf-4469-8d36-c99ca8f699a7", "description": "The unique ID of the control.", "type": "string" }, @@ -8066,6 +8097,7 @@ "type": "number" }, "i": { + "default": "49de787f-528f-47bd-a3f5-616351ccbc43", "description": "The unique identifier of the panel", "type": "string" }, @@ -8126,6 +8158,14 @@ "type": "object" }, "panelIndex": { + "default": { + "ref": { + "path": [ + "gridData", + "i" + ] + } + }, "description": "The unique ID of the panel.", "type": "string" }, @@ -8285,11 +8325,12 @@ "type": "object" }, "grow": { - "default": false, + "default": true, "description": "Expand width of the control panel to fit available space.", "type": "boolean" }, "id": { + "default": "edc483da-2dcf-4469-8d36-c99ca8f699a7", "description": "The unique ID of the control.", "type": "string" }, @@ -8598,6 +8639,7 @@ "type": "number" }, "i": { + "default": "49de787f-528f-47bd-a3f5-616351ccbc43", "description": "The unique identifier of the panel", "type": "string" }, @@ -8658,6 +8700,14 @@ "type": "object" }, "panelIndex": { + "default": { + "ref": { + "path": [ + "gridData", + "i" + ] + } + }, "description": "The unique ID of the panel.", "type": "string" }, diff --git a/src/plugins/dashboard/server/content_management/v3/cm_services.ts b/src/plugins/dashboard/server/content_management/v3/cm_services.ts index f4a4d902355f5..e086d1cc1460a 100644 --- a/src/plugins/dashboard/server/content_management/v3/cm_services.ts +++ b/src/plugins/dashboard/server/content_management/v3/cm_services.ts @@ -7,6 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ +import { v4 as uuidv4 } from 'uuid'; import { schema, Type } from '@kbn/config-schema'; import { createOptionsSchemas, updateOptionsSchema } from '@kbn/content-management-utils'; import type { ContentManagementServicesDefinition as ServicesDefinition } from '@kbn/object-versioning'; @@ -49,11 +50,10 @@ export const controlGroupInputSchema = schema.object({ { type: schema.string({ meta: { description: 'The type of the control panel.' } }), controlConfig: schema.maybe(schema.recordOf(schema.string(), schema.any())), - id: schema.maybe( - schema.string({ - meta: { description: 'The unique ID of the control.' }, - }) - ), + id: schema.string({ + defaultValue: uuidv4(), + meta: { description: 'The unique ID of the control.' }, + }), order: schema.number({ meta: { description: 'The order of the control panel in the control group.', @@ -243,11 +243,10 @@ export const gridDataSchema = schema.object({ min: 1, meta: { description: 'The height of the panel in grid units' }, }), - i: schema.maybe( - schema.string({ - meta: { description: 'The unique identifier of the panel' }, - }) - ), + i: schema.string({ + meta: { description: 'The unique identifier of the panel' }, + defaultValue: uuidv4(), + }), }); export const panelSchema = schema.object({ @@ -285,11 +284,10 @@ export const panelSchema = schema.object({ type: schema.string({ meta: { description: 'The embeddable type' } }), panelRefName: schema.maybe(schema.string()), gridData: gridDataSchema, - panelIndex: schema.maybe( - schema.string({ - meta: { description: 'The unique ID of the panel.' }, - }) - ), + panelIndex: schema.string({ + meta: { description: 'The unique ID of the panel.' }, + defaultValue: schema.siblingRef('gridData.i'), + }), title: schema.maybe(schema.string({ meta: { description: 'The title of the panel' } })), version: schema.maybe( schema.string({