import { useRef } from 'react' import { Table, TableBody } from 'ui' import { LoadMoreRow } from './BucketsTable.LoadMoreRow' import { BucketTableHeader } from './BucketTableHeader' import { BucketTableEmptyState, BucketTableRow } from './BucketTableRow' import type { AllowedBucketType, BucketsTablePaginationProps } from './types' import { VirtualizedTable, VirtualizedTableBody } from '@/components/ui/VirtualizedTable' import { type Bucket } from '@/data/storage/buckets-query' type BucketsTableProps = { buckets: Bucket[] projectRef: string filterString: string formattedGlobalUploadLimit: string onSelectBucket: (bucket: Bucket) => void allowedBucketType: AllowedBucketType pagination: BucketsTablePaginationProps } export const BucketsTable = (props: BucketsTableProps) => { const isVirtualized = props.buckets.length > 50 return isVirtualized ? ( ) : ( ) } const BucketsTableUnvirtualized = ({ buckets, filterString, formattedGlobalUploadLimit, onSelectBucket, allowedBucketType, pagination: { hasMore = false, isLoadingMore = false, onLoadMore }, }: BucketsTableProps) => { const showSearchEmptyState = buckets.length === 0 && filterString.length > 0 return ( 0} /> {showSearchEmptyState ? ( ) : ( buckets.map((bucket) => ( )) )}
) } const BucketsTableVirtualized = ({ buckets, filterString, formattedGlobalUploadLimit, onSelectBucket, allowedBucketType, pagination: { hasMore = false, isLoadingMore = false, onLoadMore }, }: BucketsTableProps) => { const showSearchEmptyState = buckets.length === 0 && filterString.length > 0 const scrollContainerRef = useRef(null) return ( 59} getItemKey={(bucket) => bucket.id} scrollContainerRef={scrollContainerRef} > 0} /> paddingColSpan={5} emptyContent={ showSearchEmptyState ? ( ) : undefined } trailingContent={ } > {(bucket) => ( )} ) }