diff --git a/public/app/features/dashboard/containers/DashboardPage.tsx b/public/app/features/dashboard/containers/DashboardPage.tsx index 3951ea820162b..b4b7f36060d12 100644 --- a/public/app/features/dashboard/containers/DashboardPage.tsx +++ b/public/app/features/dashboard/containers/DashboardPage.tsx @@ -1,5 +1,5 @@ import { cx } from '@emotion/css'; -import React, { PureComponent, ReactNode } from 'react'; +import React, { PureComponent, } from 'react'; import { connect, ConnectedProps, MapDispatchToProps, MapStateToProps } from 'react-redux'; import { NavModel, NavModelItem, TimeRange, PageLayoutType, locationUtil } from '@grafana/data'; @@ -37,6 +37,8 @@ import { liveTimer } from '../dashgrid/liveTimer'; import { getTimeSrv } from '../services/TimeSrv'; import { cleanUpDashboardAndVariables } from '../state/actions'; import { initDashboard } from '../state/initDashboard'; +import { FNDashboardProps } from 'app/fn-app/types'; +import { isUndefined, isEmpty, noop } from 'lodash'; export interface DashboardPageRouteParams { uid?: string; @@ -100,7 +102,8 @@ const connector = connect(mapStateToProps, mapDispatchToProps); type OwnProps = { isPublic?: boolean; controlsContainer?: string | null; - fnLoader?: ReactNode; + fnLoader?: FNDashboardProps['fnLoader']; + isLoading?: FNDashboardProps['isLoading'] }; export type DashboardPageProps = OwnProps & @@ -377,14 +380,18 @@ export class UnthemedDashboardPage extends PureComponent { } render() { - const { dashboard, initError, queryParams, isPublic, FNDashboard, fnLoader } = this.props; + const { dashboard, initError, queryParams, isPublic, FNDashboard, fnLoader, isLoading = noop } = this.props; const { editPanel, viewPanel, updateScrollTop, pageNav, sectionNav } = this.state; const kioskMode = FNDashboard ? KioskMode.FN : !isPublic ? getKioskMode(this.props.queryParams) : KioskMode.Full; - if (!dashboard) { - return fnLoader ? <>{fnLoader} : ; + if (!dashboard || isEmpty(queryParams)) { + isLoading(true) + + return isUndefined(fnLoader) ? : <>{fnLoader}; } + isLoading(false) + const inspectPanel = this.getInspectPanel(); const showSubMenu = !editPanel && !this.props.queryParams.editview; diff --git a/public/app/fn-app/fn-dashboard-page/render-fn-dashboard.tsx b/public/app/fn-app/fn-dashboard-page/render-fn-dashboard.tsx index 739b698e741c3..7959f70d54de7 100644 --- a/public/app/fn-app/fn-dashboard-page/render-fn-dashboard.tsx +++ b/public/app/fn-app/fn-dashboard-page/render-fn-dashboard.tsx @@ -1,4 +1,4 @@ -import { merge, isEmpty, isFunction } from 'lodash'; +import { merge, isFunction } from 'lodash'; import React, { useEffect, FC, useMemo } from 'react'; import { locationService as locationSrv, HistoryWrapper } from '@grafana/runtime'; @@ -27,7 +27,7 @@ const DEFAULT_DASHBOARD_PAGE_PROPS: Pick = (props) => { - const { queryParams, controlsContainer, setErrors, fnLoader, hiddenVariables } = props; + const { queryParams, controlsContainer, setErrors, fnLoader, hiddenVariables, isLoading } = props; const firstError = useSelector((state: StoreState) => { const { appNotifications } = state; @@ -67,9 +67,10 @@ export const RenderFNDashboard: FC = (props) => { hiddenVariables, controlsContainer, fnLoader, + isLoading }), [controlsContainer, fnLoader, hiddenVariables, props, queryParams] ); - return isEmpty(queryParams || {}) ? <>{fnLoader} : ; + return ; };