diff --git a/frontend/src/lib/components/Playlist/Playlist.stories.tsx b/frontend/src/lib/components/Playlist/Playlist.stories.tsx index a469d4cd55532..ed90e0a8a1c45 100644 --- a/frontend/src/lib/components/Playlist/Playlist.stories.tsx +++ b/frontend/src/lib/components/Playlist/Playlist.stories.tsx @@ -37,7 +37,7 @@ Default.args = { sections: [ { key: 'default', - title: `Default section`, + title: 'Default section', items: range(0, 100).map((idx) => ({ id: idx })), render: ListItem, }, @@ -61,3 +61,16 @@ MultipleSections.args = { }, ], } + +export const WithFooter: Story = Template.bind({}) +WithFooter.args = { + sections: [ + { + key: 'default', + title: 'Section with footer', + items: range(0, 100).map((idx) => ({ id: idx })), + render: ListItem, + footer:
Section footer
, + }, + ], +} diff --git a/frontend/src/lib/components/Playlist/Playlist.tsx b/frontend/src/lib/components/Playlist/Playlist.tsx index 74bbb0d1fdd01..2d4d9a48776b4 100644 --- a/frontend/src/lib/components/Playlist/Playlist.tsx +++ b/frontend/src/lib/components/Playlist/Playlist.tsx @@ -1,7 +1,7 @@ import './Playlist.scss' import { IconCollapse } from '@posthog/icons' -import { LemonButton, LemonButtonProps, LemonCollapse, LemonSkeleton, Spinner, Tooltip } from '@posthog/lemon-ui' +import { LemonButton, LemonButtonProps, LemonCollapse, LemonSkeleton, Tooltip } from '@posthog/lemon-ui' import clsx from 'clsx' import { useResizeBreakpoints } from 'lib/hooks/useResizeObserver' import { IconChevronRight } from 'lib/lemon-ui/icons' @@ -19,6 +19,7 @@ export type PlaylistSection = { title?: string items: any[] render: ({ item, isActive }: { item: any; isActive: any }) => JSX.Element + footer?: JSX.Element } type PlaylistHeaderAction = Pick & { @@ -37,7 +38,6 @@ export type PlaylistProps = { headerActions?: PlaylistHeaderAction[] onScrollListEdge?: (edge: 'top' | 'bottom') => void onSelect?: (item: any) => void - onLoadMore?: () => void 'data-attr'?: string activeItemId?: string } @@ -59,7 +59,6 @@ export function Playlist({ listEmptyState, onSelect, 'data-attr': dataAttr, - onLoadMore, }: PlaylistProps): JSX.Element { const [controlledActiveItemId, setControlledActiveItemId] = useState(null) const [listCollapsed, setListCollapsed] = useState(false) @@ -102,7 +101,6 @@ export function Playlist({ activeItemId={activeItemId} setActiveItemId={onChangeActiveItem} emptyState={listEmptyState} - onLoadMore={onLoadMore} /> )} { const [activeHeaderActionKey, setActiveHeaderActionKey] = useState(null) const lastScrollPositionRef = useRef(0) @@ -248,18 +244,6 @@ const List = ({ ) : ( )} - -
- {loading ? ( - <> - Loading - - ) : onLoadMore ? ( - Load more - ) : sections.length <= 1 ? ( - 'No more results' - ) : null} -
) : loading ? ( @@ -274,6 +258,7 @@ const List = ({ const ListSection = ({ items, render, + footer, onClick, activeItemId, }: PlaylistSection & { @@ -288,6 +273,7 @@ const ListSection = ({ {render({ item, isActive: item.id === activeItemId })} ))} + {footer} ) } diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx index 0c0e956479c17..c591fa655abc0 100644 --- a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx +++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx @@ -1,5 +1,5 @@ import { IconFilter, IconGear } from '@posthog/icons' -import { LemonButton, Link } from '@posthog/lemon-ui' +import { LemonButton, Link, Spinner } from '@posthog/lemon-ui' import { BindLogic, useActions, useValues } from 'kea' import { EmptyMessage } from 'lib/components/EmptyMessage/EmptyMessage' import { Playlist, PlaylistSection } from 'lib/components/Playlist/Playlist' @@ -123,6 +123,19 @@ export function SessionRecordingsPlaylist(props: SessionRecordingPlaylistLogicPr sessionSummaryLoading={sessionSummaryLoading} /> ), + footer: ( +
+ {sessionRecordingsResponseLoading ? ( + <> + Loading + + ) : hasNext ? ( + maybeLoadSessionRecordings('older')}>Load more + ) : ( + 'No more results' + )} +
+ ), }) return ( @@ -147,7 +160,6 @@ export function SessionRecordingsPlaylist(props: SessionRecordingPlaylistLogicPr listEmptyState={} onSelect={setSelectedRecordingId} activeItemId={activeSessionRecordingId} - onLoadMore={hasNext ? () => maybeLoadSessionRecordings('older') : undefined} content={({ activeItem }) => !activeItem ? (