mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 21:29:08 +03:00
* chore: separate interfaces per bucket type * chore: reuse existing bucket creation modal for files * chore: allow external trigger for new bucket modal * chore: minor fixes * chore: full-size empty state * chore: files other tabs * fix: show tab bar when on file subroute * chore: use existing table component to list buckets * fix: tests * fix: build error * chore: remove future bucket type components from PR * fix: dependency * Couple of refactors to simplify implementation * Fix TS * chore: move s3 settings out to sidebar * fix: minor nits * fix: reuse existing loading spinners from schema visualiser * fix: loading for files * fix: prevent loading of table for zero buckets * chore: improved loading state * chore: shimmer on table * chore: copywriting on S3 * chore: improve empty states * fix: deprecated input instructions * fix: filter/search bucket table * chore: tidy * fix: tests * Minor refactors * Rename * Nit * Shift V2 re-routing logic to layout level --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import { useRouter } from 'next/router'
|
|
import { PropsWithChildren, useEffect } from 'react'
|
|
|
|
import { useParams } from 'common'
|
|
import { useIsNewStorageUIEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
|
|
import { BUCKET_TYPES } from 'components/interfaces/Storage/Storage.constants'
|
|
import { useStorageV2Page } from 'components/interfaces/Storage/Storage.utils'
|
|
import { DocsButton } from 'components/ui/DocsButton'
|
|
import { PageLayout } from '../PageLayout/PageLayout'
|
|
import { ScaffoldContainer } from '../Scaffold'
|
|
|
|
export const StorageBucketsLayout = ({
|
|
title,
|
|
hideSubtitle = false,
|
|
children,
|
|
}: PropsWithChildren<{ title?: string; hideSubtitle?: boolean }>) => {
|
|
const { ref } = useParams()
|
|
const router = useRouter()
|
|
const page = useStorageV2Page()
|
|
const isStorageV2 = useIsNewStorageUIEnabled()
|
|
|
|
const config = !!page && page !== 's3' ? BUCKET_TYPES[page] : undefined
|
|
|
|
const navigationItems =
|
|
page === 'files'
|
|
? [
|
|
{
|
|
label: 'Buckets',
|
|
href: `/project/${ref}/storage/files`,
|
|
},
|
|
{
|
|
label: 'Settings',
|
|
href: `/project/${ref}/storage/files/settings`,
|
|
},
|
|
{
|
|
label: 'Policies',
|
|
href: `/project/${ref}/storage/files/policies`,
|
|
},
|
|
]
|
|
: []
|
|
|
|
useEffect(() => {
|
|
if (!isStorageV2) router.replace(`/project/${ref}/storage/buckets`)
|
|
}, [isStorageV2, ref, router])
|
|
|
|
return (
|
|
<PageLayout
|
|
title={title || (config?.displayName ?? 'Storage')}
|
|
subtitle={
|
|
hideSubtitle ? config?.description || 'Manage your storage buckets and files.' : null
|
|
}
|
|
navigationItems={navigationItems}
|
|
secondaryActions={config?.docsUrl ? [<DocsButton key="docs" href={config.docsUrl} />] : []}
|
|
>
|
|
<ScaffoldContainer>{children}</ScaffoldContainer>
|
|
</PageLayout>
|
|
)
|
|
}
|