mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 21:05:06 +03:00
* badge and admonition updates * whole file row tappable * file bucket improvements * match tables across all storage types * keyboard focussable rows * share function * other bucket types * fix: a11y of table rows * clean up focus state on rows * accessibility * address review comments * move accessibility --------- Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
91 lines
2.6 KiB
TypeScript
91 lines
2.6 KiB
TypeScript
import { VirtualizedTable, VirtualizedTableBody } from 'components/ui/VirtualizedTable'
|
|
import { Bucket } from 'data/storage/buckets-query'
|
|
import { Table, TableBody } from 'ui'
|
|
import { BucketTableEmptyState, BucketTableHeader, BucketTableRow } from './BucketTable'
|
|
|
|
type BucketsTableProps = {
|
|
buckets: Bucket[]
|
|
projectRef: string
|
|
filterString: string
|
|
formattedGlobalUploadLimit: string
|
|
getPolicyCount: (bucketName: string) => number
|
|
}
|
|
|
|
export const BucketsTable = (props: BucketsTableProps) => {
|
|
const isVirtualized = props.buckets.length > 50
|
|
return isVirtualized ? (
|
|
<BucketsTableVirtualized {...props} />
|
|
) : (
|
|
<BucketsTableUnvirtualized {...props} />
|
|
)
|
|
}
|
|
|
|
const BucketsTableUnvirtualized = ({
|
|
buckets,
|
|
projectRef,
|
|
filterString,
|
|
formattedGlobalUploadLimit,
|
|
getPolicyCount,
|
|
}: BucketsTableProps) => {
|
|
const showSearchEmptyState = buckets.length === 0 && filterString.length > 0
|
|
|
|
return (
|
|
<Table
|
|
containerProps={{ containerClassName: 'h-full overflow-auto', className: 'overflow-visible' }}
|
|
>
|
|
<BucketTableHeader mode="standard" hasBuckets={buckets.length > 0} />
|
|
<TableBody>
|
|
{showSearchEmptyState ? (
|
|
<BucketTableEmptyState mode="standard" filterString={filterString} />
|
|
) : (
|
|
buckets.map((bucket) => (
|
|
<BucketTableRow
|
|
mode="standard"
|
|
key={bucket.id}
|
|
bucket={bucket}
|
|
projectRef={projectRef}
|
|
formattedGlobalUploadLimit={formattedGlobalUploadLimit}
|
|
getPolicyCount={getPolicyCount}
|
|
/>
|
|
))
|
|
)}
|
|
</TableBody>
|
|
</Table>
|
|
)
|
|
}
|
|
|
|
const BucketsTableVirtualized = ({
|
|
buckets,
|
|
projectRef,
|
|
filterString,
|
|
formattedGlobalUploadLimit,
|
|
getPolicyCount,
|
|
}: BucketsTableProps) => {
|
|
const showSearchEmptyState = buckets.length === 0 && filterString.length > 0
|
|
|
|
return (
|
|
<VirtualizedTable data={buckets} estimateSize={() => 59} getItemKey={(bucket) => bucket.id}>
|
|
<BucketTableHeader mode="virtualized" hasBuckets={buckets.length > 0} />
|
|
<VirtualizedTableBody<Bucket>
|
|
paddingColSpan={5}
|
|
emptyContent={
|
|
showSearchEmptyState ? (
|
|
<BucketTableEmptyState mode="virtualized" filterString={filterString} />
|
|
) : undefined
|
|
}
|
|
>
|
|
{(bucket) => (
|
|
<BucketTableRow
|
|
mode="virtualized"
|
|
key={bucket.id}
|
|
bucket={bucket}
|
|
projectRef={projectRef}
|
|
formattedGlobalUploadLimit={formattedGlobalUploadLimit}
|
|
getPolicyCount={getPolicyCount}
|
|
/>
|
|
)}
|
|
</VirtualizedTableBody>
|
|
</VirtualizedTable>
|
|
)
|
|
}
|