DashboardScene: Fixes angular panels inside collapsed rows (#78532)

* DashboardScene: Fixes angular panels inside collapsed rows

* Update
pull/78602/head
Torkel Ödegaard 2 years ago committed by GitHub
parent 41713353eb
commit a98a39c418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      public/app/features/dashboard-scene/serialization/__snapshots__/transformSceneToSaveModel.test.ts.snap
  2. 1
      public/app/features/dashboard-scene/serialization/testfiles/repeating_rows_and_panels.json
  3. 8
      public/app/features/dashboard-scene/serialization/transformSaveModelToScene.ts
  4. 5
      public/app/features/dashboard-scene/serialization/transformSceneToSaveModel.test.ts

@ -123,11 +123,6 @@ exports[`transformSceneToSaveModel Given a scene with rows Should transform back
</div>",
"mode": "markdown",
},
"targets": [
{
"refId": "A",
},
],
"title": "",
"transformations": [],
"transparent": false,
@ -180,6 +175,7 @@ exports[`transformSceneToSaveModel Given a scene with rows Should transform back
</div>",
"mode": "markdown",
},
"title": "Text panel in collapsed row",
"transformations": [],
"transparent": false,
"type": "text",
@ -433,11 +429,6 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
"content": "content",
"mode": "markdown",
},
"targets": [
{
"refId": "A",
},
],
"title": "Transparent text panel",
"transformations": [],
"transparent": true,

@ -182,6 +182,7 @@
"y": 26
},
"id": 30,
"title": "Text panel in collapsed row",
"options": {
"code": {
"language": "plaintext",

@ -124,7 +124,13 @@ export function createSceneObjectsForPanels(oldPanels: PanelModel[]): SceneGridI
function createRowFromPanelModel(row: PanelModel, content: SceneGridItemLike[]): SceneGridItemLike {
if (Boolean(row.collapsed)) {
if (row.panels) {
content = row.panels.map(buildGridItemForPanel);
content = row.panels.map((saveModel) => {
// Collapsed panels are not actually PanelModel instances
if (!(saveModel instanceof PanelModel)) {
saveModel = new PanelModel(saveModel);
}
return buildGridItemForPanel(saveModel);
});
}
}

@ -120,6 +120,7 @@ const runRequestMock = jest.fn().mockImplementation((ds: DataSourceApi, request:
})
);
});
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({
@ -135,7 +136,9 @@ jest.mock('@grafana/runtime', () => ({
return runRequestMock(ds, request);
},
config: {
panels: [],
panels: {
text: { skipDataQuery: true },
},
featureToggles: {
dataTrails: false,
},

Loading…
Cancel
Save