Dashboard scenes: Duplicated panels should maintain size of source panel (#89152)

Maintain size of duplicated panel
This commit is contained in:
Oscar Kilhed 2024-06-13 11:24:29 +02:00 committed by GitHub
parent 025309a303
commit 99e5e1c8bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View File

@ -753,6 +753,20 @@ describe('DashboardScene', () => {
expect(gridItem.state.body!.state.key).toBe('panel-7');
});
it('Should maintain size of duplicated panel', () => {
const gItem = (scene.state.body as SceneGridLayout).state.children[0] as DashboardGridItem;
gItem.setState({ height: 1 });
const vizPanel = gItem.state.body;
scene.duplicatePanel(vizPanel as VizPanel);
const body = scene.state.body as SceneGridLayout;
const newGridItem = body.state.children[5] as DashboardGridItem;
expect(body.state.children.length).toBe(6);
expect(newGridItem.state.body!.state.key).toBe('panel-7');
expect(newGridItem.state.height).toBe(1);
});
it('Should duplicate a library panel', () => {
const libraryPanel = ((scene.state.body as SceneGridLayout).state.children[4] as DashboardGridItem).state.body;
const vizPanel = (libraryPanel as LibraryVizPanel).state.panel;

View File

@ -594,8 +594,8 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> {
newGridItem = new DashboardGridItem({
x: gridItem.state.x,
y: gridItem.state.y,
height: NEW_PANEL_HEIGHT,
width: NEW_PANEL_WIDTH,
height: gridItem.state.height,
width: gridItem.state.width,
body: new VizPanel({ ...panelState, $data: panelData, key: getVizPanelKeyForPanelId(newPanelId) }),
});
}