'use client'; import { Command, ReturnKey } from '@/components/ui/icons'; import { useBusterNotifications } from '@/context/BusterNotifications'; import { useMemoizedFn } from '@/hooks'; import { Button } from '@/components/ui/buttons/Button'; import React, { useState } from 'react'; import type { AppVerticalCodeSplitterProps } from './AppVerticalCodeSplitter'; import { cn } from '@/lib/classMerge'; import { ErrorClosableContainer } from '@/components/ui/error/ErrorClosableContainer'; import { AppDiffCodeEditor } from '@/components/ui/inputs'; import { Copy2 } from '@/components/ui/icons'; import { Text } from '@/components/ui/typography'; import { VersionPill } from '@/components/ui/tags/VersionPill'; export const DiffSQLContainer: React.FC<{ className?: string; originalValue: string | undefined; value: string | undefined; setValue: (value: string) => void; onRunQuery: () => Promise; onSaveSQL?: AppVerticalCodeSplitterProps['onSaveSQL']; disabledSave?: AppVerticalCodeSplitterProps['disabledSave']; error?: string | null; language: 'sql' | 'yaml'; fileName?: string; versionNumber?: number; }> = React.memo( ({ language, disabledSave, className = '', originalValue, value, setValue, onRunQuery, onSaveSQL, error, fileName, versionNumber }) => { const [isRunning, setIsRunning] = useState(false); const { openInfoMessage } = useBusterNotifications(); const onCopySQL = useMemoizedFn(() => { navigator.clipboard.writeText(value || ''); openInfoMessage('Copied to clipboard'); }); const onRunQueryPreflight = useMemoizedFn(async () => { setIsRunning(true); await onRunQuery(); setIsRunning(false); }); return (
{fileName} {versionNumber && }
{onSaveSQL && ( )}
}> Run
{error && }
); } ); DiffSQLContainer.displayName = 'DiffSQLContainer';