Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions ui/src/components/Pager.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
import { cn } from '../lib/cn'
import { Button } from './ui'

/** Offset pager: "showing X–Y of N" + Prev/Next, bounded to the available pages. Shared by the
* documents listing and the ingestion queue. Renders nothing when there is nothing to page. */
* documents listing and the ingestion queue. Renders nothing when there is nothing to page —
* which is also what keeps a `sticky` pager from leaving an empty bar on an empty listing. */
export function Pager({
page,
pageSize,
total,
onPage,
loading,
sticky = false,
}: {
page: number
pageSize: number
total: number
onPage: (p: number) => void
loading: boolean
/** Pin to the bottom of the scroll area, so paging a long listing never means scrolling to the
* end of it first. Assumes the page gutter both callers share (see the class note below). */
sticky?: boolean
}) {
if (total === 0) return null
const start = page * pageSize + 1
const end = Math.min((page + 1) * pageSize, total)
const lastPage = Math.max(0, Math.ceil(total / pageSize) - 1)
return (
<div className="flex items-center justify-between text-[13px] text-ink-muted">
<div
className={cn(
'flex items-center justify-between text-[13px] text-ink-muted',
// -mx-8/px-8 span the page's px-8 gutter so rows can't show beside the bar, and the
// background is opaque so they can't show through it.
sticky && 'sticky bottom-0 z-10 -mx-8 border-t border-border bg-canvas px-8 py-3',
)}
>
<span>
Showing{' '}
<span className="tabular-nums text-ink">
Expand Down
9 changes: 8 additions & 1 deletion ui/src/pages/Documents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,14 @@ export default function Documents() {
onDelete={setDeleteTarget}
/>

<Pager page={page} pageSize={PAGE_SIZE} total={total} onPage={setPage} loading={isLoading} />
<Pager
page={page}
pageSize={PAGE_SIZE}
total={total}
onPage={setPage}
loading={isLoading}
sticky
/>

<ConfirmDialog
open={deleteTarget !== null}
Expand Down
9 changes: 8 additions & 1 deletion ui/src/pages/IngestionQueue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ export default function IngestionQueue() {
message={error?.message}
onRetry={() => void refetch()}
/>
<Pager page={page} pageSize={PAGE_SIZE} total={total} onPage={setPage} loading={isLoading} />
<Pager
page={page}
pageSize={PAGE_SIZE}
total={total}
onPage={setPage}
loading={isLoading}
sticky
/>

<ConfirmDialog
open={confirmRetry}
Expand Down
Loading