groupEvents.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import {useCallback} from 'react';
  2. import {browserHistory, 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 {Group} from 'sentry/types';
  8. import useCleanQueryParamsOnRouteLeave from 'sentry/utils/useCleanQueryParamsOnRouteLeave';
  9. import useOrganization from 'sentry/utils/useOrganization';
  10. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  11. import AllEventsTable from './allEventsTable';
  12. interface Props extends RouteComponentProps<{groupId: string}, {}> {
  13. group: Group;
  14. }
  15. const excludedTags = [
  16. 'environment',
  17. 'issue',
  18. 'issue.id',
  19. 'performance.issue_ids',
  20. 'transaction.op',
  21. 'transaction.status',
  22. ];
  23. function GroupEvents({params, location, group}: Props) {
  24. const organization = useOrganization();
  25. const {groupId} = params;
  26. useCleanQueryParamsOnRouteLeave({
  27. fieldsToClean: ['cursor', 'query'],
  28. shouldClean: newLocation => newLocation.pathname.includes(`/issues/${group.id}/`),
  29. });
  30. const handleSearch = useCallback(
  31. (query: string) =>
  32. browserHistory.push(
  33. normalizeUrl({
  34. pathname: `/organizations/${organization.slug}/issues/${groupId}/events/`,
  35. query: {...location.query, query},
  36. })
  37. ),
  38. [location, organization, groupId]
  39. );
  40. return (
  41. <Layout.Body>
  42. <Layout.Main fullWidth>
  43. <AllEventsFilters>
  44. <EventSearchBar
  45. organization={organization}
  46. defaultQuery=""
  47. onSearch={handleSearch}
  48. excludedTags={excludedTags}
  49. query={location.query?.query ?? ''}
  50. hasRecentSearches={false}
  51. />
  52. </AllEventsFilters>
  53. <AllEventsTable
  54. issueId={group.id}
  55. location={location}
  56. organization={organization}
  57. group={group}
  58. excludedTags={excludedTags}
  59. />
  60. </Layout.Main>
  61. </Layout.Body>
  62. );
  63. }
  64. const AllEventsFilters = styled('div')`
  65. margin-bottom: ${space(2)};
  66. `;
  67. export default GroupEvents;