import { Button } from 'ui' import { Admonition } from 'ui-patterns/Admonition' import { ButtonTooltip } from '@/components/ui/ButtonTooltip' import type { LegacyLogsRewriteState } from '@/hooks/analytics/useLegacyLogsRewrite' interface LegacyLogsRewriteAdmonitionProps { state: LegacyLogsRewriteState onRewrite: () => void onDismiss: () => void } const BANNER_CLASSES = 'mb-0 rounded-none border-x-0 border-t-0' /** * Presentation for the BigQuery → ClickHouse rewrite offer, covering every state * of `useLegacyLogsRewrite`. Shared by the Logs Explorer and the SQL editor so the * copy and the outcome handling live in one place — a surface only decides *when* * to show this, not what each state says. * * Renders nothing once dismissed; callers can also hide it earlier if they have * their own reasons to (the SQL editor hides it while a diff is open). */ export const LegacyLogsRewriteAdmonition = ({ state, onRewrite, onDismiss, }: LegacyLogsRewriteAdmonitionProps) => { if (state.status === 'dismissed') return null if (state.status === 'failed') { return ( } /> ) } // The dialect check is a heuristic, so an unchanged rewrite is the Assistant // disagreeing with it. Say so and let the user close it, rather than proposing // an empty diff or silently giving up. if (state.status === 'noRewriteNeeded') { return ( Dismiss } /> ) } const isRewriting = state.status === 'rewriting' return ( {/* Disabled mid-rewrite so the offer can't be dismissed out from under an in-flight request — the two states stay mutually exclusive. */} Dismiss } /> ) }