mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
Scenes: Repeat horizontally set the width to 24 even if repeat variable is not set (#89658)
This commit is contained in:
parent
df4b280134
commit
6773f7f4ce
@ -504,6 +504,47 @@ describe('transformSaveModelToScene', () => {
|
||||
expect(repeater.state.maxPerRow).toBe(8);
|
||||
});
|
||||
|
||||
it('When horizontal repeat is set should modify the width to 24', () => {
|
||||
const panel = {
|
||||
title: '',
|
||||
type: 'text-plugin-34',
|
||||
gridPos: { x: 0, y: 0, w: 8, h: 8 },
|
||||
repeat: 'server',
|
||||
repeatDirection: 'h',
|
||||
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 horizontal repeat is NOT fully configured should not modify the width', () => {
|
||||
const panel = {
|
||||
title: '',
|
||||
type: 'text-plugin-34',
|
||||
gridPos: { x: 0, y: 0, w: 8, h: 8 },
|
||||
repeatDirection: 'h',
|
||||
maxPerRow: 8,
|
||||
};
|
||||
|
||||
const gridItem = buildGridItemForPanel(new PanelModel(panel));
|
||||
const repeater = gridItem as DashboardGridItem;
|
||||
|
||||
expect(repeater.state.maxPerRow).toBe(8);
|
||||
expect(repeater.state.variableName).toBe(undefined);
|
||||
expect(repeater.state.width).toBe(8);
|
||||
expect(repeater.state.height).toBe(8);
|
||||
expect(repeater.state.repeatDirection).toBe(undefined);
|
||||
expect(repeater.state.maxPerRow).toBe(8);
|
||||
});
|
||||
|
||||
it('should apply query caching options to SceneQueryRunner', () => {
|
||||
const panel = {
|
||||
title: '',
|
||||
|
@ -443,11 +443,10 @@ export function buildGridItemForLibPanel(panel: PanelModel) {
|
||||
}
|
||||
|
||||
export function buildGridItemForPanel(panel: PanelModel): DashboardGridItem {
|
||||
const repeatDirection: RepeatDirection = panel.repeatDirection === 'h' ? 'h' : 'v';
|
||||
const repeatOptions = panel.repeat
|
||||
const repeatOptions: Partial<{ variableName: string; repeatDirection: RepeatDirection }> = panel.repeat
|
||||
? {
|
||||
variableName: panel.repeat,
|
||||
repeatDirection,
|
||||
repeatDirection: panel.repeatDirection === 'h' ? 'h' : 'v',
|
||||
}
|
||||
: {};
|
||||
|
||||
@ -501,7 +500,7 @@ export function buildGridItemForPanel(panel: PanelModel): DashboardGridItem {
|
||||
key: `grid-item-${panel.id}`,
|
||||
x: panel.gridPos.x,
|
||||
y: panel.gridPos.y,
|
||||
width: repeatDirection === 'h' ? 24 : panel.gridPos.w,
|
||||
width: repeatOptions.repeatDirection === 'h' ? 24 : panel.gridPos.w,
|
||||
height: panel.gridPos.h,
|
||||
itemHeight: panel.gridPos.h,
|
||||
body,
|
||||
|
Loading…
Reference in New Issue
Block a user