|
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, GrafanaTheme2 } from '@grafana/data';
|
@@ -44,6 +44,8 @@ import { getTimeSrv } from '../services/TimeSrv';
|
44 | 44 | import { explicitlyControlledMigrationPanels, autoMigrateAngular } from '../state/PanelModel';
|
45 | 45 | import { cleanUpDashboardAndVariables } from '../state/actions';
|
46 | 46 | import { initDashboard } from '../state/initDashboard';
|
| 47 | +import { FNDashboardProps } from 'app/fn-app/types'; |
| 48 | +import { isUndefined, isEmpty, noop } from 'lodash'; |
47 | 49 |
|
48 | 50 | import { DashboardPageRouteParams, DashboardPageRouteSearchParams } from './types';
|
49 | 51 |
|
@@ -90,7 +92,8 @@ const connector = connect(mapStateToProps, mapDispatchToProps);
|
90 | 92 | type OwnProps = {
|
91 | 93 | isPublic?: boolean;
|
92 | 94 | controlsContainer?: string | null;
|
93 |
| - fnLoader?: ReactNode; |
| 95 | + fnLoader?: FNDashboardProps['fnLoader']; |
| 96 | + isLoading?: FNDashboardProps['isLoading'] |
94 | 97 | };
|
95 | 98 |
|
96 | 99 | export type DashboardPageProps = OwnProps &
|
@@ -396,14 +399,18 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
|
396 | 399 | };
|
397 | 400 |
|
398 | 401 | render() {
|
399 |
| - const { dashboard, initError, queryParams, isPublic, FNDashboard, fnLoader } = this.props; |
| 402 | + const { dashboard, initError, queryParams, isPublic, FNDashboard, fnLoader, isLoading = noop } = this.props; |
400 | 403 | const { editPanel, viewPanel, updateScrollTop, pageNav, sectionNav } = this.state;
|
401 | 404 | const kioskMode = FNDashboard ? KioskMode.FN : !isPublic ? getKioskMode(this.props.queryParams) : KioskMode.Full;
|
402 | 405 |
|
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}</>; |
405 | 410 | }
|
406 | 411 |
|
| 412 | + isLoading(false) |
| 413 | + |
407 | 414 | const inspectPanel = this.getInspectPanel();
|
408 | 415 | const showSubMenu = !editPanel && !this.props.queryParams.editview;
|
409 | 416 |
|
|
0 commit comments