Skip to content

Commit 71601ca

Browse files
committed
feat(replay): Add pagination to Playlist view
This adds our normal pagination at the end of the replays table in the Playlist view
1 parent c1ec1c7 commit 71601ca

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed

static/app/utils/replays/playback/providers/replayPlaylistProvider.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,32 @@ interface Props {
88
currentReplay: ReplayListRecord | undefined;
99
isLoading: boolean;
1010
replays: ReplayListRecord[];
11+
pageLinks?: string | null;
1112
}
1213

1314
const Context = createContext<{
1415
currentReplayIndex: number;
1516
isLoading: boolean;
17+
pageLinks: string | null;
1618
replays: ReplayListRecord[];
17-
}>({currentReplayIndex: -1, replays: [], isLoading: false});
19+
}>({currentReplayIndex: -1, replays: [], isLoading: false, pageLinks: null});
1820

1921
export function ReplayPlaylistProvider({
2022
children,
2123
currentReplay,
2224
isLoading,
25+
pageLinks = null,
2326
replays,
2427
}: Props) {
2528
const currentReplayIndex = useMemo(
2629
() => replays?.findIndex(r => r.id === currentReplay?.id) ?? -1,
2730
[replays, currentReplay]
2831
);
29-
return <Context value={{replays, currentReplayIndex, isLoading}}>{children}</Context>;
32+
return (
33+
<Context value={{replays, currentReplayIndex, isLoading, pageLinks}}>
34+
{children}
35+
</Context>
36+
);
3037
}
3138

3239
export function useReplayPlaylist() {

static/app/views/replays/detail/body/replayDetailsProviders.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ export default function ReplayDetailsProviders({children, replay, projectSlug}:
8181
? (query.referrer as ReplayListQueryReferrer)
8282
: 'replayList',
8383
});
84-
const {data, isLoading} = useApiQuery<{
84+
const {data, isLoading, getResponseHeader} = useApiQuery<{
8585
data: ReplayListRecord[];
8686
enabled: boolean;
8787
}>(queryKey, {
8888
staleTime: 0,
8989
enabled: Boolean(playlistStart && playlistEnd),
9090
});
91+
const pageLinks = getResponseHeader?.('Link') ?? null;
9192

9293
const replays = useMemo(() => data?.data?.map(mapResponseToReplayRecord) ?? [], [data]);
9394

@@ -109,6 +110,7 @@ export default function ReplayDetailsProviders({children, replay, projectSlug}:
109110
<ReplayPlaylistProvider
110111
currentReplay={replayRecord}
111112
isLoading={isLoading}
113+
pageLinks={pageLinks}
112114
replays={replays}
113115
>
114116
{children}

static/app/views/replays/detail/playlist/index.tsx

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {Flex, Grid} from '@sentry/scraps/layout';
44
import {Text} from '@sentry/scraps/text';
55

66
import {Alert} from 'sentry/components/core/alert';
7+
import Pagination from 'sentry/components/pagination';
78
import ReplayTable from 'sentry/components/replays/table/replayTable';
89
import {
910
ReplayBrowserColumn,
@@ -16,6 +17,7 @@ import {ProvidedFormattedQuery} from 'sentry/components/searchQueryBuilder/forma
1617
import {t} from 'sentry/locale';
1718
import {useReplayPlaylist} from 'sentry/utils/replays/playback/providers/replayPlaylistProvider';
1819
import {useLocation} from 'sentry/utils/useLocation';
20+
import {useNavigate} from 'sentry/utils/useNavigate';
1921
import useAllMobileProj from 'sentry/views/replays/detail/useAllMobileProj';
2022

2123
const VISIBLE_COLUMNS = [
@@ -34,8 +36,9 @@ const MOBILE_COLUMNS = [
3436
];
3537

3638
export default function Playlist() {
37-
const {replays, currentReplayIndex, isLoading} = useReplayPlaylist();
39+
const {replays, currentReplayIndex, isLoading, pageLinks} = useReplayPlaylist();
3840
const location = useLocation();
41+
const navigate = useNavigate();
3942
const [query] = useQueryState('query', parseAsString.withDefault(''));
4043

4144
const {allMobileProj} = useAllMobileProj({});
@@ -55,17 +58,28 @@ export default function Playlist() {
5558
<Text>{t('This playlist is filtered by:')} </Text>
5659
</Alert>
5760
) : null}
58-
<ReplayTable
59-
columns={columns}
60-
error={null}
61-
highlightedRowIndex={currentReplayIndex}
62-
// we prefer isLoading since isPending is true even if not enabled
63-
isPending={isLoading}
64-
query={location.query}
65-
replays={replays}
66-
showDropdownFilters={false}
67-
stickyHeader
68-
/>
61+
<Flex direction="column" gap="md">
62+
<ReplayTable
63+
columns={columns}
64+
error={null}
65+
highlightedRowIndex={currentReplayIndex}
66+
// we prefer isLoading since isPending is true even if not enabled
67+
isPending={isLoading}
68+
query={location.query}
69+
replays={replays}
70+
showDropdownFilters={false}
71+
stickyHeader
72+
/>
73+
<Pagination
74+
pageLinks={pageLinks}
75+
onCursor={(cursor, path, searchQuery) => {
76+
navigate({
77+
pathname: path,
78+
query: {...searchQuery, cursor},
79+
});
80+
}}
81+
/>
82+
</Flex>
6983
</Grid>
7084
</Flex>
7185
);

0 commit comments

Comments
 (0)