mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Error Handling: support errors and data in a response (#20169)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user