Alerting: Show full preview value in tooltip (#42445)

* use JSONCell for value

* remove console log and usememo
pull/42460/head
Peter Holmberg 4 years ago committed by GitHub
parent 8d6831f21f
commit 8bf6011450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      public/app/features/alerting/unified/components/rule-editor/PreviewRule.tsx
  2. 23
      public/app/features/alerting/unified/components/rule-editor/PreviewRuleResult.tsx

@ -94,6 +94,7 @@ function getStyles(theme: GrafanaTheme2) {
return {
container: css`
margin-top: ${theme.spacing(2)};
max-width: ${theme.breakpoints.values.xxl}px;
`,
};
}

@ -1,9 +1,9 @@
import React from 'react';
import { css } from '@emotion/css';
import AutoSizer from 'react-virtualized-auto-sizer';
import { useStyles2 } from '@grafana/ui';
import { TableCellDisplayMode, useStyles2 } from '@grafana/ui';
import { PanelRenderer } from '@grafana/runtime';
import { GrafanaTheme2, LoadingState } from '@grafana/data';
import { FieldConfigSource, FieldMatcherID, GrafanaTheme2, LoadingState } from '@grafana/data';
import { PreviewRuleResponse } from '../../types/preview';
import { RuleFormType } from '../../types/rule-form';
import { messageFromError } from '../../utils/redux';
@ -15,6 +15,15 @@ type Props = {
export function PreviewRuleResult(props: Props): React.ReactElement | null {
const { preview } = props;
const styles = useStyles2(getStyles);
const fieldConfig: FieldConfigSource = {
defaults: {},
overrides: [
{
matcher: { id: FieldMatcherID.byName, options: 'Info' },
properties: [{ id: 'custom.displayMode', value: TableCellDisplayMode.JSONView }],
},
],
};
if (!preview) {
return null;
@ -37,7 +46,6 @@ export function PreviewRuleResult(props: Props): React.ReactElement | null {
</div>
);
}
return (
<div className={styles.container}>
<span>
@ -48,7 +56,14 @@ export function PreviewRuleResult(props: Props): React.ReactElement | null {
<AutoSizer>
{({ width, height }) => (
<div style={{ width: `${width}px`, height: `${height}px` }}>
<PanelRenderer title="" width={width} height={height} pluginId="table" data={data} />
<PanelRenderer
title=""
width={width}
height={height}
pluginId="table"
data={data}
fieldConfig={fieldConfig}
/>
</div>
)}
</AutoSizer>

Loading…
Cancel
Save