userFeedback.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. <StyledActivityItem
  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. </StyledActivityItem>
  55. </div>
  56. );
  57. }
  58. const StyledActivityItem = styled(ActivityItem)`
  59. margin-bottom: 0;
  60. `;
  61. const Email = styled('span')`
  62. font-size: ${p => p.theme.fontSizeSmall};
  63. font-weight: normal;
  64. cursor: pointer;
  65. margin-left: ${space(1)};
  66. `;
  67. const ViewEventLink = styled(Link)`
  68. font-weight: 300;
  69. margin-left: ${space(1)};
  70. font-size: 0.9em;
  71. `;
  72. const StyledIconCopy = styled(IconCopy)`
  73. margin-left: ${space(1)};
  74. `;