RuleDetailsExpression.tsx 927 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { css, cx } from '@emotion/css';
  2. import React from 'react';
  3. import { CombinedRule, RulesSource } from 'app/types/unified-alerting';
  4. import { isCloudRulesSource } from '../../utils/datasource';
  5. import { DetailsField } from '../DetailsField';
  6. import { Expression } from '../Expression';
  7. type Props = {
  8. rule: CombinedRule;
  9. rulesSource: RulesSource;
  10. annotations: Array<[string, string]>;
  11. };
  12. export function RuleDetailsExpression(props: Props): JSX.Element | null {
  13. const { annotations, rulesSource, rule } = props;
  14. const styles = getStyles();
  15. if (!isCloudRulesSource(rulesSource)) {
  16. return null;
  17. }
  18. return (
  19. <DetailsField label="Expression" horizontal={true} className={cx({ [styles.exprRow]: !!annotations.length })}>
  20. <Expression expression={rule.query} rulesSource={rulesSource} />
  21. </DetailsField>
  22. );
  23. }
  24. const getStyles = () => ({
  25. exprRow: css`
  26. margin-bottom: 46px;
  27. `,
  28. });