AutoGridLayoutManager: Preserve variableName when switching between auto and custom grids (#104856)

preserve variableName when switching between auto and custom grids
This commit is contained in:
Sergej-Vlasov
2025-05-07 16:07:39 +01:00
committed by GitHub
parent 2a02fd7239
commit d095cb4e04
2 changed files with 8 additions and 1 deletions
@@ -15,6 +15,7 @@ import {
getPanelIdForVizPanel,
getVizPanelKeyForPanelId,
} from '../../utils/utils';
import { DashboardGridItem } from '../layout-default/DashboardGridItem';
import { clearClipboard, getAutoGridItemFromClipboard } from '../layouts-shared/paste';
import { DashboardLayoutManager } from '../types/DashboardLayoutManager';
import { LayoutRegistryItem } from '../types/LayoutRegistryItem';
@@ -261,7 +262,8 @@ export class AutoGridLayoutManager
const children: AutoGridItem[] = [];
for (let panel of panels) {
children.push(new AutoGridItem({ body: panel.clone() }));
const variableName = panel.parent instanceof DashboardGridItem ? panel.parent.state.variableName : undefined;
children.push(new AutoGridItem({ body: panel.clone(), variableName }));
}
const layoutManager = AutoGridLayoutManager.createEmpty();
@@ -40,6 +40,7 @@ import {
getLayoutOrchestratorFor,
getDashboardSceneFor,
} from '../../utils/utils';
import { AutoGridItem } from '../layout-auto-grid/AutoGridItem';
import { CanvasGridAddActions } from '../layouts-shared/CanvasGridAddActions';
import { clearClipboard, getDashboardGridItemFromClipboard } from '../layouts-shared/paste';
import { DashboardLayoutManager } from '../types/DashboardLayoutManager';
@@ -490,6 +491,8 @@ export class DefaultGridLayoutManager
let currentX = 0;
for (let panel of panels) {
const variableName = panel.parent instanceof AutoGridItem ? panel.parent.state.variableName : undefined;
panel.clearParent();
children.push(
@@ -499,7 +502,9 @@ export class DefaultGridLayoutManager
y: currentY,
width: panelWidth,
height: panelHeight,
itemHeight: panelHeight,
body: panel,
variableName,
})
);