From 056a82a7996e620ebbaf470ab18d3d11b22ad443 Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Mon, 15 Jun 2026 15:27:02 -0500 Subject: [PATCH 1/2] fix: try a different pagination ux --- .../databases/components/TableView.tsx | 95 ++----------------- 1 file changed, 10 insertions(+), 85 deletions(-) diff --git a/src/features/instance/databases/components/TableView.tsx b/src/features/instance/databases/components/TableView.tsx index a4a9e625c..766c272ea 100644 --- a/src/features/instance/databases/components/TableView.tsx +++ b/src/features/instance/databases/components/TableView.tsx @@ -1,11 +1,7 @@ 'use client'; import { LoadingSubtle } from '@/components/LoadingSubtle'; -import { TextLoadingSkeleton } from '@/components/TextLoadingSkeleton'; -import { Button } from '@/components/ui/button'; -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { Table, TableBody, TableCell, TableHeader, TableHeadSortable, TableRow } from '@/components/ui/table'; -import { addCommasToNumbers } from '@/lib/addCommasToNumbers'; import { cn } from '@/lib/cn'; import { Cell, @@ -17,11 +13,11 @@ import { useReactTable, VisibilityState, } from '@tanstack/react-table'; -import { ArrowLeftIcon, ArrowRightIcon } from 'lucide-react'; -import { Dispatch, SetStateAction, useCallback, useMemo } from 'react'; +import { Dispatch, SetStateAction, useMemo } from 'react'; import { UseFormReturn } from 'react-hook-form'; import { z } from 'zod'; import { ColumnFilters, ColumnFiltersSchema } from './ColumnFilters'; +import { TablePagination } from './TablePagination'; interface BrowseDataTableProps { applyFilters: () => void; @@ -78,13 +74,6 @@ export function TableView({ getPaginationRowModel: getPaginationRowModel(), }); - const previousPage = useCallback(() => { - setPageIndex(pageIndex - 1); - }, [pageIndex, setPageIndex]); - const nextPage = useCallback(() => { - setPageIndex(pageIndex + 1); - }, [pageIndex, setPageIndex]); - return ( <> @@ -125,78 +114,14 @@ export function TableView({ )}
-
- - -
- -
-
Records
-
- {totalRecords === undefined - ? - : addCommasToNumbers(totalRecords)} -
-
- {totalRecords !== undefined && totalRecords > 0 && ( - <> -
- -
- - {totalPages !== undefined && totalPages > 1 && ( - <> -
-
Pages
-
{addCommasToNumbers(totalPages)}
-
-
-
Page
-
{addCommasToNumbers(pageIndex + 1)}
-
- - )} - - )} - -
- - -
+ ); } From 18154c2256bc7063310c4acbcc35e8a1f188a9a8 Mon Sep 17 00:00:00 2001 From: Dawson Toth Date: Tue, 16 Jun 2026 12:30:09 -0400 Subject: [PATCH 2/2] fix: Improve pagination even more Collaboration! Yay! --- .../databases/components/TablePagination.tsx | 225 ++++++++++++++++++ .../databases/components/TableView.tsx | 2 - 2 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 src/features/instance/databases/components/TablePagination.tsx diff --git a/src/features/instance/databases/components/TablePagination.tsx b/src/features/instance/databases/components/TablePagination.tsx new file mode 100644 index 000000000..f57c98c30 --- /dev/null +++ b/src/features/instance/databases/components/TablePagination.tsx @@ -0,0 +1,225 @@ +'use client'; + +import { TextLoadingSkeleton } from '@/components/TextLoadingSkeleton'; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; +import { addCommasToNumbers } from '@/lib/addCommasToNumbers'; +import { cn } from '@/lib/cn'; +import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-react'; +import { ComponentProps, Dispatch, FormEvent, SetStateAction, useState } from 'react'; + +const PAGE_SIZE_OPTIONS = [20, 50, 100, 250]; + +interface TablePaginationProps { + pageIndex: number; + pageSize: number; + totalPages?: number; + totalRecords?: number; + setPageIndex: Dispatch>; + setPageSize: Dispatch>; +} + +export function TablePagination( + { pageIndex, pageSize, totalPages, totalRecords, setPageIndex, setPageSize }: TablePaginationProps, +) { + const isLoading = totalPages === undefined || totalRecords === undefined; + const pageCount = totalPages && totalPages > 0 ? totalPages : 1; + const currentPage = pageIndex + 1; + + const canPrevious = pageIndex > 0; + const canNext = !isLoading && currentPage < pageCount; + + const goToPage = (page: number) => { + setPageIndex(Math.max(0, Math.min(page, pageCount) - 1)); + }; + + const changePageSize = (size: number) => { + setPageSize(size); + setPageIndex(0); + }; + + const items = getPaginationItems(currentPage, pageCount); + + return ( +
+
+ {/* Summary — record count is the essential, kept at every width */} +
+ + Page {addCommasToNumbers(currentPage)} of {isLoading ? '…' : addCommasToNumbers(pageCount)} + + + • + + + {isLoading + ? + : <>{addCommasToNumbers(totalRecords)} {totalRecords === 1 ? 'record' : 'records'}} + +
+ +
+ + {/* Navigation — back/forward is the essential, kept at every width */} + + + {/* Keep the nav centered only while the "Go to" field is shown; otherwise pin it right */} +
+ + {/* Rows per page — extra control, only shown when there is ample room */} + + + {/* Go to page — last to appear, first to be dropped */} + +
+
+ ); +} + +function PaginationButton({ + isActive, + className, + ...props +}: ComponentProps<'button'> & { isActive?: boolean }) { + return ( +