groupEvents.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import {useCallback} from 'react';
  2. import styled from '@emotion/styled';
  3. import * as Layout from 'sentry/components/layouts/thirds';
  4. import {space} from 'sentry/styles/space';
  5. import type {Group} from 'sentry/types/group';
  6. import type {RouteComponentProps} from 'sentry/types/legacyReactRouter';
  7. import type {Project} from 'sentry/types/project';
  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 useOrganization from 'sentry/utils/useOrganization';
  13. import {EventList} from 'sentry/views/issueDetails/streamline/eventList';
  14. import {EventSearch} from 'sentry/views/issueDetails/streamline/eventSearch';
  15. import {useHasStreamlinedUI} from 'sentry/views/issueDetails/utils';
  16. import AllEventsTable from './allEventsTable';
  17. interface Props extends RouteComponentProps<{groupId: string}, {}> {
  18. environments: string[];
  19. group: Group;
  20. project: Project;
  21. }
  22. export const ALL_EVENTS_EXCLUDED_TAGS = [
  23. 'environment',
  24. 'performance.issue_ids',
  25. 'transaction.op',
  26. 'transaction.status',
  27. ...ISSUE_PROPERTY_FIELDS,
  28. ];
  29. function GroupEvents({params, location, group, environments}: Props) {
  30. const organization = useOrganization();
  31. const {groupId} = params;
  32. useCleanQueryParamsOnRouteLeave({
  33. fieldsToClean: ['cursor', 'query'],
  34. shouldClean: newLocation => newLocation.pathname.includes(`/issues/${group.id}/`),
  35. });
  36. const handleSearch = useCallback(
  37. (query: string) =>
  38. browserHistory.push(
  39. normalizeUrl({
  40. pathname: `/organizations/${organization.slug}/issues/${groupId}/events/`,
  41. query: {...location.query, query},
  42. })
  43. ),
  44. [location, organization, groupId]
  45. );
  46. const query = location.query?.query ?? '';
  47. return (
  48. <Layout.Body>
  49. <Layout.Main fullWidth>
  50. <AllEventsFilters>
  51. <EventSearch
  52. environments={environments}
  53. group={group}
  54. handleSearch={handleSearch}
  55. query={query}
  56. />
  57. </AllEventsFilters>
  58. <AllEventsTable
  59. issueId={group.id}
  60. location={location}
  61. organization={organization}
  62. group={group}
  63. excludedTags={ALL_EVENTS_EXCLUDED_TAGS}
  64. />
  65. </Layout.Main>
  66. </Layout.Body>
  67. );
  68. }
  69. const AllEventsFilters = styled('div')`
  70. margin-bottom: ${space(2)};
  71. `;
  72. // TODO(streamlined-ui): Remove this file completely and change rotue to new events list
  73. function IssueEventsList(props: Props) {
  74. const hasStreamlinedUI = useHasStreamlinedUI();
  75. if (hasStreamlinedUI) {
  76. return <EventList {...props} />;
  77. }
  78. return <GroupEvents {...props} />;
  79. }
  80. export default IssueEventsList;