RunButton.tsx38 lines · main
| 1 | import { Loader2 } from 'lucide-react' |
| 2 | import { Button, KeyboardShortcut } from 'ui' |
| 3 | |
| 4 | interface SqlRunButtonProps { |
| 5 | isDisabled?: boolean |
| 6 | isExecuting?: boolean |
| 7 | hasSelection?: boolean |
| 8 | className?: string |
| 9 | onClick: () => void |
| 10 | } |
| 11 | |
| 12 | export const SqlRunButton = ({ |
| 13 | isDisabled = false, |
| 14 | isExecuting = false, |
| 15 | hasSelection = false, |
| 16 | className, |
| 17 | onClick, |
| 18 | }: SqlRunButtonProps) => { |
| 19 | return ( |
| 20 | <Button |
| 21 | onClick={onClick} |
| 22 | disabled={isDisabled} |
| 23 | type="primary" |
| 24 | size="tiny" |
| 25 | data-testid="sql-run-button" |
| 26 | iconRight={ |
| 27 | isExecuting ? ( |
| 28 | <Loader2 className="animate-spin" size={10} strokeWidth={1.5} /> |
| 29 | ) : ( |
| 30 | <KeyboardShortcut keys={['Meta', 'Enter']} variant="inline" /> |
| 31 | ) |
| 32 | } |
| 33 | className={className} |
| 34 | > |
| 35 | {hasSelection ? 'Run selected' : 'Run'} |
| 36 | </Button> |
| 37 | ) |
| 38 | } |