index.tsx43 lines · main
| 1 | import { useParams } from 'common' |
| 2 | |
| 3 | import { BucketsUpgradePlan } from '@/components/interfaces/Storage/BucketsUpgradePlan' |
| 4 | import { VectorsBuckets } from '@/components/interfaces/Storage/VectorBuckets' |
| 5 | import { |
| 6 | RegionLimitation, |
| 7 | VECTOR_BUCKETS_AVAILABLE_REGIONS, |
| 8 | } from '@/components/interfaces/Storage/VectorBuckets/RegionLimitation' |
| 9 | import { DefaultLayout } from '@/components/layouts/DefaultLayout' |
| 10 | import { StorageBucketsLayout } from '@/components/layouts/StorageLayout/StorageBucketsLayout' |
| 11 | import StorageLayout from '@/components/layouts/StorageLayout/StorageLayout' |
| 12 | import { useIsVectorBucketsEnabled } from '@/data/config/project-storage-config-query' |
| 13 | import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject' |
| 14 | import type { NextPageWithLayout } from '@/types' |
| 15 | |
| 16 | const StorageVectorsPage: NextPageWithLayout = () => { |
| 17 | const { ref: projectRef } = useParams() |
| 18 | const { data: project } = useSelectedProjectQuery() |
| 19 | const isVectorBucketsEnabled = useIsVectorBucketsEnabled({ projectRef }) |
| 20 | |
| 21 | // [Joshen] We're actively looking into lifting this restriction so can remove once done |
| 22 | const isAvailableInProjectRegion = VECTOR_BUCKETS_AVAILABLE_REGIONS.includes( |
| 23 | project?.region ?? '' |
| 24 | ) |
| 25 | |
| 26 | if (!isAvailableInProjectRegion) { |
| 27 | return <RegionLimitation /> |
| 28 | } else if (!isVectorBucketsEnabled) { |
| 29 | return <BucketsUpgradePlan type="vector" /> |
| 30 | } else { |
| 31 | return <VectorsBuckets /> |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | StorageVectorsPage.getLayout = (page) => ( |
| 36 | <DefaultLayout> |
| 37 | <StorageLayout title="Vectors"> |
| 38 | <StorageBucketsLayout>{page}</StorageBucketsLayout> |
| 39 | </StorageLayout> |
| 40 | </DefaultLayout> |
| 41 | ) |
| 42 | |
| 43 | export default StorageVectorsPage |