groupReplays.tsx 2.5 KB

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