index.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. export interface FeatureFeedbackProps 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({
  12. feedbackTypes,
  13. featureName,
  14. buttonProps = {},
  15. }: FeatureFeedbackProps) {
  16. async function handleClick() {
  17. const mod = await import('sentry/components/featureFeedback/feedbackModal');
  18. const {FeedbackModal, modalCss} = mod;
  19. openModal(
  20. deps => (
  21. <FeedbackModal
  22. {...deps}
  23. featureName={featureName}
  24. feedbackTypes={feedbackTypes}
  25. />
  26. ),
  27. {
  28. modalCss,
  29. }
  30. );
  31. }
  32. return (
  33. <Button icon={<IconMegaphone />} onClick={handleClick} {...buttonProps}>
  34. {t('Give Feedback')}
  35. </Button>
  36. );
  37. }