index.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import React from 'react';
  2. import {openModal} from 'sentry/actionCreators/modal';
  3. import Button, {ButtonProps} from 'sentry/components/button';
  4. import {
  5. FeedbackModal,
  6. FeedbackModalProps,
  7. modalCss,
  8. } from 'sentry/components/featureFeedback/feedbackModal';
  9. import {Data} from 'sentry/components/forms/types';
  10. import {IconMegaphone} from 'sentry/icons';
  11. import {t} from 'sentry/locale';
  12. export type FeatureFeedbackProps<T extends Data> = FeedbackModalProps<T> & {
  13. buttonProps?: Partial<ButtonProps>;
  14. secondaryAction?: React.ReactNode;
  15. };
  16. // Provides a button that, when clicked, opens a modal with a form that,
  17. // when filled and submitted, will send feedback to Sentry (feedbacks project).
  18. export function FeatureFeedback<T extends Data>({
  19. buttonProps = {},
  20. ...props
  21. }: FeatureFeedbackProps<T>) {
  22. function handleClick(e: React.MouseEvent) {
  23. openModal(modalProps => <FeedbackModal {...modalProps} {...props} />, {
  24. modalCss,
  25. });
  26. buttonProps.onClick?.(e);
  27. }
  28. return (
  29. <Button {...buttonProps} icon={<IconMegaphone />} onClick={handleClick}>
  30. {t('Give Feedback')}
  31. </Button>
  32. );
  33. }