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:
@@ -753,6 +753,20 @@ describe('DashboardScene', () => {
|
|||||||
expect(gridItem.state.body!.state.key).toBe('panel-7');
|
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', () => {
|
it('Should duplicate a library panel', () => {
|
||||||
const libraryPanel = ((scene.state.body as SceneGridLayout).state.children[4] as DashboardGridItem).state.body;
|
const libraryPanel = ((scene.state.body as SceneGridLayout).state.children[4] as DashboardGridItem).state.body;
|
||||||
const vizPanel = (libraryPanel as LibraryVizPanel).state.panel;
|
const vizPanel = (libraryPanel as LibraryVizPanel).state.panel;
|
||||||
|
|||||||
@@ -594,8 +594,8 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> {
|
|||||||
newGridItem = new DashboardGridItem({
|
newGridItem = new DashboardGridItem({
|
||||||
x: gridItem.state.x,
|
x: gridItem.state.x,
|
||||||
y: gridItem.state.y,
|
y: gridItem.state.y,
|
||||||
height: NEW_PANEL_HEIGHT,
|
height: gridItem.state.height,
|
||||||
width: NEW_PANEL_WIDTH,
|
width: gridItem.state.width,
|
||||||
body: new VizPanel({ ...panelState, $data: panelData, key: getVizPanelKeyForPanelId(newPanelId) }),
|
body: new VizPanel({ ...panelState, $data: panelData, key: getVizPanelKeyForPanelId(newPanelId) }),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user