Skip to content

Commit 0c2d5d4

Browse files
SpikatrixGurinderRawala
authored andcommitted
Add fnLoader in grafana instead of prop from parent mfe (#83)
1 parent 6d861cb commit 0c2d5d4

File tree

6 files changed

+61
-11
lines changed

6 files changed

+61
-11
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Box, Typography, type BoxProps } from '@mui/material';
2+
import Lottie, { type LottieComponentProps } from 'lottie-react';
3+
import React, { type ReactNode, type FC, type HTMLAttributes } from 'react';
4+
5+
import logoUrl from './fn-logo.svg';
6+
import logoLoader from './fn-lottie-loader.json';
7+
8+
export type FnLoaderProps = {
9+
outerContainerProps?: Omit<BoxProps, 'children'>;
10+
innerContainerProps?: Omit<BoxProps, 'children'>;
11+
lottieProps?: LottieComponentProps;
12+
imageProps?: HTMLAttributes<HTMLImageElement>;
13+
text?: ReactNode;
14+
};
15+
16+
export const FnLoader: FC<FnLoaderProps> = ({
17+
outerContainerProps,
18+
innerContainerProps,
19+
lottieProps,
20+
imageProps,
21+
text,
22+
}) => (
23+
<Box
24+
display="flex"
25+
justifyContent="center"
26+
alignItems="center"
27+
flexDirection="column"
28+
paddingTop="150px"
29+
{...outerContainerProps}
30+
>
31+
<img src={logoUrl} alt={'FluxNinja logo'} style={{ transform: 'scale(4)' }} {...imageProps} />
32+
<Box marginTop="100px" {...innerContainerProps}>
33+
<Lottie
34+
animationData={logoLoader}
35+
aria-label="Loading..."
36+
style={{ maxWidth: '150px', margin: '0 auto' }}
37+
{...lottieProps}
38+
/>
39+
</Box>
40+
{typeof text === 'string' ? <Typography>{text}</Typography> : text || null}
41+
</Box>
42+
);
Lines changed: 9 additions & 0 deletions
Loading

public/app/features/dashboard/components/DashboardLoading/fn-lottie-loader.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

public/app/features/dashboard/containers/DashboardPage.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { findTemplateVarChanges } from '../../variables/utils';
3333
import { AddWidgetModal } from '../components/AddWidgetModal/AddWidgetModal';
3434
import { DashNav } from '../components/DashNav';
3535
import { DashboardFailed } from '../components/DashboardLoading/DashboardFailed';
36-
import { DashboardLoading } from '../components/DashboardLoading/DashboardLoading';
36+
import { FnLoader } from '../components/DashboardLoading/FnLoader';
3737
import { DashboardPrompt } from '../components/DashboardPrompt/DashboardPrompt';
3838
import { DashboardSettings } from '../components/DashboardSettings';
3939
import { PanelInspector } from '../components/Inspector/PanelInspector';
@@ -93,8 +93,7 @@ type OwnProps = {
9393
isPublic?: boolean;
9494
controlsContainer?: string | null;
9595
version?: FNDashboardProps['version'];
96-
fnLoader?: FNDashboardProps['fnLoader'];
97-
isLoading?: FNDashboardProps['isLoading']
96+
isLoading?: FNDashboardProps['isLoading'];
9897
};
9998

10099
export type DashboardPageProps = OwnProps &
@@ -402,17 +401,18 @@ export class UnthemedDashboardPage extends PureComponent<Props, State> {
402401
};
403402

404403
render() {
405-
const { dashboard, initError, queryParams, isPublic, FNDashboard, fnLoader, isLoading = noop } = this.props;
404+
const { dashboard, initError, queryParams, isPublic, FNDashboard, isLoading = noop } = this.props;
406405
const { editPanel, viewPanel, updateScrollTop, pageNav, sectionNav } = this.state;
407406
const kioskMode = FNDashboard ? KioskMode.FN : !isPublic ? getKioskMode(this.props.queryParams) : KioskMode.Full;
408407

409408
if (!dashboard || isEmpty(queryParams)) {
410-
isLoading(true)
409+
isLoading(true);
411410

412-
return isUndefined(fnLoader) ? <DashboardLoading initPhase={this.props.initPhase} />: <>{fnLoader}</>;
411+
// return isUndefined(fnLoader) ? <DashboardLoading initPhase={this.props.initPhase} />: <>{fnLoader}</>;
412+
return <FnLoader />;
413413
}
414414

415-
isLoading(false)
415+
isLoading(false);
416416

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

public/app/fn-app/fn-dashboard-page/render-fn-dashboard.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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, isLoading } = props;
30+
const { queryParams, controlsContainer, setErrors, hiddenVariables, isLoading } = props;
3131

3232
const firstError = useSelector((state: StoreState) => {
3333
const { appNotifications } = state;
@@ -66,10 +66,9 @@ export const RenderFNDashboard: FC<FNDashboardProps> = (props) => {
6666
queryParams,
6767
hiddenVariables,
6868
controlsContainer,
69-
fnLoader,
7069
isLoading
7170
}),
72-
[controlsContainer, fnLoader, hiddenVariables, isLoading, props, queryParams]
71+
[controlsContainer, hiddenVariables, isLoading, props, queryParams]
7372
);
7473

7574
return <DashboardPage {...dashboardPageProps} />;

public/app/fn-app/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export interface FNDashboardProps {
2626
mode: GrafanaThemeType.Dark | GrafanaThemeType.Light;
2727
queryParams: ParsedQuery<string>;
2828
fnError?: ReactNode;
29-
fnLoader?: ReactNode;
3029
pageTitle?: string;
3130
controlsContainer: string;
3231
isLoading: (isLoading: boolean) => void;

0 commit comments

Comments
 (0)