userFeedbackBadge.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 {t, 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. aria-label={t("View this issues's feedback")}
  34. >
  35. {tn('%s User Report', '%s User Reports', group.userReportCount)}
  36. </UserFeedbackButton>
  37. </Fragment>
  38. );
  39. }
  40. export const UserFeedbackButton = styled(LinkButton)`
  41. color: ${p => p.theme.gray300};
  42. text-decoration: underline;
  43. text-decoration-style: dotted;
  44. `;