mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Scenes: Fix row crash when removing a panel from it (#85339)
* Fix row crash when removing a panel from it * fix tests * fix tests
This commit is contained in:
@@ -30,6 +30,7 @@ import { DashboardControls } from './DashboardControls';
|
|||||||
import { DashboardGridItem } from './DashboardGridItem';
|
import { DashboardGridItem } from './DashboardGridItem';
|
||||||
import { DashboardScene, DashboardSceneState } from './DashboardScene';
|
import { DashboardScene, DashboardSceneState } from './DashboardScene';
|
||||||
import { LibraryVizPanel } from './LibraryVizPanel';
|
import { LibraryVizPanel } from './LibraryVizPanel';
|
||||||
|
import { RowActions } from './row-actions/RowActions';
|
||||||
|
|
||||||
jest.mock('../settings/version-history/HistorySrv');
|
jest.mock('../settings/version-history/HistorySrv');
|
||||||
jest.mock('../serialization/transformSaveModelToScene');
|
jest.mock('../serialization/transformSaveModelToScene');
|
||||||
@@ -535,6 +536,7 @@ describe('DashboardScene', () => {
|
|||||||
|
|
||||||
const body = scene.state.body as SceneGridLayout;
|
const body = scene.state.body as SceneGridLayout;
|
||||||
const gridRow = body.state.children[2] as SceneGridRow;
|
const gridRow = body.state.children[2] as SceneGridRow;
|
||||||
|
|
||||||
expect(gridRow.state.children.length).toBe(1);
|
expect(gridRow.state.children.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -888,6 +890,7 @@ function buildTestScene(overrides?: Partial<DashboardSceneState>) {
|
|||||||
}),
|
}),
|
||||||
new SceneGridRow({
|
new SceneGridRow({
|
||||||
key: 'panel-3',
|
key: 'panel-3',
|
||||||
|
actions: new RowActions({}),
|
||||||
children: [
|
children: [
|
||||||
new DashboardGridItem({
|
new DashboardGridItem({
|
||||||
body: new VizPanel({
|
body: new VizPanel({
|
||||||
|
|||||||
@@ -661,7 +661,7 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (row) {
|
if (row) {
|
||||||
row.forEachChild((child: SceneObject) => {
|
row.state.children.forEach((child: SceneObject) => {
|
||||||
if (child.state.key !== key) {
|
if (child.state.key !== key) {
|
||||||
panels.push(child);
|
panels.push(child);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user