// @ts-nocheck import { LOCAL_STORAGE_KEYS, useParams } from 'common' import { ExternalLink, Eye, EyeOff, FlaskConical } from 'lucide-react' import Link from 'next/link' import { ReactNode } from 'react' import { Badge, Button, cn, Dialog, DialogContent, DialogDescription, DialogHeader, DialogSection, DialogSectionSeparator, DialogTitle, ScrollArea, } from 'ui' import { Select, SelectContent, SelectItem, SelectTrigger, } from 'ui/src/components/shadcn/ui/select' import { AdvisorRulesPreview } from './AdvisorRulesPreview' import { CLSPreview } from './CLSPreview' import { useFeaturePreviewContext, useFeaturePreviewModal } from './FeaturePreviewContext' import { JitDbAccessPreview } from './JitDbAccessPreview' import { MarketplacePreview } from './MarketplacePreview' import { PgDeltaDiffPreview } from './PgDeltaDiffPreview' import { PlatformWebhooksPreview } from './PlatformWebhooksPreview' import { RLSTesterPreview } from './RLSTesterPreview' import { UnifiedLogsPreview } from './UnifiedLogsPreview' import { FeaturePreview, useFeaturePreviews } from './useFeaturePreviews' import { useBannerStack } from '@/components/ui/BannerStack/BannerStackProvider' import { useSendEventMutation } from '@/data/telemetry/send-event-mutation' import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage' import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization' import { IS_PLATFORM } from '@/lib/constants' const FEATURE_PREVIEW_KEY_TO_CONTENT: { [key: string]: ReactNode } = { [LOCAL_STORAGE_KEYS.UI_PREVIEW_PG_DELTA_DIFF]: , [LOCAL_STORAGE_KEYS.UI_PREVIEW_ADVISOR_RULES]: , [LOCAL_STORAGE_KEYS.UI_PREVIEW_CLS]: , [LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS]: , [LOCAL_STORAGE_KEYS.UI_PREVIEW_PLATFORM_WEBHOOKS]: , [LOCAL_STORAGE_KEYS.UI_PREVIEW_JIT_DB_ACCESS]: , [LOCAL_STORAGE_KEYS.UI_PREVIEW_RLS_TESTER]: , [LOCAL_STORAGE_KEYS.UI_PREVIEW_MARKETPLACE]: , } export const FeaturePreviewModal = () => { const { ref } = useParams() const featurePreviews = useFeaturePreviews() const { showFeaturePreviewModal, selectedFeatureKey, selectFeaturePreview, toggleFeaturePreviewModal, } = useFeaturePreviewModal() const { data: org } = useSelectedOrganizationQuery() const featurePreviewContext = useFeaturePreviewContext() const { mutate: sendEvent } = useSendEventMutation() const { dismissBanner } = useBannerStack() const [, setIsDismissedRlsTesterBanner] = useLocalStorageQuery( LOCAL_STORAGE_KEYS.RLS_TESTER_BANNER_DISMISSED(ref ?? ''), false ) const { flags, onUpdateFlag } = featurePreviewContext const allFeaturePreviews = ( IS_PLATFORM ? featurePreviews : featurePreviews.filter((x) => !x.isPlatformOnly) ).filter((x) => x.enabled) const selectedFeature = allFeaturePreviews.find((preview) => preview.key === selectedFeatureKey) ?? allFeaturePreviews[0] const isSelectedFeatureEnabled = flags[selectedFeature?.key] const toggleFeature = () => { if (!selectedFeature) return if (selectedFeature.key === LOCAL_STORAGE_KEYS.UI_PREVIEW_RLS_TESTER) { dismissBanner('rls-tester-banner') setIsDismissedRlsTesterBanner(true) } onUpdateFlag(selectedFeature.key, !isSelectedFeatureEnabled) sendEvent({ action: isSelectedFeatureEnabled ? 'feature_preview_disabled' : 'feature_preview_enabled', properties: { feature: selectedFeature.key }, groups: { project: ref ?? 'Unknown', organization: org?.slug ?? 'Unknown' }, }) } return ( Dashboard feature previews Get early access to new features and give feedback {allFeaturePreviews.length > 0 ? (
{allFeaturePreviews.map((feature) => ( ))}

{selectedFeature?.name}

{selectedFeature?.discussionsUrl !== undefined && ( )}
{FEATURE_PREVIEW_KEY_TO_CONTENT[selectedFeature?.key ?? '']}
) : (

No feature previews available

Have an idea for the dashboard? Let us know via GitHub Discussions!

)}
) } const FeaturePreviewItem = ({ feature, selectedFeature, selectFeaturePreview, className, }: { feature: FeaturePreview selectedFeature: FeaturePreview selectFeaturePreview: (key: string) => void className?: string }) => { const featurePreviewContext = useFeaturePreviewContext() const { flags } = featurePreviewContext const isEnabled = flags[feature.key] ?? false return ( ) }