eventList.tsx 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. applyEnvironmentFilter
  97. renderTableHeader={({
  98. pageLinks,
  99. pageEventsCount,
  100. totalEventsCount,
  101. isPending,
  102. }) => {
  103. const links = parseLinkHeader(pageLinks);
  104. const previousDisabled = links.previous?.results === false;
  105. const nextDisabled = links.next?.results === false;
  106. const currentCursor = parseCursor(location.query?.cursor);
  107. const start = Math.max(currentCursor?.offset ?? 1, 1);
  108. return (
  109. <EventListHeader>
  110. <EventListTitle>{t('All Events')}</EventListTitle>
  111. <EventListHeaderItem>
  112. {isPending || pageEventsCount === 0
  113. ? null
  114. : tct('Showing [start]-[end] of [count] matching events', {
  115. start: start.toLocaleString(),
  116. end: (
  117. (currentCursor?.offset ?? 0) + pageEventsCount
  118. ).toLocaleString(),
  119. count: (totalEventsCount ?? 0).toLocaleString(),
  120. })}
  121. </EventListHeaderItem>
  122. <EventListHeaderItem>
  123. <ButtonBar gap={0.25}>
  124. <LinkButton
  125. aria-label={t('Previous Page')}
  126. borderless
  127. size="xs"
  128. icon={<IconChevron direction="left" />}
  129. css={grayText}
  130. to={{
  131. ...location,
  132. query: {
  133. ...location.query,
  134. cursor: links.previous?.cursor,
  135. },
  136. }}
  137. disabled={isPending || previousDisabled}
  138. />
  139. <LinkButton
  140. aria-label={t('Next Page')}
  141. borderless
  142. size="xs"
  143. icon={<IconChevron direction="right" />}
  144. css={grayText}
  145. to={{
  146. ...location,
  147. query: {
  148. ...location.query,
  149. cursor: links.next?.cursor,
  150. },
  151. }}
  152. disabled={isPending || nextDisabled}
  153. />
  154. </ButtonBar>
  155. </EventListHeaderItem>
  156. </EventListHeader>
  157. );
  158. }}
  159. />
  160. </StreamlineEventsTable>
  161. );
  162. }
  163. const EventListHeader = styled('div')`
  164. display: grid;
  165. grid-template-columns: 1fr auto auto;
  166. gap: ${space(1.5)};
  167. align-items: center;
  168. padding: ${space(1)} ${space(1)} ${space(1)} ${space(1.5)};
  169. background: ${p => p.theme.background};
  170. border-bottom: 1px solid ${p => p.theme.translucentBorder};
  171. position: sticky;
  172. top: 0;
  173. z-index: ${p => p.theme.zIndex.header};
  174. border-radius: ${p => p.theme.borderRadiusTop};
  175. `;
  176. const EventListTitle = styled('div')`
  177. color: ${p => p.theme.textColor};
  178. font-weight: ${p => p.theme.fontWeightBold};
  179. font-size: ${p => p.theme.fontSizeMedium};
  180. `;
  181. const EventListHeaderItem = styled('div')`
  182. color: ${p => p.theme.subText};
  183. font-weight: ${p => p.theme.fontWeightNormal};
  184. font-size: ${p => p.theme.fontSizeSmall};
  185. `;
  186. const StreamlineEventsTable = styled('div')`
  187. border: 1px solid ${p => p.theme.border};
  188. border-radius: ${p => p.theme.borderRadius};
  189. ${Panel} {
  190. border: 0;
  191. margin-bottom: 0;
  192. }
  193. ${GridHead} {
  194. min-height: unset;
  195. font-size: ${p => p.theme.fontSizeMedium};
  196. ${GridResizer} {
  197. height: 36px;
  198. }
  199. }
  200. ${GridHeadCell} {
  201. height: 36px;
  202. padding: 0 ${space(1.5)};
  203. white-space: nowrap;
  204. text-overflow: ellipsis;
  205. text-transform: none;
  206. border-width: 0 1px 0 0;
  207. border-style: solid;
  208. border-image: linear-gradient(
  209. to bottom,
  210. transparent,
  211. transparent 30%,
  212. ${p => p.theme.border} 30%,
  213. ${p => p.theme.border} 70%,
  214. transparent 70%,
  215. transparent
  216. )
  217. 1;
  218. &:last-child {
  219. border: 0;
  220. }
  221. &:first-child {
  222. padding-left: ${space(1.5)};
  223. }
  224. }
  225. ${GridBodyCell} {
  226. min-height: unset;
  227. padding: ${space(1)} ${space(1.5)};
  228. font-size: ${p => p.theme.fontSizeMedium};
  229. overflow: hidden;
  230. text-overflow: ellipsis;
  231. white-space: nowrap;
  232. }
  233. ${GridRow} {
  234. td:nth-child(2) {
  235. padding-left: ${space(1.5)};
  236. }
  237. td:not(:nth-child(2)) {
  238. a {
  239. color: ${p => p.theme.textColor};
  240. text-decoration: underline;
  241. text-decoration-color: ${p => p.theme.border};
  242. }
  243. }
  244. }
  245. `;