ErrorContainer.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import React, { FunctionComponent } from 'react';
  2. import { DataQueryError } from '@grafana/ui';
  3. import { FadeIn } from 'app/core/components/Animations/FadeIn';
  4. import { getFirstQueryErrorWithoutRefId, getValueWithRefId } from 'app/core/utils/explore';
  5. interface Props {
  6. queryErrors: DataQueryError[];
  7. }
  8. export const ErrorContainer: FunctionComponent<Props> = props => {
  9. const { queryErrors } = props;
  10. const refId = getValueWithRefId(queryErrors);
  11. const queryError = refId ? null : getFirstQueryErrorWithoutRefId(queryErrors);
  12. const showError = queryError ? true : false;
  13. const duration = showError ? 100 : 10;
  14. const message = queryError ? queryError.message : null;
  15. return (
  16. <FadeIn in={showError} duration={duration}>
  17. <div className="alert-container">
  18. <div className="alert-error alert">
  19. <div className="alert-icon">
  20. <i className="fa fa-exclamation-triangle" />
  21. </div>
  22. <div className="alert-body">
  23. <div className="alert-title">{message}</div>
  24. </div>
  25. </div>
  26. </div>
  27. </FadeIn>
  28. );
  29. };