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:
+3
-1
@@ -15,6 +15,7 @@ import {
|
|||||||
getPanelIdForVizPanel,
|
getPanelIdForVizPanel,
|
||||||
getVizPanelKeyForPanelId,
|
getVizPanelKeyForPanelId,
|
||||||
} from '../../utils/utils';
|
} from '../../utils/utils';
|
||||||
|
import { DashboardGridItem } from '../layout-default/DashboardGridItem';
|
||||||
import { clearClipboard, getAutoGridItemFromClipboard } from '../layouts-shared/paste';
|
import { clearClipboard, getAutoGridItemFromClipboard } from '../layouts-shared/paste';
|
||||||
import { DashboardLayoutManager } from '../types/DashboardLayoutManager';
|
import { DashboardLayoutManager } from '../types/DashboardLayoutManager';
|
||||||
import { LayoutRegistryItem } from '../types/LayoutRegistryItem';
|
import { LayoutRegistryItem } from '../types/LayoutRegistryItem';
|
||||||
@@ -261,7 +262,8 @@ export class AutoGridLayoutManager
|
|||||||
const children: AutoGridItem[] = [];
|
const children: AutoGridItem[] = [];
|
||||||
|
|
||||||
for (let panel of panels) {
|
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();
|
const layoutManager = AutoGridLayoutManager.createEmpty();
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import {
|
|||||||
getLayoutOrchestratorFor,
|
getLayoutOrchestratorFor,
|
||||||
getDashboardSceneFor,
|
getDashboardSceneFor,
|
||||||
} from '../../utils/utils';
|
} from '../../utils/utils';
|
||||||
|
import { AutoGridItem } from '../layout-auto-grid/AutoGridItem';
|
||||||
import { CanvasGridAddActions } from '../layouts-shared/CanvasGridAddActions';
|
import { CanvasGridAddActions } from '../layouts-shared/CanvasGridAddActions';
|
||||||
import { clearClipboard, getDashboardGridItemFromClipboard } from '../layouts-shared/paste';
|
import { clearClipboard, getDashboardGridItemFromClipboard } from '../layouts-shared/paste';
|
||||||
import { DashboardLayoutManager } from '../types/DashboardLayoutManager';
|
import { DashboardLayoutManager } from '../types/DashboardLayoutManager';
|
||||||
@@ -490,6 +491,8 @@ export class DefaultGridLayoutManager
|
|||||||
let currentX = 0;
|
let currentX = 0;
|
||||||
|
|
||||||
for (let panel of panels) {
|
for (let panel of panels) {
|
||||||
|
const variableName = panel.parent instanceof AutoGridItem ? panel.parent.state.variableName : undefined;
|
||||||
|
|
||||||
panel.clearParent();
|
panel.clearParent();
|
||||||
|
|
||||||
children.push(
|
children.push(
|
||||||
@@ -499,7 +502,9 @@ export class DefaultGridLayoutManager
|
|||||||
y: currentY,
|
y: currentY,
|
||||||
width: panelWidth,
|
width: panelWidth,
|
||||||
height: panelHeight,
|
height: panelHeight,
|
||||||
|
itemHeight: panelHeight,
|
||||||
body: panel,
|
body: panel,
|
||||||
|
variableName,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user