groupReplays.tsx 2.0 KB

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