userFeedbackBadge.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import {LinkButton} from 'sentry/components/button';
  4. import {IconMegaphone} from 'sentry/icons';
  5. import {tn} from 'sentry/locale';
  6. import type {Group} from 'sentry/types/group';
  7. import type {Project} from 'sentry/types/project';
  8. import {getConfigForIssueType} from 'sentry/utils/issueTypeConfig';
  9. import {useLocation} from 'sentry/utils/useLocation';
  10. import {Divider} from 'sentry/views/issueDetails/divider';
  11. import {Tab, TabPaths} from 'sentry/views/issueDetails/types';
  12. import {useGroupDetailsRoute} from 'sentry/views/issueDetails/useGroupDetailsRoute';
  13. export function UserFeedbackBadge({group, project}: {group: Group; project: Project}) {
  14. const {baseUrl} = useGroupDetailsRoute();
  15. const location = useLocation();
  16. const issueTypeConfig = getConfigForIssueType(group, project);
  17. if (!issueTypeConfig.userFeedback.enabled || group.userReportCount <= 0) {
  18. return null;
  19. }
  20. return (
  21. <Fragment>
  22. <Divider />
  23. <UserFeedbackButton
  24. type="button"
  25. priority="link"
  26. size="zero"
  27. icon={<IconMegaphone size="xs" />}
  28. to={{
  29. pathname: `${baseUrl}${TabPaths[Tab.USER_FEEDBACK]}`,
  30. query: location.query,
  31. replace: true,
  32. }}
  33. >
  34. {tn('%s User Report', '%s User Reports', group.userReportCount)}
  35. </UserFeedbackButton>
  36. </Fragment>
  37. );
  38. }
  39. export const UserFeedbackButton = styled(LinkButton)`
  40. color: ${p => p.theme.gray300};
  41. text-decoration: underline;
  42. text-decoration-style: dotted;
  43. `;