issues.tsx 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. import styled from '@emotion/styled';
  2. import ActorAvatar from 'sentry/components/avatar/actorAvatar';
  3. import Count from 'sentry/components/count';
  4. import EventOrGroupExtraDetails from 'sentry/components/eventOrGroupExtraDetails';
  5. import LoadingError from 'sentry/components/loadingError';
  6. import LoadingIndicator from 'sentry/components/loadingIndicator';
  7. import Panel from 'sentry/components/panels/panel';
  8. import PanelHeader from 'sentry/components/panels/panelHeader';
  9. import PanelItem from 'sentry/components/panels/panelItem';
  10. import {IconWrapper} from 'sentry/components/sidebarSection';
  11. import GroupChart from 'sentry/components/stream/groupChart';
  12. import {IconUser} from 'sentry/icons';
  13. import {t, tct, tn} from 'sentry/locale';
  14. import {space} from 'sentry/styles/space';
  15. import type {Group, Organization} from 'sentry/types';
  16. import type {TraceErrorOrIssue} from 'sentry/utils/performance/quickTrace/types';
  17. import {useApiQuery} from 'sentry/utils/queryClient';
  18. import type {
  19. TraceTree,
  20. TraceTreeNode,
  21. } from 'sentry/views/performance/newTraceDetails/traceTree';
  22. import {IssueSummary} from './issueSummary';
  23. type IssueProps = {
  24. issue: TraceErrorOrIssue;
  25. organization: Organization;
  26. };
  27. function Issue(props: IssueProps) {
  28. const {
  29. isLoading,
  30. data: fetchedIssue,
  31. isError,
  32. } = useApiQuery<Group>(
  33. [
  34. `/issues/${props.issue.issue_id}/`,
  35. {
  36. query: {
  37. collapse: 'release',
  38. expand: 'inbox',
  39. },
  40. },
  41. ],
  42. {
  43. staleTime: 2 * 60 * 1000,
  44. }
  45. );
  46. return isLoading ? (
  47. <StyledLoadingIndicatorWrapper>
  48. <LoadingIndicator size={24} mini />
  49. </StyledLoadingIndicatorWrapper>
  50. ) : fetchedIssue ? (
  51. <StyledPanelItem>
  52. <IssueSummaryWrapper>
  53. <IssueSummary
  54. data={fetchedIssue}
  55. organization={props.organization}
  56. event_id={props.issue.event_id}
  57. />
  58. <EventOrGroupExtraDetails data={fetchedIssue} />
  59. </IssueSummaryWrapper>
  60. <ChartWrapper>
  61. <GroupChart
  62. statsPeriod={'24h'}
  63. data={fetchedIssue}
  64. showSecondaryPoints
  65. showMarkLine
  66. />
  67. </ChartWrapper>
  68. <ColumnWrapper>
  69. <PrimaryCount
  70. value={fetchedIssue.filtered ? fetchedIssue.filtered.count : fetchedIssue.count}
  71. />
  72. </ColumnWrapper>
  73. <ColumnWrapper>
  74. <PrimaryCount
  75. value={
  76. fetchedIssue.filtered
  77. ? fetchedIssue.filtered.userCount
  78. : fetchedIssue.userCount
  79. }
  80. />
  81. </ColumnWrapper>
  82. <ColumnWrapper>
  83. {fetchedIssue.assignedTo ? (
  84. <ActorAvatar actor={fetchedIssue.assignedTo} hasTooltip size={24} />
  85. ) : (
  86. <StyledIconWrapper>
  87. <IconUser size="md" />
  88. </StyledIconWrapper>
  89. )}
  90. </ColumnWrapper>
  91. </StyledPanelItem>
  92. ) : isError ? (
  93. <LoadingError message={t('Failed to fetch issue')} />
  94. ) : null;
  95. }
  96. type IssueListProps = {
  97. issues: TraceErrorOrIssue[];
  98. node: TraceTreeNode<TraceTree.NodeValue>;
  99. organization: Organization;
  100. };
  101. export function IssueList({issues, node, organization}: IssueListProps) {
  102. if (!issues.length) {
  103. return null;
  104. }
  105. return (
  106. <StyledPanel>
  107. <IssueListHeader node={node} />
  108. {issues.map((issue, index) => (
  109. <Issue key={index} issue={issue} organization={organization} />
  110. ))}
  111. </StyledPanel>
  112. );
  113. }
  114. function IssueListHeader({node}: {node: TraceTreeNode<TraceTree.NodeValue>}) {
  115. const {errors, performance_issues} = node;
  116. return (
  117. <StyledPanelHeader disablePadding>
  118. <IssueHeading>
  119. {errors.length > 0 && performance_issues.length === 0
  120. ? tct('[count] [text]', {
  121. count: errors.length,
  122. text: tn('Error', 'Errors', errors.length),
  123. })
  124. : performance_issues.length > 0 && errors.length === 0
  125. ? tct('[count] [text]', {
  126. count: performance_issues.length,
  127. text: tn(
  128. 'Performance issue',
  129. 'Performance Issues',
  130. performance_issues.length
  131. ),
  132. })
  133. : tct(
  134. '[errors] [errorsText] and [performance_issues] [performanceIssuesText]',
  135. {
  136. errors: errors.length,
  137. performance_issues: performance_issues.length,
  138. errorsText: tn('Error', 'Errors', errors.length),
  139. performanceIssuesText: tn(
  140. 'performance issue',
  141. 'performance issues',
  142. performance_issues.length
  143. ),
  144. }
  145. )}
  146. </IssueHeading>
  147. <GraphHeading>{t('Graph')}</GraphHeading>
  148. <Heading>{t('Events')}</Heading>
  149. <UsersHeading>{t('Users')}</UsersHeading>
  150. <Heading>{t('Assignee')}</Heading>
  151. </StyledPanelHeader>
  152. );
  153. }
  154. const Heading = styled('div')`
  155. display: flex;
  156. align-self: center;
  157. margin: 0 ${space(2)};
  158. width: 60px;
  159. color: ${p => p.theme.subText};
  160. `;
  161. const IssueHeading = styled(Heading)`
  162. flex: 1;
  163. width: 66.66%;
  164. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  165. width: 50%;
  166. }
  167. `;
  168. const GraphHeading = styled(Heading)`
  169. width: 160px;
  170. display: flex;
  171. justify-content: center;
  172. `;
  173. const UsersHeading = styled(Heading)`
  174. display: flex;
  175. justify-content: center;
  176. `;
  177. const StyledPanel = styled(Panel)`
  178. margin-bottom: 0;
  179. border: 1px solid ${p => p.theme.red200};
  180. `;
  181. const StyledPanelHeader = styled(PanelHeader)`
  182. padding-top: ${space(1)};
  183. padding-bottom: ${space(1)};
  184. border-bottom: 1px solid ${p => p.theme.red200};
  185. `;
  186. const StyledLoadingIndicatorWrapper = styled('div')`
  187. display: flex;
  188. justify-content: center;
  189. width: 100%;
  190. padding: ${space(2)} 0;
  191. height: 84px;
  192. `;
  193. const StyledIconWrapper = styled(IconWrapper)`
  194. margin: 0;
  195. `;
  196. const IssueSummaryWrapper = styled('div')`
  197. overflow: hidden;
  198. flex: 1;
  199. width: 66.66%;
  200. @media (min-width: ${p => p.theme.breakpoints.medium}) {
  201. width: 50%;
  202. }
  203. `;
  204. const ChartWrapper = styled('div')`
  205. width: 200px;
  206. align-self: center;
  207. `;
  208. const ColumnWrapper = styled('div')`
  209. display: flex;
  210. justify-content: flex-end;
  211. align-self: center;
  212. width: 60px;
  213. margin: 0 ${space(2)};
  214. `;
  215. const PrimaryCount = styled(Count)`
  216. font-size: ${p => p.theme.fontSizeLarge};
  217. font-variant-numeric: tabular-nums;
  218. `;
  219. const StyledPanelItem = styled(PanelItem)`
  220. padding-top: ${space(1)};
  221. padding-bottom: ${space(1)};
  222. height: 84px;
  223. `;