mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Reporting: Disable lazy loading for panels (#98065)
This commit is contained in:
parent
87b250d7e2
commit
f9c2a5fae9
@ -51,6 +51,7 @@ import {
|
||||
QueryVariableKind,
|
||||
TextVariableKind,
|
||||
} from '@grafana/schema/src/schema/dashboard/v2alpha0/dashboard.gen';
|
||||
import { contextSrv } from 'app/core/core';
|
||||
import {
|
||||
AnnoKeyCreatedBy,
|
||||
AnnoKeyDashboardNotFound,
|
||||
@ -170,7 +171,7 @@ export function transformSaveModelSchemaV2ToScene(dto: DashboardWithAccessInfo<D
|
||||
version: parseInt(metadata.resourceVersion, 10),
|
||||
body: new DefaultGridLayoutManager({
|
||||
grid: new SceneGridLayout({
|
||||
isLazy: dashboard.preload ? false : true,
|
||||
isLazy: !(dashboard.preload || contextSrv.user.authenticatedBy === 'render'),
|
||||
children: createSceneGridLayoutForItems(dashboard),
|
||||
$behaviors: [trackIfEmpty],
|
||||
}),
|
||||
|
@ -20,6 +20,7 @@ import {
|
||||
RowPanel,
|
||||
VariableType,
|
||||
} from '@grafana/schema';
|
||||
import { contextSrv } from 'app/core/core';
|
||||
import { DashboardModel } from 'app/features/dashboard/state/DashboardModel';
|
||||
import { PanelModel } from 'app/features/dashboard/state/PanelModel';
|
||||
import { createPanelSaveModel } from 'app/features/dashboard/state/__fixtures__/dashboardFixtures';
|
||||
@ -168,6 +169,35 @@ describe('transformSaveModelToScene', () => {
|
||||
const scene = createDashboardSceneFromDashboardModel(oldModel, dash);
|
||||
expect(scene.state.$variables?.state.variables).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not return lazy loaded panels when user is image renderer', () => {
|
||||
contextSrv.user.authenticatedBy = 'render';
|
||||
|
||||
const panel1 = createPanelSaveModel({
|
||||
title: 'test1',
|
||||
gridPos: { x: 0, y: 1, w: 12, h: 8 },
|
||||
}) as Panel;
|
||||
|
||||
const panel2 = createPanelSaveModel({
|
||||
title: 'test2',
|
||||
gridPos: { x: 0, y: 10, w: 12, h: 8 },
|
||||
}) as Panel;
|
||||
|
||||
const dashboard = {
|
||||
...defaultDashboard,
|
||||
title: 'Test dashboard',
|
||||
uid: 'test-uid',
|
||||
panels: [panel1, panel2],
|
||||
};
|
||||
|
||||
const oldModel = new DashboardModel(dashboard);
|
||||
|
||||
const scene = createDashboardSceneFromDashboardModel(oldModel, dashboard);
|
||||
const layout = scene.state.body as DefaultGridLayoutManager;
|
||||
const body = layout.state.grid;
|
||||
|
||||
expect(body.state.isLazy).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When creating a new dashboard', () => {
|
||||
|
@ -21,6 +21,7 @@ import {
|
||||
UserActionEvent,
|
||||
SceneObjectState,
|
||||
} from '@grafana/scenes';
|
||||
import { contextSrv } from 'app/core/core';
|
||||
import { DashboardModel } from 'app/features/dashboard/state/DashboardModel';
|
||||
import { PanelModel } from 'app/features/dashboard/state/PanelModel';
|
||||
import { DashboardDTO, DashboardDataDTO } from 'app/types';
|
||||
@ -256,7 +257,7 @@ export function createDashboardSceneFromDashboardModel(oldModel: DashboardModel,
|
||||
version: oldModel.version,
|
||||
body: new DefaultGridLayoutManager({
|
||||
grid: new SceneGridLayout({
|
||||
isLazy: dto.preload ? false : true,
|
||||
isLazy: !(dto.preload || contextSrv.user.authenticatedBy === 'render'),
|
||||
children: createSceneObjectsForPanels(oldModel.panels),
|
||||
$behaviors: [trackIfEmpty],
|
||||
}),
|
||||
|
Loading…
Reference in New Issue
Block a user