userFeedback.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import styled from '@emotion/styled';
  2. import ActivityAuthor from 'sentry/components/activity/author';
  3. import ActivityItem from 'sentry/components/activity/item';
  4. import Clipboard from 'sentry/components/clipboard';
  5. import Link from 'sentry/components/links/link';
  6. import {IconCopy} from 'sentry/icons';
  7. import {t} from 'sentry/locale';
  8. import space from 'sentry/styles/space';
  9. import {UserReport} from 'sentry/types';
  10. import {escape, nl2br} from 'sentry/utils';
  11. type Props = {
  12. issueId: string;
  13. orgId: string;
  14. report: UserReport;
  15. className?: string;
  16. };
  17. export function EventUserFeedback({className, report, orgId, issueId}: Props) {
  18. const user = report.user || {
  19. name: report.name,
  20. email: report.email,
  21. id: '',
  22. username: '',
  23. ip_address: '',
  24. };
  25. return (
  26. <div className={className}>
  27. <ActivityItem
  28. date={report.dateCreated}
  29. author={{type: 'user', user}}
  30. header={
  31. <div>
  32. <ActivityAuthor>{report.name}</ActivityAuthor>
  33. <Clipboard value={report.email}>
  34. <Email>
  35. {report.email}
  36. <StyledIconCopy size="xs" />
  37. </Email>
  38. </Clipboard>
  39. {report.eventID && (
  40. <ViewEventLink
  41. to={`/organizations/${orgId}/issues/${issueId}/events/${report.eventID}/?referrer=user-feedback`}
  42. >
  43. {t('View event')}
  44. </ViewEventLink>
  45. )}
  46. </div>
  47. }
  48. >
  49. <p
  50. dangerouslySetInnerHTML={{
  51. __html: nl2br(escape(report.comments)),
  52. }}
  53. />
  54. </ActivityItem>
  55. </div>
  56. );
  57. }
  58. const Email = styled('span')`
  59. font-size: ${p => p.theme.fontSizeSmall};
  60. font-weight: normal;
  61. cursor: pointer;
  62. margin-left: ${space(1)};
  63. `;
  64. const ViewEventLink = styled(Link)`
  65. font-weight: 300;
  66. margin-left: ${space(1)};
  67. font-size: 0.9em;
  68. `;
  69. const StyledIconCopy = styled(IconCopy)`
  70. margin-left: ${space(1)};
  71. `;