feedbackAlertBanner.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import styled from '@emotion/styled';
  2. import Alert from 'sentry/components/alert';
  3. import ExternalLink from 'sentry/components/links/externalLink';
  4. import Link from 'sentry/components/links/link';
  5. import {tct} from 'sentry/locale';
  6. import {space} from 'sentry/styles/space';
  7. import {IssueAlertFilterType, type IssueAlertRuleCondition} from 'sentry/types/alerts';
  8. import useOrganization from 'sentry/utils/useOrganization';
  9. export default function FeedbackAlertBanner({
  10. filters,
  11. projectSlug,
  12. }: {
  13. filters: IssueAlertRuleCondition[] | undefined;
  14. projectSlug: string;
  15. }) {
  16. const organization = useOrganization();
  17. const filterSet = filters?.filter(r => r.id === IssueAlertFilterType.ISSUE_CATEGORY);
  18. if (!filterSet || !filterSet.length) {
  19. return null;
  20. }
  21. const filterFeedback = filterSet.find(f => f.value === '6'); // category: feedback
  22. return filterFeedback ? (
  23. <StyledFeedbackAlert showIcon type="info">
  24. {tct(
  25. 'This issue category condition is ONLY for feedbacks from the [linkWidget:built-in widget]. [linkModal: Crash-report modal] alerts can be enabled in [link:Project Settings].',
  26. {
  27. link: (
  28. <Link
  29. to={`/settings/${organization.slug}/projects/${projectSlug}/user-feedback/`}
  30. />
  31. ),
  32. linkWidget: (
  33. <ExternalLink href="https://docs.sentry.io/platforms/javascript/user-feedback/#user-feedback-widget" />
  34. ),
  35. linkModal: (
  36. <ExternalLink href="https://docs.sentry.io/platforms/javascript/user-feedback/#crash-report-modal" />
  37. ),
  38. }
  39. )}
  40. </StyledFeedbackAlert>
  41. ) : null;
  42. }
  43. const StyledFeedbackAlert = styled(Alert)`
  44. margin: ${space(1)} 0 0 0;
  45. `;