Skip to content

8225 Fix missing grafana loader #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions public/app/features/dashboard/containers/DashboardPage.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 &
Expand Down Expand Up @@ -377,14 +380,18 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
}

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}</> : <DashboardLoading initPhase={this.props.initPhase} />;
if (!dashboard || isEmpty(queryParams)) {
isLoading(true)

return isUndefined(fnLoader) ? <DashboardLoading initPhase={this.props.initPhase} />: <>{fnLoader}</>;
}

isLoading(false)

const inspectPanel = this.getInspectPanel();
const showSubMenu = !editPanel && !this.props.queryParams.editview;

Expand Down
7 changes: 4 additions & 3 deletions public/app/fn-app/fn-dashboard-page/render-fn-dashboard.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -27,7 +27,7 @@ const DEFAULT_DASHBOARD_PAGE_PROPS: Pick<DashboardPageProps, 'history' | 'route'
};

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

const firstError = useSelector((state: StoreState) => {
const { appNotifications } = state;
Expand Down Expand Up @@ -67,9 +67,10 @@ export const RenderFNDashboard: FC<FNDashboardProps> = (props) => {
hiddenVariables,
controlsContainer,
fnLoader,
isLoading
}),
[controlsContainer, fnLoader, hiddenVariables, props, queryParams]
);

return isEmpty(queryParams || {}) ? <>{fnLoader}</> : <DashboardPage {...dashboardPageProps} />;
return <DashboardPage {...dashboardPageProps} />;
};