mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Infra] Inventory-view saved object schema fix (#210023)
fixes [#209996](https://github.com/elastic/kibana/issues/209996) ## Summary Fix the `inventory-view` schema. The wrong schema was causing an error when trying to create/update a saved view on Infra Inventory UI  ### How to test - Run on dev tools the request below, it should return a 400 containing the message: `"[attributes.legend.steps]: Value must be equal to or lower than [18].: Bad Request"` ``` POST kbn:/api/saved_objects/inventory-view { "attributes": { "metric": { "type": "cpuV2" }, "sort": { "by": "name", "direction": "desc" }, "groupBy": [], "nodeType": "host", "view": "map", "customOptions": [], "customMetrics": [], "boundsOverride": { "max": 1, "min": 0 }, "autoBounds": true, "accountId": "", "region": "", "time": 1738848614746, "autoReload": false, "filterQuery": { "expression": "", "kind": "kuery" }, "legend": { "palette": "cool", "steps": 20, "reverseColors": false }, "timelineOpen": false, "name": "sss" } } ``` - Navigate to Infra > Inventory - Create a new saved view
This commit is contained in:
parent
02c3373419
commit
e21e7482e7
1 changed files with 9 additions and 4 deletions
|
@ -23,9 +23,14 @@ const getInventoryViewTitle = (savedObject: SavedObject<unknown>) =>
|
|||
);
|
||||
|
||||
const schemaV1 = schema.object({}, { unknowns: 'allow' });
|
||||
const schemaV2 = schema.object({
|
||||
legend: schema.object({ steps: schema.number({ max: 18, min: 2 }) }),
|
||||
});
|
||||
const schemaV2 = schema.object(
|
||||
{
|
||||
legend: schema.maybe(
|
||||
schema.object({ steps: schema.number({ max: 18, min: 2 }) }, { unknowns: 'allow' })
|
||||
),
|
||||
},
|
||||
{ unknowns: 'allow' }
|
||||
);
|
||||
|
||||
export const inventoryViewSavedObjectType: SavedObjectsType = {
|
||||
name: inventoryViewSavedObjectName,
|
||||
|
@ -64,7 +69,7 @@ export const inventoryViewSavedObjectType: SavedObjectsType = {
|
|||
},
|
||||
],
|
||||
schemas: {
|
||||
forwardCompatibility: schemaV2.extends({}, { unknowns: 'ignore' }),
|
||||
forwardCompatibility: schemaV2,
|
||||
create: schemaV2,
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue