[v11.3.x] DashboardScene: Fix layout issues with repeated panels when repeatDirection is missing (#97156)
DashboardScene: Fix layout issues with repeated panels when `repeatDirection` is missing (#97149)
fix
(cherry picked from commit 0bf9d68070)
Co-authored-by: Victor Marin <36818606+mdvictor@users.noreply.github.com>
This commit is contained in:
co-authored by
Victor Marin
parent
1c201629d5
commit
f8dfaebf4c
@@ -648,6 +648,26 @@ describe('transformSaveModelToScene', () => {
|
|||||||
expect(vizPanel.state.$data).toBeUndefined();
|
expect(vizPanel.state.$data).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('When repeat is set but repeatDirection is not it should default to horizontal repeat', () => {
|
||||||
|
const panel = {
|
||||||
|
title: '',
|
||||||
|
type: 'text-plugin-34',
|
||||||
|
gridPos: { x: 0, y: 0, w: 8, h: 8 },
|
||||||
|
repeat: 'server',
|
||||||
|
maxPerRow: 8,
|
||||||
|
};
|
||||||
|
|
||||||
|
const gridItem = buildGridItemForPanel(new PanelModel(panel));
|
||||||
|
const repeater = gridItem as DashboardGridItem;
|
||||||
|
|
||||||
|
expect(repeater.state.maxPerRow).toBe(8);
|
||||||
|
expect(repeater.state.variableName).toBe('server');
|
||||||
|
expect(repeater.state.width).toBe(24);
|
||||||
|
expect(repeater.state.height).toBe(8);
|
||||||
|
expect(repeater.state.repeatDirection).toBe('h');
|
||||||
|
expect(repeater.state.maxPerRow).toBe(8);
|
||||||
|
});
|
||||||
|
|
||||||
it('When repeat is set should build PanelRepeaterGridItem', () => {
|
it('When repeat is set should build PanelRepeaterGridItem', () => {
|
||||||
const panel = {
|
const panel = {
|
||||||
title: '',
|
title: '',
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ export function buildGridItemForPanel(panel: PanelModel): DashboardGridItem {
|
|||||||
const repeatOptions: Partial<{ variableName: string; repeatDirection: RepeatDirection }> = panel.repeat
|
const repeatOptions: Partial<{ variableName: string; repeatDirection: RepeatDirection }> = panel.repeat
|
||||||
? {
|
? {
|
||||||
variableName: panel.repeat,
|
variableName: panel.repeat,
|
||||||
repeatDirection: panel.repeatDirection === 'h' ? 'h' : 'v',
|
repeatDirection: panel.repeatDirection === 'v' ? 'v' : 'h',
|
||||||
}
|
}
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user