groupReplays.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 {DEFAULT_SORT, REPLAY_LIST_FIELDS} from 'sentry/utils/replays/fetchReplayList';
  9. import useReplayList from 'sentry/utils/replays/hooks/useReplayList';
  10. import {useLocation} from 'sentry/utils/useLocation';
  11. import useOrganization from 'sentry/utils/useOrganization';
  12. import ReplayTable from 'sentry/views/replays/replayTable';
  13. import type {ReplayListLocationQuery} from 'sentry/views/replays/types';
  14. type Props = {
  15. group: Group;
  16. replayIds: string[];
  17. };
  18. const GroupReplays = ({group, replayIds}: Props) => {
  19. const location = useLocation<ReplayListLocationQuery>();
  20. const organization = useOrganization();
  21. const {project} = group;
  22. const eventView = useMemo(() => {
  23. return EventView.fromNewQueryWithLocation(
  24. {
  25. id: '',
  26. name: '',
  27. version: 2,
  28. fields: REPLAY_LIST_FIELDS,
  29. projects: [Number(project.id)],
  30. query: `id:[${String(replayIds)}]`,
  31. orderby: decodeScalar(location.query.sort, DEFAULT_SORT),
  32. },
  33. location
  34. );
  35. }, [location, project.id, replayIds]);
  36. const {replays, pageLinks, isFetching, fetchError} = useReplayList({
  37. organization,
  38. eventView,
  39. });
  40. return (
  41. <StyledPageContent>
  42. <ReplayTable
  43. isFetching={isFetching}
  44. replays={replays}
  45. showProjectColumn={false}
  46. sort={eventView.sorts[0]}
  47. fetchError={fetchError}
  48. />
  49. <Pagination pageLinks={pageLinks} />
  50. </StyledPageContent>
  51. );
  52. };
  53. const StyledPageContent = styled(PageContent)`
  54. box-shadow: 0px 0px 1px ${p => p.theme.gray200};
  55. background-color: ${p => p.theme.background};
  56. `;
  57. export default GroupReplays;