eventList.tsx 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. import {useState} from 'react';
  2. import {css, useTheme} from '@emotion/react';
  3. import styled from '@emotion/styled';
  4. import {LinkButton} from 'sentry/components/button';
  5. import ButtonBar from 'sentry/components/buttonBar';
  6. import {
  7. GridBodyCell,
  8. GridHead,
  9. GridHeadCell,
  10. GridResizer,
  11. GridRow,
  12. } from 'sentry/components/gridEditable/styles';
  13. import Panel from 'sentry/components/panels/panel';
  14. import {IconChevron} from 'sentry/icons';
  15. import {t, tct} from 'sentry/locale';
  16. import {space} from 'sentry/styles/space';
  17. import {type Group, IssueType} from 'sentry/types/group';
  18. import {parseCursor} from 'sentry/utils/cursor';
  19. import parseLinkHeader from 'sentry/utils/parseLinkHeader';
  20. import {decodeSorts} from 'sentry/utils/queryString';
  21. import {useLocation} from 'sentry/utils/useLocation';
  22. import useOrganization from 'sentry/utils/useOrganization';
  23. import {useRoutes} from 'sentry/utils/useRoutes';
  24. import {useEventColumns} from 'sentry/views/issueDetails/allEventsTable';
  25. import {ALL_EVENTS_EXCLUDED_TAGS} from 'sentry/views/issueDetails/groupEvents';
  26. import {useIssueDetailsEventView} from 'sentry/views/issueDetails/streamline/hooks/useIssueDetailsDiscoverQuery';
  27. import EventsTable from 'sentry/views/performance/transactionSummary/transactionEvents/eventsTable';
  28. interface EventListProps {
  29. group: Group;
  30. }
  31. export function EventList({group}: EventListProps) {
  32. const referrer = 'issue_details.streamline_list';
  33. const theme = useTheme();
  34. const location = useLocation();
  35. const organization = useOrganization();
  36. const routes = useRoutes();
  37. const [_error, setError] = useState('');
  38. const {fields, columnTitles} = useEventColumns(group, organization);
  39. const eventView = useIssueDetailsEventView({
  40. group,
  41. queryProps: {
  42. fields,
  43. widths: fields.map(field => {
  44. switch (field) {
  45. case 'id':
  46. case 'trace':
  47. case 'replayId':
  48. // Id columns can be smaller
  49. return '100';
  50. case 'environment':
  51. // Big enough to fit "Environment"
  52. return '115';
  53. case 'timestamp':
  54. return '220';
  55. case 'url':
  56. return '300';
  57. case 'title':
  58. case 'transaction':
  59. return '200';
  60. default:
  61. return '150';
  62. }
  63. }),
  64. },
  65. });
  66. eventView.sorts = decodeSorts(location.query.sort).filter(sort =>
  67. fields.includes(sort.field)
  68. );
  69. if (!eventView.sorts.length) {
  70. eventView.sorts = [{field: 'timestamp', kind: 'desc'}];
  71. }
  72. const grayText = css`
  73. color: ${theme.subText};
  74. font-weight: ${theme.fontWeightNormal};
  75. `;
  76. const isRegressionIssue =
  77. group.issueType === IssueType.PERFORMANCE_DURATION_REGRESSION ||
  78. group.issueType === IssueType.PERFORMANCE_ENDPOINT_REGRESSION;
  79. return (
  80. <StreamlineEventsTable>
  81. <EventsTable
  82. eventView={eventView}
  83. location={location}
  84. issueId={group.id}
  85. isRegressionIssue={isRegressionIssue}
  86. organization={organization}
  87. routes={routes}
  88. excludedTags={ALL_EVENTS_EXCLUDED_TAGS}
  89. projectSlug={group.project.slug}
  90. customColumns={['minidump']}
  91. setError={err => setError(err ?? '')}
  92. transactionName={group.title || group.type}
  93. columnTitles={columnTitles}
  94. referrer={referrer}
  95. hidePagination
  96. renderTableHeader={({
  97. pageLinks,
  98. pageEventsCount,
  99. totalEventsCount,
  100. isPending,
  101. }) => {
  102. const links = parseLinkHeader(pageLinks);
  103. const previousDisabled = links.previous?.results === false;
  104. const nextDisabled = links.next?.results === false;
  105. const currentCursor = parseCursor(location.query?.cursor);
  106. const start = Math.max(currentCursor?.offset ?? 1, 1);
  107. return (
  108. <EventListHeader>
  109. <EventListTitle>{t('All Events')}</EventListTitle>
  110. <EventListHeaderItem>
  111. {isPending || pageEventsCount === 0
  112. ? null
  113. : tct('Showing [start]-[end] of [count] matching events', {
  114. start: start.toLocaleString(),
  115. end: (
  116. (currentCursor?.offset ?? 0) + pageEventsCount
  117. ).toLocaleString(),
  118. count: (totalEventsCount ?? 0).toLocaleString(),
  119. })}
  120. </EventListHeaderItem>
  121. <EventListHeaderItem>
  122. <ButtonBar gap={0.25}>
  123. <LinkButton
  124. aria-label={t('Previous Page')}
  125. borderless
  126. size="xs"
  127. icon={<IconChevron direction="left" />}
  128. css={grayText}
  129. to={{
  130. ...location,
  131. query: {
  132. ...location.query,
  133. cursor: links.previous?.cursor,
  134. },
  135. }}
  136. disabled={isPending || previousDisabled}
  137. />
  138. <LinkButton
  139. aria-label={t('Next Page')}
  140. borderless
  141. size="xs"
  142. icon={<IconChevron direction="right" />}
  143. css={grayText}
  144. to={{
  145. ...location,
  146. query: {
  147. ...location.query,
  148. cursor: links.next?.cursor,
  149. },
  150. }}
  151. disabled={isPending || nextDisabled}
  152. />
  153. </ButtonBar>
  154. </EventListHeaderItem>
  155. </EventListHeader>
  156. );
  157. }}
  158. />
  159. </StreamlineEventsTable>
  160. );
  161. }
  162. const EventListHeader = styled('div')`
  163. display: grid;
  164. grid-template-columns: 1fr auto auto;
  165. gap: ${space(1.5)};
  166. align-items: center;
  167. padding: ${space(1)} ${space(1)} ${space(1)} ${space(1.5)};
  168. background: ${p => p.theme.background};
  169. border-bottom: 1px solid ${p => p.theme.translucentBorder};
  170. position: sticky;
  171. top: 0;
  172. z-index: ${p => p.theme.zIndex.header};
  173. border-radius: ${p => p.theme.borderRadiusTop};
  174. `;
  175. const EventListTitle = styled('div')`
  176. color: ${p => p.theme.textColor};
  177. font-weight: ${p => p.theme.fontWeightBold};
  178. font-size: ${p => p.theme.fontSizeMedium};
  179. `;
  180. const EventListHeaderItem = styled('div')`
  181. color: ${p => p.theme.subText};
  182. font-weight: ${p => p.theme.fontWeightNormal};
  183. font-size: ${p => p.theme.fontSizeSmall};
  184. `;
  185. const StreamlineEventsTable = styled('div')`
  186. border: 1px solid ${p => p.theme.border};
  187. border-radius: ${p => p.theme.borderRadius};
  188. ${Panel} {
  189. border: 0;
  190. margin-bottom: 0;
  191. }
  192. ${GridHead} {
  193. min-height: unset;
  194. font-size: ${p => p.theme.fontSizeMedium};
  195. ${GridResizer} {
  196. height: 36px;
  197. }
  198. }
  199. ${GridHeadCell} {
  200. height: 36px;
  201. padding: 0 ${space(1.5)};
  202. white-space: nowrap;
  203. text-overflow: ellipsis;
  204. text-transform: none;
  205. border-width: 0 1px 0 0;
  206. border-style: solid;
  207. border-image: linear-gradient(
  208. to bottom,
  209. transparent,
  210. transparent 30%,
  211. ${p => p.theme.border} 30%,
  212. ${p => p.theme.border} 70%,
  213. transparent 70%,
  214. transparent
  215. )
  216. 1;
  217. &:last-child {
  218. border: 0;
  219. }
  220. &:first-child {
  221. padding-left: ${space(1.5)};
  222. }
  223. }
  224. ${GridBodyCell} {
  225. min-height: unset;
  226. padding: ${space(1)} ${space(1.5)};
  227. font-size: ${p => p.theme.fontSizeMedium};
  228. overflow: hidden;
  229. text-overflow: ellipsis;
  230. white-space: nowrap;
  231. }
  232. ${GridRow} {
  233. td:nth-child(2) {
  234. padding-left: ${space(1.5)};
  235. }
  236. td:not(:nth-child(2)) {
  237. a {
  238. color: ${p => p.theme.textColor};
  239. text-decoration: underline;
  240. text-decoration-color: ${p => p.theme.border};
  241. }
  242. }
  243. }
  244. `;