diff --git a/packages/web/src/app/repos/columns.tsx b/packages/web/src/app/repos/columns.tsx index a239dce8..be39d72d 100644 --- a/packages/web/src/app/repos/columns.tsx +++ b/packages/web/src/app/repos/columns.tsx @@ -25,6 +25,7 @@ export const columns: ColumnDef[] = [ { accessorKey: "name", header: "Name", + size: 250, cell: ({ row }) => { const repo = row.original; const url = repo.url; @@ -33,7 +34,7 @@ export const columns: ColumnDef[] = [ return (
{ if (!isRemoteRepo) { window.open(url, "_blank"); @@ -61,7 +62,8 @@ export const columns: ColumnDef[] = [ {branches.map(({ name, version }, index) => { const shortVersion = version.substring(0, 8); return ( - + {name} @ ) -} \ No newline at end of file +} diff --git a/packages/web/src/app/repos/page.tsx b/packages/web/src/app/repos/page.tsx index 7da11dd4..dc117b54 100644 --- a/packages/web/src/app/repos/page.tsx +++ b/packages/web/src/app/repos/page.tsx @@ -7,10 +7,10 @@ export default function ReposPage() {
Loading...
}> -
+
) -} \ No newline at end of file +} diff --git a/packages/web/src/app/repos/repositoryTable.tsx b/packages/web/src/app/repos/repositoryTable.tsx index b6a185a1..5bd2f96f 100644 --- a/packages/web/src/app/repos/repositoryTable.tsx +++ b/packages/web/src/app/repos/repositoryTable.tsx @@ -29,15 +29,14 @@ export const RepositoryTable = async () => { url: repo.Repository.URL, } }).sort((a, b) => { - return new Date(b.lastIndexed).getTime() - new Date(a.lastIndexed).getTime(); + return new Date(b.lastIndexed).getTime() - new Date(a.lastIndexed).getTime(); }); - return ( ); -} \ No newline at end of file +} diff --git a/packages/web/src/components/ui/data-table.tsx b/packages/web/src/components/ui/data-table.tsx index a328d833..be09476e 100644 --- a/packages/web/src/components/ui/data-table.tsx +++ b/packages/web/src/components/ui/data-table.tsx @@ -1,5 +1,6 @@ -"use client" +"use client"; +import React from "react"; import { ColumnDef, ColumnFiltersState, @@ -10,25 +11,24 @@ import { getPaginationRowModel, getSortedRowModel, useReactTable, -} from "@tanstack/react-table" +} from "@tanstack/react-table"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table" -import { Button } from "@/components/ui/button" -import { Input } from "@/components/ui/input" -import * as React from "react" - + DropdownMenu, + DropdownMenuTrigger, + DropdownMenuContent, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, +} from "@/components/ui/dropdown-menu"; +import { ChevronDown } from "lucide-react"; interface DataTableProps { - columns: ColumnDef[] - data: TData[] - searchKey: string - searchPlaceholder?: string + columns: ColumnDef[]; + data: TData[]; + searchKey: string; + searchPlaceholder?: string; } export function DataTable({ @@ -37,67 +37,118 @@ export function DataTable({ searchKey, searchPlaceholder, }: DataTableProps) { - const [sorting, setSorting] = React.useState([]) - const [columnFilters, setColumnFilters] = React.useState( - [] - ) + const [sorting, setSorting] = React.useState([]); + const [columnFilters, setColumnFilters] = React.useState([]); + const [pagination, setPagination] = React.useState({ + pageIndex: 0, + pageSize: 10, // Default page size + }); const table = useReactTable({ data, columns, - getCoreRowModel: getCoreRowModel(), - getPaginationRowModel: getPaginationRowModel(), - onSortingChange: setSorting, - getSortedRowModel: getSortedRowModel(), - onColumnFiltersChange: setColumnFilters, - getFilteredRowModel: getFilteredRowModel(), state: { sorting, columnFilters, + pagination, }, - }) + onSortingChange: setSorting, + onColumnFiltersChange: setColumnFilters, + onPaginationChange: setPagination, + getCoreRowModel: getCoreRowModel(), + getPaginationRowModel: getPaginationRowModel(), + getSortedRowModel: getSortedRowModel(), + getFilteredRowModel: getFilteredRowModel(), + }); return ( -
-
+
+
- table.getColumn(searchKey)?.setFilterValue(event.target.value) - } + onChange={(event) => table.getColumn(searchKey)?.setFilterValue(event.target.value)} className="max-w-sm" /> + + {/* Pagination Controls */} +
+ + Page {table.getState().pagination.pageIndex + 1} of {table.getPageCount()} + + + + + {/* Radix Dropdown for items per page */} + + + {/* Fixed width here to prevent layout shift */} + + + + + setPagination((prev) => ({ + ...prev, + pageSize: Number(value), + })) + } + > + 10 + 20 + 50 + 100 + + + +
+
- +
{table.getHeaderGroups().map((headerGroup) => ( - {headerGroup.headers.map((header) => { - return ( - - {header.isPlaceholder - ? null - : flexRender( - header.column.columnDef.header, - header.getContext() - )} - - ) - })} + {headerGroup.headers.map((header) => ( + + {header.isPlaceholder + ? null + : flexRender( + header.column.columnDef.header, + header.getContext() + )} + + ))} ))} {table.getRowModel().rows?.length ? ( table.getRowModel().rows.map((row) => ( - + {row.getVisibleCells().map((cell) => ( - + {flexRender(cell.column.columnDef.cell, cell.getContext())} ))} @@ -105,7 +156,10 @@ export function DataTable({ )) ) : ( - + No results. @@ -113,24 +167,6 @@ export function DataTable({
-
- - -
- ) + ); } diff --git a/packages/web/src/components/ui/dropdown-menu.tsx b/packages/web/src/components/ui/dropdown-menu.tsx index f69a0d64..9224a3cc 100644 --- a/packages/web/src/components/ui/dropdown-menu.tsx +++ b/packages/web/src/components/ui/dropdown-menu.tsx @@ -47,7 +47,7 @@ const DropdownMenuSubContent = React.forwardRef<