import { FilesBucket as FilesBucketIcon } from 'icons' import { ChevronRight } from 'lucide-react' import { KeyboardEventHandler, MouseEventHandler } from 'react' import { Badge, cn, TableCell, TableRow, Tooltip, TooltipContent, TooltipTrigger } from 'ui' import type { AllowedBucketType } from './types' import { PUBLIC_BUCKET_TOOLTIP } from '@/components/interfaces/Storage/Storage.constants' import { useBucketPolicyCount } from '@/components/interfaces/Storage/useBucketPolicyCount' import { VirtualizedTableCell, VirtualizedTableRow } from '@/components/ui/VirtualizedTable' import { Bucket } from '@/data/storage/buckets-query' import { formatBytes } from '@/lib/helpers' type BucketTableMode = 'standard' | 'virtualized' type BucketTableEmptyStateProps = { mode: BucketTableMode filterString: string } export const BucketTableEmptyState = ({ mode, filterString }: BucketTableEmptyStateProps) => { const BucketTableRow = mode === 'standard' ? TableRow : VirtualizedTableRow const BucketTableCell = mode === 'standard' ? TableCell : VirtualizedTableCell return (

No results found

Your search for “{filterString}” did not return any results

) } type BucketTableRowProps = { mode: BucketTableMode bucket: Bucket onSelectBucket: (bucket: Bucket) => void allowedBucketType: AllowedBucketType formattedGlobalUploadLimit: string } export const BucketTableRow = ({ mode, bucket, onSelectBucket, allowedBucketType, formattedGlobalUploadLimit, }: BucketTableRowProps) => { const { getPolicyCount } = useBucketPolicyCount() const BucketTableRow = mode === 'standard' ? TableRow : VirtualizedTableRow const BucketTableCell = mode === 'standard' ? TableCell : VirtualizedTableCell const isDisabled = !( allowedBucketType === 'all' || (allowedBucketType === 'public' && bucket.public) || (allowedBucketType === 'private' && !bucket.public) ) const handleRowActivate: MouseEventHandler = (e) => { e.preventDefault() if (isDisabled) return onSelectBucket(bucket) } const handleRowKeyDown: KeyboardEventHandler = (e) => { if (isDisabled) return if (e.key === 'Enter' || e.key === ' ') { e.preventDefault() onSelectBucket(bucket) } } return ( td]:hover:bg-transparent cursor-not-allowed' )} onClick={handleRowActivate} onKeyDown={handleRowKeyDown} tabIndex={isDisabled ? -1 : 0} aria-disabled={isDisabled || undefined} >

{bucket.id}

{bucket.public && ( Public {PUBLIC_BUCKET_TOOLTIP} )}

{getPolicyCount(bucket.id)}

{bucket.file_size_limit ? formatBytes(bucket.file_size_limit) : `Unset (${formattedGlobalUploadLimit})`}

{bucket.allowed_mime_types ? bucket.allowed_mime_types.join(', ') : 'Any'}

{!isDisabled && ( <>
)}
{isDisabled && ( {allowedBucketType === 'public' ? 'Private buckets are not selectable for this action. Please select a public bucket.' : 'Public buckets are not selectable for this action. Please select a private bucket.'} )}
) }