SchemaV2: Accept rows with no panel property (#101503)

accept rows with no panel property
This commit is contained in:
Oscar Kilhed
2025-03-03 11:19:17 +01:00
committed by GitHub
parent 28a28a686d
commit 070d4b2ee4
2 changed files with 14 additions and 2 deletions
@@ -406,6 +406,13 @@ describe('ResponseTransformers', () => {
],
collapsed: true,
},
{
id: 6,
type: 'row',
title: 'Row with no panel property',
gridPos: { x: 0, y: 25, w: 12, h: 1 },
collapsed: true,
},
],
};
@@ -483,7 +490,7 @@ describe('ResponseTransformers', () => {
// Panel
expect(spec.layout.kind).toBe('GridLayout');
const layout = spec.layout as GridLayoutKind;
expect(layout.spec.items).toHaveLength(4);
expect(layout.spec.items).toHaveLength(5);
expect(layout.spec.items[0].spec).toEqual({
element: {
kind: 'ElementReference',
@@ -606,6 +613,11 @@ describe('ResponseTransformers', () => {
height: 8,
});
const rowWithNoPanelProperty = layout.spec.items[4].spec as GridLayoutRowSpec;
expect(rowWithNoPanelProperty.collapsed).toBe(true);
expect(rowWithNoPanelProperty.title).toBe('Row with no panel property');
expect(rowWithNoPanelProperty.elements).toHaveLength(0);
// Variables
validateVariablesV1ToV2(spec.variables[0], dashboardV1.templating?.list?.[0]);
validateVariablesV1ToV2(spec.variables[1], dashboardV1.templating?.list?.[1]);
@@ -298,7 +298,7 @@ function getElementsFromPanels(
const rowElements = [];
for (const panel of p.panels) {
for (const panel of p.panels || []) {
const [element, name] = buildElement(panel);
elements[name] = element;
rowElements.push(buildGridItemKind(panel, name, yOffsetInRows(panel, p.gridPos!.y)));