linkWithConfirmation.tsx 836 B

1234567891011121314151617181920212223242526272829303132
  1. import * as React from 'react';
  2. import classNames from 'classnames';
  3. import Button from 'sentry/components/button';
  4. import Confirm from 'sentry/components/confirm';
  5. type Props = {
  6. message: React.ReactNode;
  7. onConfirm: () => void;
  8. title: string;
  9. className?: string;
  10. disabled?: boolean;
  11. priority?: React.ComponentProps<typeof Button>['priority'];
  12. };
  13. /**
  14. * <Confirm> is a more generic version of this component
  15. */
  16. class LinkWithConfirmation extends React.PureComponent<Props> {
  17. render() {
  18. const {className, disabled, title, children, ...otherProps} = this.props;
  19. return (
  20. <Confirm {...otherProps} disabled={disabled}>
  21. <a href="#" className={classNames(className || '', {disabled})} title={title}>
  22. {children}
  23. </a>
  24. </Confirm>
  25. );
  26. }
  27. }
  28. export default LinkWithConfirmation;