grafana/public/app/features/alerting/components/PreviewInstancesTab.tsx
Peter Holmberg 9ffd88b103
AlertingNG: Refactor the query preview component (#31281)
* refactor to purecomponent

* use subscription in component

* correct onRunQueries

* move more things from render function

* fix issue with no queries

* pr feedback

* revert to FC

* redo some code layout, simplify if

* minor fixes after review
2021-03-15 10:17:21 +01:00

24 lines
712 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { FC } from 'react';
import { DataFrame } from '@grafana/data';
import { Button, Table } from '@grafana/ui';
import { EmptyState } from './EmptyState';
interface Props {
instances: DataFrame[];
width: number;
height: number;
onTest: () => void;
}
export const PreviewInstancesTab: FC<Props> = ({ instances, onTest, height, width }) => {
if (!instances.length) {
return (
<EmptyState title="You havent tested your alert yet.">
<div>In order to see your instances, you need to test your alert first.</div>
<Button onClick={onTest}>Test alert now</Button>
</EmptyState>
);
}
return <Table data={instances[0]} height={height} width={width} />;
};