mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 00:25:46 -06:00
7c03cc83c6
feat: hide empty breakdown panels, improve loading status
41 lines
931 B
TypeScript
41 lines
931 B
TypeScript
import { css } from '@emotion/css';
|
|
import React, { ReactNode } from 'react';
|
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
import { LoadingPlaceholder, useStyles2 } from '@grafana/ui';
|
|
|
|
type Props = {
|
|
blockingMessage?: string;
|
|
isLoading?: boolean;
|
|
children?: ReactNode;
|
|
};
|
|
|
|
export function StatusWrapper({ blockingMessage, isLoading, children }: Props) {
|
|
const styles = useStyles2(getStyles);
|
|
|
|
if (isLoading && !blockingMessage) {
|
|
blockingMessage = 'Loading...';
|
|
}
|
|
|
|
if (isLoading) {
|
|
return <LoadingPlaceholder className={styles.statusMessage} text={blockingMessage} />;
|
|
}
|
|
|
|
if (!blockingMessage) {
|
|
return children;
|
|
}
|
|
|
|
return <div className={styles.statusMessage}>{blockingMessage}</div>;
|
|
}
|
|
|
|
function getStyles(theme: GrafanaTheme2) {
|
|
return {
|
|
statusMessage: css({
|
|
fontStyle: 'italic',
|
|
marginTop: theme.spacing(7),
|
|
textAlign: 'center',
|
|
width: '100%',
|
|
}),
|
|
};
|
|
}
|