confirmableAction.tsx 654 B

1234567891011121314151617181920
  1. import {Fragment} from 'react';
  2. import Confirm from 'sentry/components/confirm';
  3. type ConfirmProps = React.ComponentProps<typeof Confirm>;
  4. type Props = {
  5. children: React.ReactNode | ConfirmProps['children'];
  6. shouldConfirm?: boolean;
  7. } & Partial<
  8. Pick<ConfirmProps, 'confirmText' | 'priority' | 'stopPropagation' | 'header'>
  9. > &
  10. Pick<ConfirmProps, 'message' | 'disabled' | 'confirmText' | 'onConfirm'>;
  11. export default function ConfirmableAction({shouldConfirm, children, ...props}: Props) {
  12. if (shouldConfirm) {
  13. return <Confirm {...props}>{children as ConfirmProps['children']}</Confirm>;
  14. }
  15. return <Fragment>{children}</Fragment>;
  16. }