mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard scenes: Duplicated panels should maintain size of source panel (#89152)
Maintain size of duplicated panel
This commit is contained in:
parent
025309a303
commit
99e5e1c8bd
@ -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;
|
||||
|
@ -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) }),
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user