feedbackItem.tsx 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import ProjectAvatar from 'sentry/components/avatar/projectAvatar';
  4. import {CopyToClipboardButton} from 'sentry/components/copyToClipboardButton';
  5. import {DropdownMenu} from 'sentry/components/dropdownMenu';
  6. import ErrorBoundary from 'sentry/components/errorBoundary';
  7. import Section from 'sentry/components/feedback/feedbackItem/feedbackItemSection';
  8. import FeedbackItemUsername from 'sentry/components/feedback/feedbackItem/feedbackItemUsername';
  9. import FeedbackViewers from 'sentry/components/feedback/feedbackItem/feedbackViewers';
  10. import ReplaySection from 'sentry/components/feedback/feedbackItem/replaySection';
  11. import ObjectInspector from 'sentry/components/objectInspector';
  12. import PanelItem from 'sentry/components/panels/panelItem';
  13. import {Flex} from 'sentry/components/profiling/flex';
  14. import TextCopyInput from 'sentry/components/textCopyInput';
  15. import {IconChevron, IconEllipsis, IconJson, IconLink} from 'sentry/icons';
  16. import {t} from 'sentry/locale';
  17. import {space} from 'sentry/styles/space';
  18. import {Event} from 'sentry/types';
  19. import {getShortEventId} from 'sentry/utils/events';
  20. import type {HydratedFeedbackItem} from 'sentry/utils/feedback/item/types';
  21. import useOrganization from 'sentry/utils/useOrganization';
  22. interface Props {
  23. eventData: Event | undefined;
  24. feedbackItem: HydratedFeedbackItem;
  25. }
  26. export default function FeedbackItem({feedbackItem, eventData}: Props) {
  27. const organization = useOrganization();
  28. return (
  29. <Fragment>
  30. <HeaderPanelItem>
  31. <Flex gap={space(2)} justify="space-between">
  32. <Flex column>
  33. <Flex align="center" gap={space(0.5)}>
  34. <FeedbackItemUsername feedbackItem={feedbackItem} detailDisplay />
  35. {feedbackItem.metadata.contact_email ? (
  36. <CopyToClipboardButton
  37. size="xs"
  38. iconSize="xs"
  39. text={feedbackItem.metadata.contact_email}
  40. />
  41. ) : null}
  42. </Flex>
  43. <Flex gap={space(1)}>
  44. <Flex align="center" gap={space(0.5)}>
  45. <ProjectAvatar
  46. project={feedbackItem.project}
  47. size={12}
  48. title={feedbackItem.project.slug}
  49. />
  50. {feedbackItem.project.slug}
  51. </Flex>
  52. <Flex align="center" gap={space(1)}>
  53. <IconChevron direction="right" size="xs" />
  54. <Flex>{getShortEventId(feedbackItem.feedback_id)}</Flex>
  55. </Flex>
  56. </Flex>
  57. </Flex>
  58. <Flex gap={space(1)} align="center">
  59. <ErrorBoundary mini>
  60. <FeedbackViewers feedbackItem={feedbackItem} />
  61. </ErrorBoundary>
  62. <ErrorBoundary mini>
  63. <DropdownMenu
  64. position="bottom-end"
  65. triggerLabel="Unresolved"
  66. triggerProps={{
  67. 'aria-label': t('Resolve or Archive Menu'),
  68. showChevron: true,
  69. size: 'xs',
  70. }}
  71. items={[
  72. {
  73. key: 'resolve',
  74. label: t('Resolve'),
  75. onAction: () => {},
  76. },
  77. {
  78. key: 'archive',
  79. label: t('Archive'),
  80. onAction: () => {},
  81. },
  82. ]}
  83. />
  84. </ErrorBoundary>
  85. <ErrorBoundary mini>
  86. <DropdownMenu
  87. position="bottom-end"
  88. triggerProps={{
  89. 'aria-label': t('Read or Delete Menu'),
  90. icon: <IconEllipsis size="xs" />,
  91. showChevron: false,
  92. size: 'xs',
  93. }}
  94. items={[
  95. {
  96. key: 'mark read',
  97. label: t('Mark as read'),
  98. onAction: () => {},
  99. },
  100. {
  101. key: 'mark unread',
  102. label: t('Mark as unread'),
  103. onAction: () => {},
  104. },
  105. ]}
  106. />
  107. </ErrorBoundary>
  108. </Flex>
  109. </Flex>
  110. </HeaderPanelItem>
  111. <OverflowPanelItem>
  112. <Section title={t('Description')}>
  113. <Blockquote>
  114. <pre>{feedbackItem.metadata.message}</pre>
  115. </Blockquote>
  116. </Section>
  117. <Section icon={<IconLink size="xs" />} title={t('Url')}>
  118. <ErrorBoundary mini>
  119. <TextCopyInput size="sm">{'TODO'}</TextCopyInput>
  120. </ErrorBoundary>
  121. </Section>
  122. {feedbackItem.replay_id ? (
  123. <ReplaySection organization={organization} replayId={feedbackItem.replay_id} />
  124. ) : null}
  125. {/* <TagsSection tags={feedbackItem.tags} /> */}
  126. <Section icon={<IconJson size="xs" />} title={t('Raw Issue Data')}>
  127. <ObjectInspector
  128. data={feedbackItem}
  129. expandLevel={3}
  130. theme={{
  131. TREENODE_FONT_SIZE: '0.7rem',
  132. ARROW_FONT_SIZE: '0.5rem',
  133. }}
  134. />
  135. </Section>
  136. <Section icon={<IconJson size="xs" />} title={t('Raw Event Data')}>
  137. <ObjectInspector
  138. data={eventData}
  139. expandLevel={3}
  140. theme={{
  141. TREENODE_FONT_SIZE: '0.7rem',
  142. ARROW_FONT_SIZE: '0.5rem',
  143. }}
  144. />
  145. </Section>
  146. </OverflowPanelItem>
  147. </Fragment>
  148. );
  149. }
  150. const HeaderPanelItem = styled(PanelItem)`
  151. display: grid;
  152. padding: ${space(1)} ${space(2)};
  153. `;
  154. const OverflowPanelItem = styled(PanelItem)`
  155. overflow: scroll;
  156. flex-direction: column;
  157. flex-grow: 1;
  158. gap: ${space(3)};
  159. `;
  160. const Blockquote = styled('blockquote')`
  161. margin: 0 ${space(4)};
  162. position: relative;
  163. &::before {
  164. position: absolute;
  165. color: ${p => p.theme.purple300};
  166. content: '❝';
  167. font-size: ${space(4)};
  168. left: -${space(4)};
  169. top: -0.4rem;
  170. }
  171. &::after {
  172. position: absolute;
  173. border: 1px solid ${p => p.theme.purple300};
  174. bottom: 0;
  175. content: '';
  176. left: -${space(1)};
  177. top: 0;
  178. }
  179. & > pre {
  180. margin: 0;
  181. background: none;
  182. font-family: inherit;
  183. font-size: ${p => p.theme.fontSizeMedium};
  184. line-height: 1.6;
  185. padding: 0;
  186. word-break: break-word;
  187. }
  188. `;