Skip to content

Commit 2ceb550

Browse files
ziomeckaKatarzyna Ziomek-Zdanowicz
authored andcommitted
8225 Fix missing grafana loader (#53)
Co-authored-by: Katarzyna Ziomek-Zdanowicz <[email protected]>
1 parent ebee848 commit 2ceb550

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, GrafanaTheme2 } from '@grafana/data';
@@ -44,6 +44,8 @@ import { getTimeSrv } from '../services/TimeSrv';
4444
import { explicitlyControlledMigrationPanels, autoMigrateAngular } from '../state/PanelModel';
4545
import { cleanUpDashboardAndVariables } from '../state/actions';
4646
import { initDashboard } from '../state/initDashboard';
47+
import { FNDashboardProps } from 'app/fn-app/types';
48+
import { isUndefined, isEmpty, noop } from 'lodash';
4749

4850
import { DashboardPageRouteParams, DashboardPageRouteSearchParams } from './types';
4951

@@ -90,7 +92,8 @@ const connector = connect(mapStateToProps, mapDispatchToProps);
9092
type OwnProps = {
9193
isPublic?: boolean;
9294
controlsContainer?: string | null;
93-
fnLoader?: ReactNode;
95+
fnLoader?: FNDashboardProps['fnLoader'];
96+
isLoading?: FNDashboardProps['isLoading']
9497
};
9598

9699
export type DashboardPageProps = OwnProps &
@@ -396,14 +399,18 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
396399
};
397400

398401
render() {
399-
const { dashboard, initError, queryParams, isPublic, FNDashboard, fnLoader } = this.props;
402+
const { dashboard, initError, queryParams, isPublic, FNDashboard, fnLoader, isLoading = noop } = this.props;
400403
const { editPanel, viewPanel, updateScrollTop, pageNav, sectionNav } = this.state;
401404
const kioskMode = FNDashboard ? KioskMode.FN : !isPublic ? getKioskMode(this.props.queryParams) : KioskMode.Full;
402405

403-
if (!dashboard) {
404-
return fnLoader ? <>{fnLoader}</> : <DashboardLoading initPhase={this.props.initPhase} />;
406+
if (!dashboard || isEmpty(queryParams)) {
407+
isLoading(true)
408+
409+
return isUndefined(fnLoader) ? <DashboardLoading initPhase={this.props.initPhase} />: <>{fnLoader}</>;
405410
}
406411

412+
isLoading(false)
413+
407414
const inspectPanel = this.getInspectPanel();
408415
const showSubMenu = !editPanel && !this.props.queryParams.editview;
409416

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)