Error Handling: support errors and data in a response (#20169)

This commit is contained in:
Ryan McKinley
2019-11-05 15:20:04 -08:00
committed by GitHub
parent 7a3d1c0e4b
commit 92ab4d80f0
9 changed files with 68 additions and 13 deletions

View File

@@ -6,6 +6,7 @@ import { Tooltip, PopoverContent } from '@grafana/ui';
import { PanelModel } from 'app/features/dashboard/state/PanelModel';
import templateSrv from 'app/features/templating/template_srv';
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { getLocationSrv } from '@grafana/runtime';
enum InfoMode {
Error = 'Error',
@@ -68,11 +69,18 @@ export class PanelHeaderCorner extends Component<Props> {
);
};
renderCornerType(infoMode: InfoMode, content: PopoverContent) {
/**
* Open the Panel Inspector when we click on an error
*/
onClickError = () => {
getLocationSrv().update({ partial: true, query: { inspect: this.props.panel.id } });
};
renderCornerType(infoMode: InfoMode, content: PopoverContent, onClick?: () => void) {
const theme = infoMode === InfoMode.Error ? 'error' : 'info';
return (
<Tooltip content={content} placement="top-start" theme={theme}>
<div className={`panel-info-corner panel-info-corner--${infoMode.toLowerCase()}`}>
<div className={`panel-info-corner panel-info-corner--${infoMode.toLowerCase()}`} onClick={onClick}>
<i className="fa" />
<span className="panel-info-corner-inner" />
</div>
@@ -88,7 +96,7 @@ export class PanelHeaderCorner extends Component<Props> {
}
if (infoMode === InfoMode.Error) {
return this.renderCornerType(infoMode, this.props.error);
return this.renderCornerType(infoMode, this.props.error, this.onClickError);
}
if (infoMode === InfoMode.Info || infoMode === InfoMode.Links) {