RunButton.tsx 856 B

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