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 = { 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 (
Manage} /> {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 = (

{config.displayName}

{isAlphaEnabled && New}
) return (
{shortcutId ? ( {item} ) : ( item )}
) })}
{isPlatform && ( <>
Configuration} />

S3

)}
) }