diff --git a/apps/docs/components/APIDocs/Content/Bucket.tsx b/apps/docs/components/APIDocs/Content/Bucket.tsx new file mode 100644 index 00000000000..6b7e6e8e804 --- /dev/null +++ b/apps/docs/components/APIDocs/Content/Bucket.tsx @@ -0,0 +1,110 @@ +import { useParams } from 'common' +import { Badge } from 'ui' + +import { useBucketsQuery } from 'data/storage/buckets-query' +import { formatBytes } from 'lib/helpers' +import { useAppStateSnapshot } from 'state/app-state' +import { DOCS_RESOURCE_CONTENT } from '../ProjectAPIDocs.constants' +import ResourceContent from '../ResourceContent' +import type { ContentProps } from './Content.types' + +const Bucket = ({ language, apikey, endpoint }: ContentProps) => { + const { ref } = useParams() + const snap = useAppStateSnapshot() + const { data } = useBucketsQuery({ projectRef: ref }) + + const resource = snap.activeDocsSection[1] + const buckets = data ?? [] + const bucket = buckets.find((b) => b.name === resource) + const allowedMimeTypes = bucket?.allowed_mime_types + const maxFileSizeLimit = bucket?.file_size_limit + + if (bucket === undefined) return null + + return ( +
+ Allowed MIME types:{' '} + {allowedMimeTypes === null + ? 'All types are allowed' + : (allowedMimeTypes ?? []).length === 0 + ? 'No types are allowed' + : (allowedMimeTypes ?? []).length > 1 + ? (allowedMimeTypes ?? []).join(', ') + : 'Unknown'} +
++ Max file size limit:{' '} + {maxFileSizeLimit === null ? 'No limit' : `${formatBytes(maxFileSizeLimit)}`} +
++ Remember to re-generate and download this file as you make changes to your tables. +
++ {definition?.description ?? 'No description available'} +
+Columns
+