eventList.tsx 7.1 KB

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