mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Context We've been seeing many `NotFoundError: Failed to execute 'removeChild' on 'Node'` and `NotFoundError: Failed to execute 'insertBefore' on 'Node'` events on Sentry which are historically known to be caused by Google Translate in the browser. There's technically no _right way_ to address this unfortunately, but one of the solutions which should address most of these issues is to wrap any dynamic text within a span - we've considered that quite a while back tbh but never took the time to do this until today with the help of Claude. Although just a heads up that it might not necessarily completely eradicate those issues. Also added an eslint rule which should prevent future occurences of this <img width="1264" height="192" alt="image" src="https://github.com/user-attachments/assets/b2c32ea0-45a2-4ccd-82fe-1a859905fc29" />
114 lines
3.5 KiB
TypeScript
114 lines
3.5 KiB
TypeScript
import { useParams } from 'common'
|
|
import { Badge } from 'ui'
|
|
|
|
import { DOCS_RESOURCE_CONTENT } from '../ProjectAPIDocs.constants'
|
|
import ResourceContent from '../ResourceContent'
|
|
import type { ContentProps } from './Content.types'
|
|
import { useBucketInfoQueryPreferCached } from '@/data/storage/buckets-query'
|
|
import { formatBytes } from '@/lib/helpers'
|
|
import { useAppStateSnapshot } from '@/state/app-state'
|
|
|
|
export const Bucket = ({ language, apikey, endpoint }: ContentProps) => {
|
|
const { ref } = useParams()
|
|
|
|
const snap = useAppStateSnapshot()
|
|
const resource = snap.activeDocsSection[1]
|
|
|
|
const bucket = useBucketInfoQueryPreferCached(resource, ref)
|
|
const allowedMimeTypes = bucket?.allowed_mime_types
|
|
const maxFileSizeLimit = bucket?.file_size_limit
|
|
|
|
if (bucket === undefined) return null
|
|
|
|
return (
|
|
<div className="divide-y">
|
|
<div className="space-y-1 px-4 py-4">
|
|
<div className="flex items-center space-x-2">
|
|
<h2>{bucket.name}</h2>
|
|
<Badge variant={bucket.public ? 'warning' : 'default'}>
|
|
{bucket.public ? 'Public' : 'Private'}
|
|
</Badge>
|
|
</div>
|
|
<p className="text-sm text-foreground-light">
|
|
Allowed MIME types:{' '}
|
|
{allowedMimeTypes === null ? (
|
|
<span>All types are allowed</span>
|
|
) : (allowedMimeTypes ?? []).length === 0 ? (
|
|
<span>No types are allowed</span>
|
|
) : (allowedMimeTypes ?? []).length > 1 ? (
|
|
(allowedMimeTypes ?? []).join(', ')
|
|
) : (
|
|
<span>Unknown</span>
|
|
)}
|
|
</p>
|
|
<p className="text-sm text-foreground-light">
|
|
Max file size limit:{' '}
|
|
{maxFileSizeLimit === null ? (
|
|
<span>No limit</span>
|
|
) : (
|
|
<span>{`${formatBytes(maxFileSizeLimit)}`}</span>
|
|
)}
|
|
</p>
|
|
</div>
|
|
|
|
<ResourceContent
|
|
selectedLanguage={language}
|
|
snippet={DOCS_RESOURCE_CONTENT.uploadFile}
|
|
codeSnippets={DOCS_RESOURCE_CONTENT.uploadFile.code({
|
|
name: resource,
|
|
apikey,
|
|
endpoint,
|
|
})}
|
|
/>
|
|
<ResourceContent
|
|
selectedLanguage={language}
|
|
snippet={DOCS_RESOURCE_CONTENT.deleteFiles}
|
|
codeSnippets={DOCS_RESOURCE_CONTENT.deleteFiles.code({
|
|
name: resource,
|
|
apikey,
|
|
endpoint,
|
|
})}
|
|
/>
|
|
<ResourceContent
|
|
selectedLanguage={language}
|
|
snippet={DOCS_RESOURCE_CONTENT.listFiles}
|
|
codeSnippets={DOCS_RESOURCE_CONTENT.listFiles.code({
|
|
name: resource,
|
|
apikey,
|
|
endpoint,
|
|
})}
|
|
/>
|
|
<ResourceContent
|
|
selectedLanguage={language}
|
|
snippet={DOCS_RESOURCE_CONTENT.downloadFile}
|
|
codeSnippets={DOCS_RESOURCE_CONTENT.downloadFile.code({
|
|
name: resource,
|
|
apikey,
|
|
endpoint,
|
|
})}
|
|
/>
|
|
{bucket.public ? (
|
|
<ResourceContent
|
|
selectedLanguage={language}
|
|
snippet={DOCS_RESOURCE_CONTENT.retrievePublicURL}
|
|
codeSnippets={DOCS_RESOURCE_CONTENT.retrievePublicURL.code({
|
|
name: resource,
|
|
apikey,
|
|
endpoint,
|
|
})}
|
|
/>
|
|
) : (
|
|
<ResourceContent
|
|
selectedLanguage={language}
|
|
snippet={DOCS_RESOURCE_CONTENT.createSignedURL}
|
|
codeSnippets={DOCS_RESOURCE_CONTENT.createSignedURL.code({
|
|
name: resource,
|
|
apikey,
|
|
endpoint,
|
|
})}
|
|
/>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|