userFeedback.tsx 2.1 KB

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