index.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import {openModal} from 'sentry/actionCreators/modal';
  2. import Button, {ButtonProps} from 'sentry/components/button';
  3. import {IconMegaphone} from 'sentry/icons';
  4. import {t} from 'sentry/locale';
  5. import {FeedBackModalProps} from './feedbackModal';
  6. interface Props extends FeedBackModalProps {
  7. buttonProps?: Partial<ButtonProps>;
  8. }
  9. // Provides a button that, when clicked, opens a modal with a form that,
  10. // when filled and submitted, will send feedback to Sentry (feedbacks project).
  11. export function FeatureFeedback({feedbackTypes, featureName, buttonProps = {}}: Props) {
  12. async function handleClick() {
  13. const mod = await import('sentry/components/featureFeedback/feedbackModal');
  14. const {FeedbackModal, modalCss} = mod;
  15. openModal(
  16. deps => (
  17. <FeedbackModal
  18. {...deps}
  19. featureName={featureName}
  20. feedbackTypes={feedbackTypes}
  21. />
  22. ),
  23. {
  24. modalCss,
  25. }
  26. );
  27. }
  28. return (
  29. <Button icon={<IconMegaphone />} onClick={handleClick} {...buttonProps}>
  30. {t('Give Feedback')}
  31. </Button>
  32. );
  33. }