groupEvents.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import {useCallback} from 'react';
  2. import type {RouteComponentProps} from 'react-router';
  3. import styled from '@emotion/styled';
  4. import EventSearchBar from 'sentry/components/events/searchBar';
  5. import * as Layout from 'sentry/components/layouts/thirds';
  6. import {space} from 'sentry/styles/space';
  7. import type {Group} from 'sentry/types/group';
  8. import {browserHistory} from 'sentry/utils/browserHistory';
  9. import normalizeUrl from 'sentry/utils/url/normalizeUrl';
  10. import useCleanQueryParamsOnRouteLeave from 'sentry/utils/useCleanQueryParamsOnRouteLeave';
  11. import useOrganization from 'sentry/utils/useOrganization';
  12. import {EventSearch} from 'sentry/views/issueDetails/streamline/eventSearch';
  13. import AllEventsTable from './allEventsTable';
  14. interface Props extends RouteComponentProps<{groupId: string}, {}> {
  15. environments: string[];
  16. group: Group;
  17. }
  18. export const ALL_EVENTS_EXCLUDED_TAGS = [
  19. 'environment',
  20. 'issue',
  21. 'issue.id',
  22. 'performance.issue_ids',
  23. 'transaction.op',
  24. 'transaction.status',
  25. ];
  26. function GroupEvents({params, location, group, environments}: Props) {
  27. const organization = useOrganization();
  28. const {groupId} = params;
  29. useCleanQueryParamsOnRouteLeave({
  30. fieldsToClean: ['cursor', 'query'],
  31. shouldClean: newLocation => newLocation.pathname.includes(`/issues/${group.id}/`),
  32. });
  33. const handleSearch = useCallback(
  34. (query: string) =>
  35. browserHistory.push(
  36. normalizeUrl({
  37. pathname: `/organizations/${organization.slug}/issues/${groupId}/events/`,
  38. query: {...location.query, query},
  39. })
  40. ),
  41. [location, organization, groupId]
  42. );
  43. const query = location.query?.query ?? '';
  44. return (
  45. <Layout.Body>
  46. <Layout.Main fullWidth>
  47. <AllEventsFilters>
  48. {organization.features.includes('issue-stream-search-query-builder') ? (
  49. <EventSearch
  50. environments={environments}
  51. group={group}
  52. handleSearch={handleSearch}
  53. query={query}
  54. />
  55. ) : (
  56. <EventSearchBar
  57. organization={organization}
  58. defaultQuery=""
  59. onSearch={handleSearch}
  60. excludedTags={ALL_EVENTS_EXCLUDED_TAGS}
  61. query={query}
  62. hasRecentSearches={false}
  63. searchSource="issue_events_tab"
  64. />
  65. )}
  66. </AllEventsFilters>
  67. <AllEventsTable
  68. issueId={group.id}
  69. location={location}
  70. organization={organization}
  71. group={group}
  72. excludedTags={ALL_EVENTS_EXCLUDED_TAGS}
  73. />
  74. </Layout.Main>
  75. </Layout.Body>
  76. );
  77. }
  78. const AllEventsFilters = styled('div')`
  79. margin-bottom: ${space(2)};
  80. `;
  81. export default GroupEvents;