import { useNavigate } from '@tanstack/react-router' import { LOCAL_STORAGE_KEYS, useParams } from 'common' import { CircleHelpIcon, Undo2Icon, XIcon } from 'lucide-react' import { Badge, Button, cn } from 'ui' import { useFeaturePreviewModal, useUnifiedLogsPreview, } from '../App/FeaturePreview/FeaturePreviewContext' import { ButtonTooltip } from '@/components/ui/ButtonTooltip' import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage' import { IS_PLATFORM } from '@/lib/constants' import { navigateToUrl } from '@/lib/navigation' interface UnifiedLogsBannerProps { className?: string } export function UnifiedLogsBanner({ className = 'mx-4 mt-4' }: UnifiedLogsBannerProps) { const navigate = useNavigate() const { ref } = useParams() const { selectFeaturePreview } = useFeaturePreviewModal() const { enable, disable, isDefaultOptIn, isEnabled } = useUnifiedLogsPreview() const [isDismissed, setIsDismissed] = useLocalStorageQuery( LOCAL_STORAGE_KEYS.UNIFIED_LOGS_SIDEBAR_BANNER_DISMISSED, false ) if (!IS_PLATFORM) return null // Keep the "Go back" banner visible even after dismissal so manually opted-in users can switch back if (isDismissed && !(isEnabled && !isDefaultOptIn)) return null const cardClassName = cn('rounded-lg border p-4 space-y-3 text-left', className) const onSwitchBack = () => { disable() navigateToUrl(navigate, `/project/${ref}/logs/explorer`) } const onEnable = () => { enable() navigateToUrl(navigate, `/project/${ref}/logs`) } if (isEnabled && !isDefaultOptIn) { return (

Go back to old logs

} onClick={onSwitchBack} tooltip={{ content: { side: 'bottom', text: 'Switch back' } }} />
) } return (
New

Introducing unified logs

{isDefaultOptIn ? ( ) : ( <> } onClick={() => selectFeaturePreview('supabase-ui-preview-unified-logs')} tooltip={{ content: { side: 'bottom', text: 'More information' } }} /> )}
) }