groupEvents.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import {useCallback} from 'react';
  2. import styled from '@emotion/styled';
  3. import * as Layout from 'sentry/components/layouts/thirds';
  4. import LoadingError from 'sentry/components/loadingError';
  5. import LoadingIndicator from 'sentry/components/loadingIndicator';
  6. import {space} from 'sentry/styles/space';
  7. import type {Group} from 'sentry/types/group';
  8. import {browserHistory} from 'sentry/utils/browserHistory';
  9. import {ISSUE_PROPERTY_FIELDS} from 'sentry/utils/fields';
  10. import normalizeUrl from 'sentry/utils/url/normalizeUrl';
  11. import useCleanQueryParamsOnRouteLeave from 'sentry/utils/useCleanQueryParamsOnRouteLeave';
  12. import {useLocation} from 'sentry/utils/useLocation';
  13. import useOrganization from 'sentry/utils/useOrganization';
  14. import {useParams} from 'sentry/utils/useParams';
  15. import {EventList} from 'sentry/views/issueDetails/streamline/eventList';
  16. import {EventSearch} from 'sentry/views/issueDetails/streamline/eventSearch';
  17. import {useGroup} from 'sentry/views/issueDetails/useGroup';
  18. import {
  19. useEnvironmentsFromUrl,
  20. useHasStreamlinedUI,
  21. } from 'sentry/views/issueDetails/utils';
  22. import AllEventsTable from './allEventsTable';
  23. export const ALL_EVENTS_EXCLUDED_TAGS = [
  24. 'environment',
  25. 'performance.issue_ids',
  26. 'transaction.op',
  27. 'transaction.status',
  28. ...ISSUE_PROPERTY_FIELDS,
  29. ];
  30. interface GroupEventsProps {
  31. group: Group;
  32. }
  33. function GroupEvents({group}: GroupEventsProps) {
  34. const location = useLocation();
  35. const environments = useEnvironmentsFromUrl();
  36. const params = useParams<{groupId: string}>();
  37. const organization = useOrganization();
  38. useCleanQueryParamsOnRouteLeave({
  39. fieldsToClean: ['cursor', 'query'],
  40. shouldClean: newLocation =>
  41. newLocation.pathname.includes(`/issues/${params.groupId}/`),
  42. });
  43. const handleSearch = useCallback(
  44. (query: string) =>
  45. browserHistory.push(
  46. normalizeUrl({
  47. pathname: `/organizations/${organization.slug}/issues/${params.groupId}/events/`,
  48. query: {...location.query, query},
  49. })
  50. ),
  51. [location, organization, params.groupId]
  52. );
  53. const query = (location.query?.query ?? '') as string;
  54. return (
  55. <Layout.Body>
  56. <Layout.Main fullWidth>
  57. <AllEventsFilters>
  58. <EventSearch
  59. environments={environments}
  60. group={group}
  61. handleSearch={handleSearch}
  62. query={query}
  63. />
  64. </AllEventsFilters>
  65. <AllEventsTable
  66. organization={organization}
  67. group={group}
  68. excludedTags={ALL_EVENTS_EXCLUDED_TAGS}
  69. />
  70. </Layout.Main>
  71. </Layout.Body>
  72. );
  73. }
  74. const AllEventsFilters = styled('div')`
  75. margin-bottom: ${space(2)};
  76. `;
  77. // TODO(streamlined-ui): Remove this file completely and change rotue to new events list
  78. function IssueEventsList() {
  79. const hasStreamlinedUI = useHasStreamlinedUI();
  80. const params = useParams<{groupId: string}>();
  81. const {
  82. data: group,
  83. isPending: isGroupPending,
  84. isError: isGroupError,
  85. refetch: refetchGroup,
  86. } = useGroup({groupId: params.groupId});
  87. if (isGroupPending) {
  88. return <LoadingIndicator />;
  89. }
  90. if (isGroupError) {
  91. return <LoadingError onRetry={refetchGroup} />;
  92. }
  93. if (hasStreamlinedUI) {
  94. return <EventList group={group} />;
  95. }
  96. return <GroupEvents group={group} />;
  97. }
  98. export default IssueEventsList;