PanelHeaderNotice.tsx 938 B

12345678910111213141516171819202122232425262728
  1. import React, { FC } from 'react';
  2. import { QueryResultMetaNotice } from '@grafana/data';
  3. import { Icon, Tooltip } from '@grafana/ui';
  4. interface Props {
  5. notice: QueryResultMetaNotice;
  6. onClick: (e: React.SyntheticEvent, tab: string) => void;
  7. }
  8. export const PanelHeaderNotice: FC<Props> = ({ notice, onClick }) => {
  9. const iconName =
  10. notice.severity === 'error' || notice.severity === 'warning' ? 'exclamation-triangle' : 'info-circle';
  11. return (
  12. <Tooltip content={notice.text} key={notice.severity}>
  13. {notice.inspect ? (
  14. <div className="panel-info-notice pointer" onClick={(e) => onClick(e, notice.inspect!)}>
  15. <Icon name={iconName} style={{ marginRight: '8px' }} />
  16. </div>
  17. ) : (
  18. <a className="panel-info-notice" href={notice.link} target="_blank" rel="noreferrer">
  19. <Icon name={iconName} style={{ marginRight: '8px' }} />
  20. </a>
  21. )}
  22. </Tooltip>
  23. );
  24. };