FeedbackLink.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { css } from '@emotion/css';
  2. import React from 'react';
  3. import { GrafanaTheme2 } from '@grafana/data';
  4. import { Stack } from '@grafana/experimental';
  5. import { config, reportInteraction } from '@grafana/runtime';
  6. import { Icon, useStyles2 } from '@grafana/ui';
  7. export interface Props {
  8. feedbackUrl?: string;
  9. }
  10. export function FeedbackLink({ feedbackUrl }: Props) {
  11. const styles = useStyles2(getStyles);
  12. if (!config.feedbackLinksEnabled) {
  13. return null;
  14. }
  15. return (
  16. <Stack gap={1}>
  17. <a
  18. href={feedbackUrl}
  19. className={styles.link}
  20. title="This query builder is new, please let us know how we can improve it"
  21. target="_blank"
  22. rel="noreferrer noopener"
  23. onClick={() =>
  24. reportInteraction('grafana_feedback_link_clicked', {
  25. link: feedbackUrl,
  26. })
  27. }
  28. >
  29. <Icon name="comment-alt-message" /> Give feedback
  30. </a>
  31. </Stack>
  32. );
  33. }
  34. function getStyles(theme: GrafanaTheme2) {
  35. return {
  36. link: css({
  37. color: theme.colors.text.secondary,
  38. fontSize: theme.typography.bodySmall.fontSize,
  39. ':hover': {
  40. color: theme.colors.text.link,
  41. },
  42. }),
  43. };
  44. }