2019-05-10 07:00:39 -05:00
|
|
|
import React, { FunctionComponent } from 'react';
|
2019-10-31 04:48:05 -05:00
|
|
|
import { DataQueryError } from '@grafana/data';
|
2020-04-12 15:20:02 -05:00
|
|
|
import { Icon } from '@grafana/ui';
|
2019-05-10 07:00:39 -05:00
|
|
|
import { FadeIn } from 'app/core/components/Animations/FadeIn';
|
|
|
|
|
2020-03-11 04:01:58 -05:00
|
|
|
export interface ErrorContainerProps {
|
|
|
|
queryError?: DataQueryError;
|
2019-05-10 07:00:39 -05:00
|
|
|
}
|
|
|
|
|
2021-01-20 00:59:48 -06:00
|
|
|
export const ErrorContainer: FunctionComponent<ErrorContainerProps> = (props) => {
|
2020-03-11 04:01:58 -05:00
|
|
|
const { queryError } = props;
|
2019-05-10 07:00:39 -05:00
|
|
|
const showError = queryError ? true : false;
|
|
|
|
const duration = showError ? 100 : 10;
|
2021-03-23 05:58:09 -05:00
|
|
|
const message = queryError?.message || queryError?.data?.message || 'Unknown error';
|
2019-05-10 07:00:39 -05:00
|
|
|
|
|
|
|
return (
|
|
|
|
<FadeIn in={showError} duration={duration}>
|
|
|
|
<div className="alert-container">
|
|
|
|
<div className="alert-error alert">
|
|
|
|
<div className="alert-icon">
|
2020-04-12 15:20:02 -05:00
|
|
|
<Icon name="exclamation-triangle" />
|
2019-05-10 07:00:39 -05:00
|
|
|
</div>
|
|
|
|
<div className="alert-body">
|
|
|
|
<div className="alert-title">{message}</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</FadeIn>
|
|
|
|
);
|
|
|
|
};
|