import { useTelemetryProps } from 'common' import { useRouter } from 'next/router' import { useState } from 'react' import { Button, IconExternalLink, IconEye, IconEyeOff, Modal, ScrollArea, cn } from 'ui' import { LOCAL_STORAGE_KEYS } from 'lib/constants' import Telemetry from 'lib/telemetry' import { useAppStateSnapshot } from 'state/app-state' import APISidePanelPreview from './APISidePanelPreview' import { useFeaturePreviewContext } from './FeaturePreviewContext' import Link from 'next/link' // [Ivan] We should probably move this to a separate file, together with LOCAL_STORAGE_KEYS. We should make adding new feature previews as simple as possible. const FEATURE_PREVIEWS = [ // { // key: LOCAL_STORAGE_KEYS.UI_PREVIEW_NAVIGATION_LAYOUT, // name: 'Global navigation update', // content: null // }, { key: LOCAL_STORAGE_KEYS.UI_PREVIEW_API_SIDE_PANEL, name: 'Project API documentation', content: , discussionsUrl: 'https://github.com/orgs/supabase/discussions/18038', }, ] const FeaturePreviewModal = () => { const router = useRouter() const snap = useAppStateSnapshot() const telemetryProps = useTelemetryProps() const featurePreviewContext = useFeaturePreviewContext() const [selectedFeatureKey, setSelectedFeatureKey] = useState(FEATURE_PREVIEWS[0].key) const { flags, onUpdateFlag } = featurePreviewContext const selectedFeature = FEATURE_PREVIEWS.find((preview) => preview.key === selectedFeatureKey) const isSelectedFeatureEnabled = flags[selectedFeatureKey] const toggleFeature = () => { onUpdateFlag(selectedFeatureKey, !isSelectedFeatureEnabled) Telemetry.sendEvent( { category: 'ui_feature_previews', action: isSelectedFeatureEnabled ? 'disabled' : 'enabled', label: selectedFeatureKey, }, telemetryProps, router ) } return ( snap.setShowFeaturePreviewModal(false)} > {FEATURE_PREVIEWS.map((feature) => { const isEnabled = flags[feature.key] ?? false return ( setSelectedFeatureKey(feature.key)} className={cn( 'flex items-center space-x-3 p-4 border-b cursor-pointer bg transition', selectedFeatureKey === feature.key ? 'bg-surface-200' : '' )} > {isEnabled ? ( ) : ( )} {feature.name} ) })} {selectedFeature?.name} {selectedFeature?.discussionsUrl !== undefined && ( }> Give feedback )} toggleFeature()}> {isSelectedFeatureEnabled ? 'Disable' : 'Enable'} feature {selectedFeature?.content} ) } export default FeaturePreviewModal
{feature.name}
{selectedFeature?.name}