mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 16:45:43 -06:00
* Remove getFirstNonQueryRowSpecificError * Move some error handling to separate component * Update public/app/features/explore/ErrorContainer.tsx Co-authored-by: Giordano Ricci <gio.ricci@grafana.com> * Add comments * More explicit expects * Update tests with proper expects Co-authored-by: Giordano Ricci <gio.ricci@grafana.com>
31 lines
974 B
TypeScript
31 lines
974 B
TypeScript
import React, { FunctionComponent } from 'react';
|
|
import { DataQueryError } from '@grafana/data';
|
|
import { Icon } from '@grafana/ui';
|
|
import { FadeIn } from 'app/core/components/Animations/FadeIn';
|
|
|
|
export interface ErrorContainerProps {
|
|
queryError?: DataQueryError;
|
|
}
|
|
|
|
export const ErrorContainer: FunctionComponent<ErrorContainerProps> = (props) => {
|
|
const { queryError } = props;
|
|
const showError = queryError ? true : false;
|
|
const duration = showError ? 100 : 10;
|
|
const message = queryError?.message || queryError?.data?.message || 'Unknown error';
|
|
|
|
return (
|
|
<FadeIn in={showError} duration={duration}>
|
|
<div className="alert-container">
|
|
<div className="alert-error alert">
|
|
<div className="alert-icon">
|
|
<Icon name="exclamation-triangle" />
|
|
</div>
|
|
<div className="alert-body">
|
|
<div className="alert-title">{message}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</FadeIn>
|
|
);
|
|
};
|