groupReplays.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import {useMemo} from 'react';
  2. import {useTheme} from '@emotion/react';
  3. import styled from '@emotion/styled';
  4. import {Location} from 'history';
  5. import * as Layout from 'sentry/components/layouts/thirds';
  6. import type {Group, Organization} from 'sentry/types';
  7. import EventView from 'sentry/utils/discover/eventView';
  8. import useReplayList from 'sentry/utils/replays/hooks/useReplayList';
  9. import {useLocation} from 'sentry/utils/useLocation';
  10. import useMedia from 'sentry/utils/useMedia';
  11. import useOrganization from 'sentry/utils/useOrganization';
  12. import useReplaysFromIssue from 'sentry/views/issueDetails/groupReplays/useReplaysFromIssue';
  13. import ReplayTable from 'sentry/views/replays/replayTable';
  14. import {ReplayColumns} from 'sentry/views/replays/replayTable/types';
  15. import type {ReplayListLocationQuery} from 'sentry/views/replays/types';
  16. type Props = {
  17. group: Group;
  18. };
  19. function GroupReplays({group}: Props) {
  20. const theme = useTheme();
  21. const hasRoomForColumns = useMedia(`(min-width: ${theme.breakpoints.small})`);
  22. const organization = useOrganization();
  23. const location = useLocation<ReplayListLocationQuery>();
  24. const {eventView, fetchError, pageLinks} = useReplaysFromIssue({
  25. group,
  26. location,
  27. organization,
  28. });
  29. if (!eventView) {
  30. return (
  31. <StyledLayoutPage withPadding>
  32. <ReplayTable
  33. fetchError={fetchError}
  34. isFetching
  35. replays={[]}
  36. sort={undefined}
  37. visibleColumns={[
  38. ReplayColumns.session,
  39. ...(hasRoomForColumns ? [ReplayColumns.startedAt] : []),
  40. ReplayColumns.duration,
  41. ReplayColumns.countErrors,
  42. ReplayColumns.activity,
  43. ]}
  44. />
  45. </StyledLayoutPage>
  46. );
  47. }
  48. return (
  49. <GroupReplaysTable
  50. eventView={eventView}
  51. organization={organization}
  52. pageLinks={pageLinks}
  53. />
  54. );
  55. }
  56. const GroupReplaysTable = ({
  57. eventView,
  58. organization,
  59. }: {
  60. eventView: EventView;
  61. organization: Organization;
  62. pageLinks: string | null;
  63. }) => {
  64. const location = useMemo(() => ({query: {}} as Location<ReplayListLocationQuery>), []);
  65. const theme = useTheme();
  66. const hasRoomForColumns = useMedia(`(min-width: ${theme.breakpoints.small})`);
  67. const {replays, isFetching, fetchError} = useReplayList({
  68. eventView,
  69. location,
  70. organization,
  71. });
  72. return (
  73. <StyledLayoutPage withPadding>
  74. <ReplayTable
  75. fetchError={fetchError}
  76. isFetching={isFetching}
  77. replays={replays}
  78. sort={undefined}
  79. visibleColumns={[
  80. ReplayColumns.session,
  81. ...(hasRoomForColumns ? [ReplayColumns.startedAt] : []),
  82. ReplayColumns.duration,
  83. ReplayColumns.countErrors,
  84. ReplayColumns.activity,
  85. ]}
  86. />
  87. </StyledLayoutPage>
  88. );
  89. };
  90. const StyledLayoutPage = styled(Layout.Page)`
  91. box-shadow: 0px 0px 1px ${p => p.theme.gray200};
  92. background-color: ${p => p.theme.background};
  93. `;
  94. export default GroupReplays;