groupReplays.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import {useMemo} from 'react';
  2. import styled from '@emotion/styled';
  3. import Pagination from 'sentry/components/pagination';
  4. import {PageContent} from 'sentry/styles/organization';
  5. import type {Group} from 'sentry/types';
  6. import EventView from 'sentry/utils/discover/eventView';
  7. import {decodeScalar} from 'sentry/utils/queryString';
  8. import useReplayList, {
  9. DEFAULT_SORT,
  10. REPLAY_LIST_FIELDS,
  11. } from 'sentry/utils/replays/hooks/useReplayList';
  12. import {MutableSearch} from 'sentry/utils/tokenizeSearch';
  13. import {useLocation} from 'sentry/utils/useLocation';
  14. import useOrganization from 'sentry/utils/useOrganization';
  15. import {useParams} from 'sentry/utils/useParams';
  16. import ReplayTable from 'sentry/views/replays/replayTable';
  17. import type {ReplayListLocationQuery} from 'sentry/views/replays/types';
  18. type Props = {
  19. group: Group;
  20. };
  21. const GroupReplays = ({group}: Props) => {
  22. const location = useLocation<ReplayListLocationQuery>();
  23. const organization = useOrganization();
  24. const params = useParams();
  25. const {project} = group;
  26. const eventView = useMemo(() => {
  27. const query = decodeScalar(location.query.query, '');
  28. const conditions = new MutableSearch(query);
  29. conditions.addFilterValues('issue.id', params.groupId);
  30. return EventView.fromNewQueryWithLocation(
  31. {
  32. id: '',
  33. name: '',
  34. version: 2,
  35. fields: REPLAY_LIST_FIELDS,
  36. projects: [Number(project.id)],
  37. query: conditions.formatString(),
  38. orderby: decodeScalar(location.query.sort, DEFAULT_SORT),
  39. },
  40. location
  41. );
  42. }, [location, project.id, params.groupId]);
  43. const {replays, pageLinks, isFetching} = useReplayList({
  44. organization,
  45. eventView,
  46. });
  47. return (
  48. <StyledPageContent>
  49. <ReplayTable
  50. isFetching={isFetching}
  51. replays={replays}
  52. showProjectColumn={false}
  53. sort={eventView.sorts[0]}
  54. />
  55. <Pagination pageLinks={pageLinks} />
  56. </StyledPageContent>
  57. );
  58. };
  59. const StyledPageContent = styled(PageContent)`
  60. box-shadow: 0px 0px 1px ${p => p.theme.gray200};
  61. background-color: ${p => p.theme.background};
  62. `;
  63. export default GroupReplays;