StatPanel: Fixes data link tooltip not showing for single value (#34934) (#34962)

(cherry picked from commit d9e9e4744d)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
This commit is contained in:
Grot (@grafanabot) 2021-05-31 03:31:18 -04:00 committed by GitHub
parent bf3ce22358
commit fdd80b1b4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,6 +59,8 @@ export interface Props extends Themeable2 {
text?: TextDisplayOptions;
/** Specify which text should be visible in the BigValue */
textMode?: BigValueTextMode;
/** If true disables the tooltip */
hasLinks?: boolean;
/**
* If part of a series of stat panes, this is the total number.
@ -73,7 +75,7 @@ export class BigValue extends PureComponent<Props> {
};
render() {
const { onClick, className } = this.props;
const { onClick, className, hasLinks } = this.props;
const layout = buildLayout(this.props);
const panelStyles = layout.getPanelStyles();
const valueAndTitleContainerStyles = layout.getValueAndTitleContainerStyles();
@ -81,8 +83,11 @@ export class BigValue extends PureComponent<Props> {
const titleStyles = layout.getTitleStyles();
const textValues = layout.textValues;
// When there is an outer data link this tooltip will override the outer native tooltip
const tooltip = hasLinks ? undefined : textValues.tooltip;
return (
<div className={className} style={panelStyles} onClick={onClick} title={textValues.tooltip}>
<div className={className} style={panelStyles} onClick={onClick} title={tooltip}>
<div style={valueAndTitleContainerStyles}>
{textValues.title && <div style={titleStyles}>{textValues.title}</div>}
<FormattedValueDisplay value={textValues} style={valueStyles} />