groupEvents.tsx 2.2 KB

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