mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import { css, keyframes } from '@emotion/css';
|
|
import React from 'react';
|
|
|
|
import { GrafanaTheme } from '@grafana/data';
|
|
import { locationService } from '@grafana/runtime';
|
|
import { Button, HorizontalGroup, Spinner, useStyles, VerticalGroup } from '@grafana/ui';
|
|
import { DashboardInitPhase } from 'app/types';
|
|
|
|
export interface Props {
|
|
initPhase: DashboardInitPhase;
|
|
}
|
|
|
|
export const DashboardLoading = ({ initPhase }: Props) => {
|
|
const styles = useStyles(getStyles);
|
|
const cancelVariables = () => {
|
|
locationService.push('/');
|
|
};
|
|
|
|
return (
|
|
<div className={styles.dashboardLoading}>
|
|
<div className={styles.dashboardLoadingText}>
|
|
<VerticalGroup spacing="md">
|
|
<HorizontalGroup align="center" justify="center" spacing="xs">
|
|
<Spinner inline={true} /> {initPhase}
|
|
</HorizontalGroup>{' '}
|
|
<HorizontalGroup align="center" justify="center">
|
|
<Button variant="secondary" size="md" icon="repeat" onClick={cancelVariables}>
|
|
Cancel loading dashboard
|
|
</Button>
|
|
</HorizontalGroup>
|
|
</VerticalGroup>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export const getStyles = (theme: GrafanaTheme) => {
|
|
// Amount of time we want to pass before we start showing loading spinner
|
|
const slowStartThreshold = '0.5s';
|
|
|
|
const invisibleToVisible = keyframes`
|
|
0% { opacity: 0%; }
|
|
100% { opacity: 100%; }
|
|
`;
|
|
|
|
return {
|
|
dashboardLoading: css`
|
|
height: 60vh;
|
|
display: flex;
|
|
opacity: 0%;
|
|
align-items: center;
|
|
justify-content: center;
|
|
animation: ${invisibleToVisible} 0s step-end ${slowStartThreshold} 1 normal forwards;
|
|
`,
|
|
dashboardLoadingText: css`
|
|
font-size: ${theme.typography.size.lg};
|
|
`,
|
|
};
|
|
};
|