|
1 | 1 | import { cx } from '@emotion/css';
|
2 |
| -import React, { PureComponent, ReactNode } from 'react'; |
| 2 | +import React, { PureComponent, } from 'react'; |
3 | 3 | import { connect, ConnectedProps, MapDispatchToProps, MapStateToProps } from 'react-redux';
|
4 | 4 |
|
5 | 5 | import { NavModel, NavModelItem, TimeRange, PageLayoutType, locationUtil } from '@grafana/data';
|
@@ -37,6 +37,8 @@ import { liveTimer } from '../dashgrid/liveTimer';
|
37 | 37 | import { getTimeSrv } from '../services/TimeSrv';
|
38 | 38 | import { cleanUpDashboardAndVariables } from '../state/actions';
|
39 | 39 | import { initDashboard } from '../state/initDashboard';
|
| 40 | +import { FNDashboardProps } from 'app/fn-app/types'; |
| 41 | +import { isUndefined, isEmpty, noop } from 'lodash'; |
40 | 42 |
|
41 | 43 | export interface DashboardPageRouteParams {
|
42 | 44 | uid?: string;
|
@@ -100,7 +102,8 @@ const connector = connect(mapStateToProps, mapDispatchToProps);
|
100 | 102 | type OwnProps = {
|
101 | 103 | isPublic?: boolean;
|
102 | 104 | controlsContainer?: string | null;
|
103 |
| - fnLoader?: ReactNode; |
| 105 | + fnLoader?: FNDashboardProps['fnLoader']; |
| 106 | + isLoading?: FNDashboardProps['isLoading'] |
104 | 107 | };
|
105 | 108 |
|
106 | 109 | export type DashboardPageProps = OwnProps &
|
@@ -377,14 +380,18 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
|
377 | 380 | }
|
378 | 381 |
|
379 | 382 | render() {
|
380 |
| - const { dashboard, initError, queryParams, isPublic, FNDashboard, fnLoader } = this.props; |
| 383 | + const { dashboard, initError, queryParams, isPublic, FNDashboard, fnLoader, isLoading = noop } = this.props; |
381 | 384 | const { editPanel, viewPanel, updateScrollTop, pageNav, sectionNav } = this.state;
|
382 | 385 | const kioskMode = FNDashboard ? KioskMode.FN : !isPublic ? getKioskMode(this.props.queryParams) : KioskMode.Full;
|
383 | 386 |
|
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}</>; |
386 | 391 | }
|
387 | 392 |
|
| 393 | + isLoading(false) |
| 394 | + |
388 | 395 | const inspectPanel = this.getInspectPanel();
|
389 | 396 | const showSubMenu = !editPanel && !this.props.queryParams.editview;
|
390 | 397 |
|
|
0 commit comments