Skip to content

Commit 4a2776c

Browse files
ziomeckaKatarzyna Ziomek-Zdanowicz
and
Katarzyna Ziomek-Zdanowicz
authored
8225 Fix missing grafana loader (#53)
Co-authored-by: Katarzyna Ziomek-Zdanowicz <[email protected]>
1 parent 3080d5c commit 4a2776c

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

public/app/features/dashboard/containers/DashboardPage.tsx

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { cx } from '@emotion/css';
2-
import React, { PureComponent, ReactNode } from 'react';
2+
import React, { PureComponent, } from 'react';
33
import { connect, ConnectedProps, MapDispatchToProps, MapStateToProps } from 'react-redux';
44

55
import { NavModel, NavModelItem, TimeRange, PageLayoutType, locationUtil } from '@grafana/data';
@@ -37,6 +37,8 @@ import { liveTimer } from '../dashgrid/liveTimer';
3737
import { getTimeSrv } from '../services/TimeSrv';
3838
import { cleanUpDashboardAndVariables } from '../state/actions';
3939
import { initDashboard } from '../state/initDashboard';
40+
import { FNDashboardProps } from 'app/fn-app/types';
41+
import { isUndefined, isEmpty, noop } from 'lodash';
4042

4143
export interface DashboardPageRouteParams {
4244
uid?: string;
@@ -100,7 +102,8 @@ const connector = connect(mapStateToProps, mapDispatchToProps);
100102
type OwnProps = {
101103
isPublic?: boolean;
102104
controlsContainer?: string | null;
103-
fnLoader?: ReactNode;
105+
fnLoader?: FNDashboardProps['fnLoader'];
106+
isLoading?: FNDashboardProps['isLoading']
104107
};
105108

106109
export type DashboardPageProps = OwnProps &
@@ -377,14 +380,18 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
377380
}
378381

379382
render() {
380-
const { dashboard, initError, queryParams, isPublic, FNDashboard, fnLoader } = this.props;
383+
const { dashboard, initError, queryParams, isPublic, FNDashboard, fnLoader, isLoading = noop } = this.props;
381384
const { editPanel, viewPanel, updateScrollTop, pageNav, sectionNav } = this.state;
382385
const kioskMode = FNDashboard ? KioskMode.FN : !isPublic ? getKioskMode(this.props.queryParams) : KioskMode.Full;
383386

384-
if (!dashboard) {
385-
return fnLoader ? <>{fnLoader}</> : <DashboardLoading initPhase={this.props.initPhase} />;
387+
if (!dashboard || isEmpty(queryParams)) {
388+
isLoading(true)
389+
390+
return isUndefined(fnLoader) ? <DashboardLoading initPhase={this.props.initPhase} />: <>{fnLoader}</>;
386391
}
387392

393+
isLoading(false)
394+
388395
const inspectPanel = this.getInspectPanel();
389396
const showSubMenu = !editPanel && !this.props.queryParams.editview;
390397

public/app/fn-app/fn-dashboard-page/render-fn-dashboard.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { merge, isEmpty, isFunction } from 'lodash';
1+
import { merge, isFunction } from 'lodash';
22
import React, { useEffect, FC, useMemo } from 'react';
33

44
import { locationService as locationSrv, HistoryWrapper } from '@grafana/runtime';
@@ -27,7 +27,7 @@ const DEFAULT_DASHBOARD_PAGE_PROPS: Pick<DashboardPageProps, 'history' | 'route'
2727
};
2828

2929
export const RenderFNDashboard: FC<FNDashboardProps> = (props) => {
30-
const { queryParams, controlsContainer, setErrors, fnLoader, hiddenVariables } = props;
30+
const { queryParams, controlsContainer, setErrors, fnLoader, hiddenVariables, isLoading } = props;
3131

3232
const firstError = useSelector((state: StoreState) => {
3333
const { appNotifications } = state;
@@ -67,9 +67,10 @@ export const RenderFNDashboard: FC<FNDashboardProps> = (props) => {
6767
hiddenVariables,
6868
controlsContainer,
6969
fnLoader,
70+
isLoading
7071
}),
7172
[controlsContainer, fnLoader, hiddenVariables, props, queryParams]
7273
);
7374

74-
return isEmpty(queryParams || {}) ? <>{fnLoader}</> : <DashboardPage {...dashboardPageProps} />;
75+
return <DashboardPage {...dashboardPageProps} />;
7576
};

0 commit comments

Comments
 (0)