Dashboards: Fix saving repeat rows in schemav2 (#101432)

fix saving repeat rows
This commit is contained in:
Oscar Kilhed
2025-03-04 15:16:01 +01:00
committed by GitHub
parent b3ad7ce151
commit 6ed55766da
@@ -32,8 +32,13 @@ import { RowRepeaterBehavior } from '../../scene/layout-default/RowRepeaterBehav
import { RowActions } from '../../scene/layout-default/row-actions/RowActions';
import { setDashboardPanelContext } from '../../scene/setDashboardPanelContext';
import { DashboardLayoutManager, LayoutManagerSerializer } from '../../scene/types/DashboardLayoutManager';
import { isClonedKey } from '../../utils/clone';
import { calculateGridItemDimensions, getVizPanelKeyForPanelId, isLibraryPanel } from '../../utils/utils';
import { getOriginalKey, isClonedKey } from '../../utils/clone';
import {
calculateGridItemDimensions,
getPanelIdForVizPanel,
getVizPanelKeyForPanelId,
isLibraryPanel,
} from '../../utils/utils';
import { GRID_ROW_HEIGHT } from '../const';
import { buildVizPanel } from './utils';
@@ -143,7 +148,7 @@ function gridItemToGridLayoutItemKind(gridItem: DashboardGridItem, yOverride?: n
const repeatVar = gridItem_.state.variableName;
// FIXME: which name should we use for the element reference, key or something else ?
const elementName = gridItem_.state.body.state.key ?? 'DefaultName';
const elementName = getVizPanelKeyForPanelId(getPanelIdForVizPanel(gridItem_.state.body));
elementGridItem = {
kind: 'GridLayoutItem',
spec: {
@@ -266,7 +271,7 @@ function createSceneGridLayoutForItems(layout: GridLayoutKind, elements: Record<
}
} else if (element.kind === 'GridLayoutRow') {
const children = element.spec.elements.map((gridElement) => {
const panel = elements[gridElement.spec.element.name];
const panel = elements[getOriginalKey(gridElement.spec.element.name)];
if (panel.kind === 'Panel') {
return buildGridItem(gridElement.spec, panel, element.spec.y + GRID_ROW_HEIGHT + gridElement.spec.y);
} else {