Files
supabase/apps/studio/components/interfaces/Storage/BucketsPickerDialog/BucketsTable.tsx
Ivan Vasilov 35905e70d5 feat: Add a logo picker for OAuth app creation sheet (#44995)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Logo field now accepts/editable logo URL, plus a new storage-based
Logo Picker to select or remove images from project storage.
* Full storage picker: browse buckets, columns/list views, search,
drag‑and‑drop uploads, file previews (image/audio/video), and
single-file selection with responsive mobile/desktop layouts.

* **Refactor**
* Logo submission streamlined to send the provided URL directly (legacy
file-read/upload flow removed).
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-06 16:44:18 +02:00

125 lines
3.6 KiB
TypeScript

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 ? (
<BucketsTableVirtualized {...props} />
) : (
<BucketsTableUnvirtualized {...props} />
)
}
const BucketsTableUnvirtualized = ({
buckets,
filterString,
formattedGlobalUploadLimit,
onSelectBucket,
allowedBucketType,
pagination: { hasMore = false, isLoadingMore = false, onLoadMore },
}: 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}
onSelectBucket={onSelectBucket}
allowedBucketType={allowedBucketType}
formattedGlobalUploadLimit={formattedGlobalUploadLimit}
/>
))
)}
<LoadMoreRow
mode="standard"
colSpan={6}
hasMore={hasMore}
isLoadingMore={isLoadingMore}
onLoadMore={onLoadMore}
/>
</TableBody>
</Table>
)
}
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<HTMLDivElement>(null)
return (
<VirtualizedTable
data={buckets}
estimateSize={() => 59}
getItemKey={(bucket) => bucket.id}
scrollContainerRef={scrollContainerRef}
>
<BucketTableHeader mode="virtualized" hasBuckets={buckets.length > 0} />
<VirtualizedTableBody<Bucket>
paddingColSpan={5}
emptyContent={
showSearchEmptyState ? (
<BucketTableEmptyState mode="virtualized" filterString={filterString} />
) : undefined
}
trailingContent={
<LoadMoreRow
mode="virtualized"
colSpan={6}
hasMore={hasMore}
isLoadingMore={isLoadingMore}
onLoadMore={onLoadMore}
/>
}
>
{(bucket) => (
<BucketTableRow
mode="virtualized"
key={bucket.id}
bucket={bucket}
onSelectBucket={onSelectBucket}
allowedBucketType={allowedBucketType}
formattedGlobalUploadLimit={formattedGlobalUploadLimit}
/>
)}
</VirtualizedTableBody>
</VirtualizedTable>
)
}