mirror of
https://github.com/supabase/supabase.git
synced 2026-06-12 08:29:15 +08:00
## Context > [!IMPORTANT] > Will open up for review once CLI PR is merged and deployed so that it's easier to test Related PR: https://github.com/supabase/cli/pull/5230 Adding support for vector buckets for local CLI - will need to be tested locally via `pnpm run dev:studio-local` ## To test There's a bit of testing instructions in the linear ticket [here](https://linear.app/supabase/issue/FE-3474/show-vector-buckets-in-local-admin-studio) as it involves using a branch of CLI - otherwise do reach out to Fabrizio if any help might be needed, but generally: ### Local CLI You might need to manually set `isCli` to `true` in `StorageMenuV2` if the "Vectors" nav item isn't showing up on the storage UI given we're testing via `pnpm run dev:studio-local` - [x] Can create bucket - [x] Can delete bucket - [x] Can create indexes - [x] Can insert data into indexes (via FDW) - [x] Can delete indexes Known issues (that aren't directly solvable from FE end) Reach out to Fabrizio for context as we were both investigating this - PG database needs to be on 17.6 (otherwise there's no S3 vectors FDW) - Storage version needs to be on 1.59.0 ### Self-hosted (This might be tricky to actually test, but just ensure that the code satisfies this) - [x] Cannot see vector buckets ### Hosted - [x] Everything works status quo <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Vector bucket management UI and platform APIs (create/list/delete buckets & indexes) * Local S3 credentials endpoint and client-side hook for self‑hosted/CLI use * **Bug Fixes** * Improved S3 vector setup notifications and clearer error guidance for manual installation * **Refactor** * Deployment-mode gating: platform vs CLI/self‑hosted now controls feature visibility and page behavior * **Tests** * Added suites covering deployment-mode gates and vector bucket error/usage scenarios * **Chores** * Build env updated to expose local S3 credential vars <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46381?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Ali Waseem <waseema393@gmail.com>
125 lines
4.3 KiB
TypeScript
125 lines
4.3 KiB
TypeScript
import { useParams } from 'common'
|
|
import Link from 'next/link'
|
|
import { useRouter } from 'next/router'
|
|
import { Badge, Menu } from 'ui'
|
|
|
|
import { BUCKET_TYPES } from './Storage.constants'
|
|
import { useStorageV2Page } from './Storage.utils'
|
|
import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
|
|
import {
|
|
useIsAnalyticsBucketsEnabled,
|
|
useIsVectorBucketsEnabled,
|
|
} from '@/data/config/project-storage-config-query'
|
|
import { useDeploymentMode } from '@/hooks/misc/useDeploymentMode'
|
|
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
|
|
import { SHORTCUT_IDS, type ShortcutId } from '@/state/shortcuts/registry'
|
|
import { useShortcut } from '@/state/shortcuts/useShortcut'
|
|
|
|
const BUCKET_TYPE_SHORTCUTS: Record<keyof typeof BUCKET_TYPES, ShortcutId> = {
|
|
files: SHORTCUT_IDS.NAV_STORAGE_FILES,
|
|
analytics: SHORTCUT_IDS.NAV_STORAGE_ANALYTICS,
|
|
vectors: SHORTCUT_IDS.NAV_STORAGE_VECTORS,
|
|
}
|
|
|
|
export const StorageMenuV2 = () => {
|
|
const router = useRouter()
|
|
const { ref } = useParams()
|
|
const page = useStorageV2Page()
|
|
|
|
const { isCli, isPlatform } = useDeploymentMode()
|
|
|
|
const { storageAnalytics, storageVectors } = useIsFeatureEnabled([
|
|
'storage:analytics',
|
|
'storage:vectors',
|
|
])
|
|
|
|
const isAnalyticsBucketsEnabled = useIsAnalyticsBucketsEnabled({ projectRef: ref })
|
|
const isVectorBucketsEnabled = useIsVectorBucketsEnabled({ projectRef: ref })
|
|
|
|
const showAnalytics = isPlatform && storageAnalytics
|
|
const showVectors = (isPlatform && storageVectors) || isCli
|
|
|
|
useShortcut(SHORTCUT_IDS.NAV_STORAGE_FILES, () => router.push(`/project/${ref}/storage/files`))
|
|
useShortcut(
|
|
SHORTCUT_IDS.NAV_STORAGE_ANALYTICS,
|
|
() => router.push(`/project/${ref}/storage/analytics`),
|
|
{ enabled: showAnalytics }
|
|
)
|
|
useShortcut(
|
|
SHORTCUT_IDS.NAV_STORAGE_VECTORS,
|
|
() => router.push(`/project/${ref}/storage/vectors`),
|
|
{ enabled: showVectors }
|
|
)
|
|
useShortcut(SHORTCUT_IDS.NAV_STORAGE_S3, () => router.push(`/project/${ref}/storage/s3`), {
|
|
enabled: isPlatform,
|
|
})
|
|
|
|
const bucketTypes = Object.entries(BUCKET_TYPES).filter(([key]) => {
|
|
if (key === 'analytics') return showAnalytics
|
|
if (key === 'vectors') return showVectors
|
|
return true
|
|
})
|
|
|
|
return (
|
|
<Menu type="pills" className="my-2 md:my-4 flex grow flex-col">
|
|
<div className="space-y-4">
|
|
<div className="md:mx-3">
|
|
<Menu.Group title={<span className="uppercase font-mono">Manage</span>} />
|
|
|
|
{bucketTypes.map(([type, config]) => {
|
|
const isSelected = page === type
|
|
const isAlphaEnabled =
|
|
(type === 'analytics' && isAnalyticsBucketsEnabled) ||
|
|
(type === 'vectors' && isVectorBucketsEnabled)
|
|
const shortcutId = BUCKET_TYPE_SHORTCUTS[type as keyof typeof BUCKET_TYPES]
|
|
|
|
const item = (
|
|
<Link href={`/project/${ref}/storage/${type}`}>
|
|
<Menu.Item rounded active={isSelected}>
|
|
<div className="flex items-center justify-between">
|
|
<p className="truncate">{config.displayName}</p>
|
|
{isAlphaEnabled && <Badge variant="success">New</Badge>}
|
|
</div>
|
|
</Menu.Item>
|
|
</Link>
|
|
)
|
|
|
|
return (
|
|
<div key={type}>
|
|
{shortcutId ? (
|
|
<ShortcutTooltip shortcutId={shortcutId} side="right" delayDuration={1000}>
|
|
{item}
|
|
</ShortcutTooltip>
|
|
) : (
|
|
item
|
|
)}
|
|
</div>
|
|
)
|
|
})}
|
|
</div>
|
|
|
|
{isPlatform && (
|
|
<>
|
|
<div className="h-px w-[calc(100%-1.5rem)] mx-auto md:w-full bg-border" />
|
|
<div className="md:mx-3">
|
|
<Menu.Group title={<span className="uppercase font-mono">Configuration</span>} />
|
|
|
|
<ShortcutTooltip
|
|
shortcutId={SHORTCUT_IDS.NAV_STORAGE_S3}
|
|
side="right"
|
|
delayDuration={1000}
|
|
>
|
|
<Link href={`/project/${ref}/storage/s3`}>
|
|
<Menu.Item rounded active={page === 's3'}>
|
|
<p className="truncate">S3</p>
|
|
</Menu.Item>
|
|
</Link>
|
|
</ShortcutTooltip>
|
|
</div>
|
|
</>
|
|
)}
|
|
</div>
|
|
</Menu>
|
|
)
|
|
}
|