DashboardScene: Fixes issue with mobile responsive layout due to repeated grid item class (#85731)

This commit is contained in:
Torkel Ödegaard 2024-04-08 16:55:35 +02:00 committed by GitHub
parent 37d39de36d
commit edf36d9ec0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 2 deletions

View File

@ -1,9 +1,11 @@
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { setPluginImportUtils } from '@grafana/runtime';
import { SceneGridLayout } from '@grafana/scenes';
import { SceneGridLayout, VizPanel } from '@grafana/scenes';
import { activateFullSceneTree, buildPanelRepeaterScene } from '../utils/test-utils';
import { DashboardGridItem } from './DashboardGridItem';
setPluginImportUtils({
importPanelPlugin: (id: string) => Promise.resolve(getPanelPlugin({})),
getPanelPluginFromCache: (id: string) => undefined,
@ -116,4 +118,18 @@ describe('PanelRepeaterGridItem', () => {
'_____default_sys_repeat_var_____'
);
});
it('Should return className when repeat variable is set', () => {
const { repeater } = buildPanelRepeaterScene({ variableQueryTime: 0 });
expect(repeater.getClassName()).toBe('panel-repeater-grid-item');
});
it('Should not className variable is not set', () => {
const gridItem = new DashboardGridItem({
body: new VizPanel({ pluginId: 'text' }),
});
expect(gridItem.getClassName()).toBe('');
});
});

View File

@ -170,7 +170,7 @@ export class DashboardGridItem extends SceneObjectBase<DashboardGridItemState> i
}
public getClassName() {
return 'panel-repeater-grid-item';
return this.state.variableName ? 'panel-repeater-grid-item' : '';
}
public isRepeated() {