feedbackItem.tsx 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 useDeleteFeedback from 'sentry/components/feedback/feedbackItem/useDeleteFeedback';
  12. import ObjectInspector from 'sentry/components/objectInspector';
  13. import PanelItem from 'sentry/components/panels/panelItem';
  14. import {Flex} from 'sentry/components/profiling/flex';
  15. import TextCopyInput from 'sentry/components/textCopyInput';
  16. import {IconChevron, IconEllipsis, IconJson, IconLink} from 'sentry/icons';
  17. import {t} from 'sentry/locale';
  18. import {space} from 'sentry/styles/space';
  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. feedbackItem: HydratedFeedbackItem;
  24. }
  25. export default function FeedbackItem({feedbackItem}: Props) {
  26. const organization = useOrganization();
  27. const {onDelete} = useDeleteFeedback({feedbackItem});
  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. key: 'delete',
  107. label: t('Delete'),
  108. onAction: onDelete,
  109. },
  110. ]}
  111. />
  112. </ErrorBoundary>
  113. </Flex>
  114. </Flex>
  115. </HeaderPanelItem>
  116. <OverflowPanelItem>
  117. <Section title={t('Description')}>
  118. <Blockquote>
  119. <pre>{feedbackItem.metadata.message}</pre>
  120. </Blockquote>
  121. </Section>
  122. <Section icon={<IconLink size="xs" />} title={t('Url')}>
  123. <ErrorBoundary mini>
  124. <TextCopyInput size="sm">{'TODO'}</TextCopyInput>
  125. </ErrorBoundary>
  126. </Section>
  127. {feedbackItem.replay_id ? (
  128. <ReplaySection organization={organization} replayId={feedbackItem.replay_id} />
  129. ) : null}
  130. {/* <TagsSection tags={feedbackItem.tags} /> */}
  131. <Section icon={<IconJson size="xs" />} title={t('Raw')}>
  132. <ObjectInspector
  133. data={feedbackItem}
  134. expandLevel={3}
  135. theme={{
  136. TREENODE_FONT_SIZE: '0.7rem',
  137. ARROW_FONT_SIZE: '0.5rem',
  138. }}
  139. />
  140. </Section>
  141. </OverflowPanelItem>
  142. </Fragment>
  143. );
  144. }
  145. const HeaderPanelItem = styled(PanelItem)`
  146. display: grid;
  147. padding: ${space(1)} ${space(2)};
  148. `;
  149. const OverflowPanelItem = styled(PanelItem)`
  150. overflow: scroll;
  151. flex-direction: column;
  152. flex-grow: 1;
  153. gap: ${space(3)};
  154. `;
  155. const Blockquote = styled('blockquote')`
  156. margin: 0 ${space(4)};
  157. position: relative;
  158. &::before {
  159. position: absolute;
  160. color: ${p => p.theme.purple300};
  161. content: '❝';
  162. font-size: ${space(4)};
  163. left: -${space(4)};
  164. top: -0.4rem;
  165. }
  166. &::after {
  167. position: absolute;
  168. border: 1px solid ${p => p.theme.purple300};
  169. bottom: 0;
  170. content: '';
  171. left: -${space(1)};
  172. top: 0;
  173. }
  174. & > pre {
  175. margin: 0;
  176. background: none;
  177. font-family: inherit;
  178. font-size: ${p => p.theme.fontSizeMedium};
  179. line-height: 1.6;
  180. padding: 0;
  181. word-break: break-word;
  182. }
  183. `;