mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
DashboardScene: Add mapping for hoverHeader and displayMode to DashboardsLoader (#64870)
Dashboard scene fixes
This commit is contained in:
parent
5d8ec2756e
commit
07305c72bf
@ -1,6 +1,7 @@
|
||||
// Libraries
|
||||
import React, { useEffect } from 'react';
|
||||
|
||||
import { PageLayoutType } from '@grafana/data';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
import PageLoader from 'app/core/components/PageLoader/PageLoader';
|
||||
import { GrafanaRouteComponentProps } from 'app/core/navigation/types';
|
||||
@ -15,11 +16,14 @@ export const DashboardScenePage = ({ match }: Props) => {
|
||||
|
||||
useEffect(() => {
|
||||
loader.load(match.params.uid);
|
||||
return () => {
|
||||
loader.clearState();
|
||||
};
|
||||
}, [loader, match.params.uid]);
|
||||
|
||||
if (!dashboard) {
|
||||
return (
|
||||
<Page navId="dashboards/browse">
|
||||
<Page layout={PageLayoutType.Canvas}>
|
||||
{isLoading && <PageLoader />}
|
||||
{!isLoading && <h2>Dashboard not found</h2>}
|
||||
</Page>
|
||||
|
@ -312,6 +312,20 @@ describe('DashboardLoader', () => {
|
||||
panel.transformations
|
||||
);
|
||||
});
|
||||
|
||||
it('should initalize the VizPanel without title and transparent true', () => {
|
||||
const panel = {
|
||||
title: '',
|
||||
type: 'test-plugin',
|
||||
gridPos: { x: 0, y: 0, w: 12, h: 8 },
|
||||
transparent: true,
|
||||
};
|
||||
|
||||
const vizPanelSceneObject = createVizPanelFromPanelModel(new PanelModel(panel));
|
||||
|
||||
expect(vizPanelSceneObject.state.displayMode).toEqual('transparent');
|
||||
expect(vizPanelSceneObject.state.hoverHeader).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when creating variables objects', () => {
|
||||
|
@ -73,6 +73,10 @@ export class DashboardLoader extends StateManagerBase<DashboardLoaderState> {
|
||||
this.cache[rsp.dashboard.uid] = dashboard;
|
||||
this.setState({ dashboard, isLoading: false });
|
||||
}
|
||||
|
||||
public clearState() {
|
||||
this.setState({ dashboard: undefined, loadError: undefined, isLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
export function createSceneObjectsForPanels(oldPanels: PanelModel[]): SceneObject[] {
|
||||
@ -264,6 +268,9 @@ export function createVizPanelFromPanelModel(panel: PanelModel) {
|
||||
options: panel.options,
|
||||
fieldConfig: panel.fieldConfig,
|
||||
pluginVersion: panel.pluginVersion,
|
||||
displayMode: panel.transparent ? 'transparent' : undefined,
|
||||
// To be replaced with it's own option persited option instead derived
|
||||
hoverHeader: !panel.title && !panel.timeFrom && !panel.timeShift,
|
||||
$data: new SceneDataTransformer({
|
||||
$data: new SceneQueryRunner({
|
||||
queries: panel.targets,
|
||||
|
Loading…
Reference in New Issue
Block a user