import { LOCAL_STORAGE_KEYS, useParams } from 'common' import { useSendEventMutation } from 'data/telemetry/send-event-mutation' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { IS_PLATFORM } from 'lib/constants' 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 { AdvisorRulesPreview } from './AdvisorRulesPreview' import { APISidePanelPreview } from './APISidePanelPreview' import { Branching2Preview } from './Branching2Preview' import { CLSPreview } from './CLSPreview' import { useFeaturePreviewContext, useFeaturePreviewModal } from './FeaturePreviewContext' import { PgDeltaDiffPreview } from './PgDeltaDiffPreview' import { QueueOperationsPreview } from './QueueOperationsPreview' import { TableFilterBarPreview } from './TableFilterBarPreview' import { UnifiedLogsPreview } from './UnifiedLogsPreview' import { useFeaturePreviews } from './useFeaturePreviews' import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage' const FEATURE_PREVIEW_KEY_TO_CONTENT: { [key: string]: ReactNode } = { [LOCAL_STORAGE_KEYS.UI_PREVIEW_BRANCHING_2_0]: , [LOCAL_STORAGE_KEYS.UI_PREVIEW_PG_DELTA_DIFF]: , [LOCAL_STORAGE_KEYS.UI_PREVIEW_ADVISOR_RULES]: , [LOCAL_STORAGE_KEYS.UI_PREVIEW_API_SIDE_PANEL]: , [LOCAL_STORAGE_KEYS.UI_PREVIEW_CLS]: , [LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS]: , [LOCAL_STORAGE_KEYS.UI_PREVIEW_QUEUE_OPERATIONS]: , [LOCAL_STORAGE_KEYS.UI_PREVIEW_TABLE_FILTER_BAR]: , } 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 [isDismissedTableFilterBar, setIsDismissedTableFilterBar] = useLocalStorageQuery( LOCAL_STORAGE_KEYS.TABLE_EDITOR_NEW_FILTER_BANNER_DISMISSED(ref ?? ''), false ) const { flags, onUpdateFlag } = featurePreviewContext const selectedFeature = featurePreviews.find((preview) => preview.key === selectedFeatureKey) ?? featurePreviews[0] const isSelectedFeatureEnabled = flags[selectedFeatureKey] const allFeaturePreviews = IS_PLATFORM ? featurePreviews : featurePreviews.filter((x) => !x.isPlatformOnly) const toggleFeature = () => { 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' }, }) if ( selectedFeature.key === LOCAL_STORAGE_KEYS.UI_PREVIEW_TABLE_FILTER_BAR && !isDismissedTableFilterBar ) { setIsDismissedTableFilterBar(true) } } return ( Dashboard feature previews Get early access to new features and give feedback {featurePreviews.length > 0 ? (
{allFeaturePreviews.map((feature) => { const isEnabled = flags[feature.key] ?? false return (
selectFeaturePreview(feature.key)} className={cn( 'flex items-center justify-between p-4 border-b cursor-pointer bg transition', selectedFeature.key === feature.key ? 'bg-surface-300' : 'bg-surface-100' )} >
{isEnabled ? ( ) : ( )}

{feature.name}

{feature.isNew && New}
) })}

{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!

)}
) }