PanelChrome: Simplify props and code a bit (#61595)

* PanelChrome: Simplify props and code a bit

* Don't set a default empty array for leftItems so we can know user has set it

* fix 'this' is undefined

* add storybook examples of statusMessage; remove SB examples of loadingState === Error; simplify loadingState checks in PanelChrome;

Co-authored-by: polinaboneva <polina.boneva@grafana.com>
This commit is contained in:
Torkel Ödegaard
2023-01-17 09:52:14 +01:00
committed by GitHub
parent 54fd1b634f
commit c1d3b59643
3 changed files with 50 additions and 62 deletions

View File

@@ -592,10 +592,11 @@ export class PanelStateWrapper extends PureComponent<Props, State> {
e.stopPropagation();
locationService.partial({ inspect: this.props.panel.id, inspectTab: tab });
};
onOpenErrorInspect(e: React.SyntheticEvent, tab: string) {
onOpenErrorInspect = (e: React.SyntheticEvent) => {
e.stopPropagation();
locationService.partial({ inspect: this.props.panel.id, inspectTab: tab });
}
locationService.partial({ inspect: this.props.panel.id, inspectTab: InspectTab.Error });
};
render() {
const { dashboard, panel, isViewing, isEditing, width, height, plugin } = this.props;
@@ -648,10 +649,8 @@ export class PanelStateWrapper extends PureComponent<Props, State> {
height={height}
title={title}
loadingState={data.state}
status={{
message: errorMessage,
onClick: (e: React.SyntheticEvent) => this.onOpenErrorInspect(e, InspectTab.Error),
}}
statusMessage={errorMessage}
statusMessageOnClick={this.onOpenErrorInspect}
description={!!panel.description ? this.onShowPanelDescription : undefined}
titleItems={titleItems}
menu={menu}