grafana/public/app/features/explore/ErrorContainer.tsx
Hugo Häggmark 6dbaa704bc
Explore: Align Explore with Dashboards and Panels (#16823)
* Wip: Removes queryTransactions from state

* Refactor: Adds back query failures

* Refactor: Moves error parsing to datasources

* Refactor: Adds back hinting for Prometheus

* Refactor: removed commented out code

* Refactor: Adds back QueryStatus

* Refactor: Adds scanning back to Explore

* Fix: Fixes prettier error

* Fix: Makes sure there is an error

* Merge: Merges with master

* Fix: Adds safeStringifyValue to error parsing

* Fix: Fixes table result calculations

* Refactor: Adds ErrorContainer and generic error handling in Explore

* Fix: Fixes so refIds remain consistent

* Refactor: Makes it possible to return result even when there are errors

* Fix: Fixes digest issue with Angular editors

* Refactor: Adds tests for explore utils

* Refactor: Breakes current behaviour of always returning a result even if Query fails

* Fix: Fixes Prettier error

* Fix: Adds back console.log for erroneous querys

* Refactor: Changes console.log to console.error
2019-05-10 14:00:39 +02:00

33 lines
1.1 KiB
TypeScript

import React, { FunctionComponent } from 'react';
import { DataQueryError } from '@grafana/ui';
import { FadeIn } from 'app/core/components/Animations/FadeIn';
import { getFirstQueryErrorWithoutRefId, getValueWithRefId } from 'app/core/utils/explore';
interface Props {
queryErrors: DataQueryError[];
}
export const ErrorContainer: FunctionComponent<Props> = props => {
const { queryErrors } = props;
const refId = getValueWithRefId(queryErrors);
const queryError = refId ? null : getFirstQueryErrorWithoutRefId(queryErrors);
const showError = queryError ? true : false;
const duration = showError ? 100 : 10;
const message = queryError ? queryError.message : null;
return (
<FadeIn in={showError} duration={duration}>
<div className="alert-container">
<div className="alert-error alert">
<div className="alert-icon">
<i className="fa fa-exclamation-triangle" />
</div>
<div className="alert-body">
<div className="alert-title">{message}</div>
</div>
</div>
</div>
</FadeIn>
);
};