disabledAlertsPage.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import List from 'sentry/components/list';
  4. import ListItem from 'sentry/components/list/listItem';
  5. import {IconBusiness} from 'sentry/icons';
  6. import {t, tct} from 'sentry/locale';
  7. import type {Organization} from 'sentry/types/organization';
  8. import type {Subscription} from 'getsentry/types';
  9. import {displayPlanName, hasPerformance} from 'getsentry/utils/billing';
  10. import withSubscription from '../withSubscription';
  11. import AlertsBackground from './illustrations/alertsBackground';
  12. import PageUpsellOverlay from './pageUpsellOverlay';
  13. import PlanFeature from './planFeature';
  14. type Props = React.PropsWithChildren<{
  15. features: string[];
  16. organization: Organization;
  17. subscription: Subscription;
  18. }>;
  19. const TextWrapper = styled('div')`
  20. width: 550px;
  21. `;
  22. function DisabledAlertsPage({
  23. organization,
  24. subscription,
  25. features,
  26. children: _children,
  27. ...props
  28. }: Props) {
  29. const requiredPlan = tct(`You'll need a [plan] or up to view metric alerts.`, {
  30. plan: (
  31. <PlanFeature organization={organization} features={features}>
  32. {({plan}) => (
  33. <strong data-test-id="upsell-planid">
  34. {t('%s Plan', displayPlanName(plan))}
  35. </strong>
  36. )}
  37. </PlanFeature>
  38. ),
  39. });
  40. const description = (
  41. <Fragment>
  42. <p>
  43. {t(
  44. 'Sure, we like attention as much as the next app. But we don’t want to send notifications you don’t need. Set your own alert rules.'
  45. )}
  46. </p>
  47. <FeatureList symbol={<IconBusiness size="sm" />}>
  48. <ListItem>{t('Set critical thresholds')}</ListItem>
  49. <ListItem>{t('Automate resolution')}</ListItem>
  50. <ListItem>{t('Identify key events to watch')}</ListItem>
  51. <ListItem>{t('Create custom triggers')}</ListItem>
  52. </FeatureList>
  53. </Fragment>
  54. );
  55. return (
  56. <PageUpsellOverlay
  57. name={t('Choose your alerts')}
  58. source={
  59. hasPerformance(subscription.planDetails) ? 'incidents' : 'incidents-performance'
  60. }
  61. description={description}
  62. data-test-id="mock-incidents-page"
  63. organization={organization}
  64. requiredPlan={requiredPlan}
  65. features={features}
  66. background={AlertsBackground}
  67. customWrapper={TextWrapper}
  68. positioningStrategy={({mainRect, anchorRect, wrapperRect}) => {
  69. // Vertically center within the anchor
  70. const y =
  71. (anchorRect.height - wrapperRect.height + 40) / 2 + anchorRect.y - mainRect.y;
  72. // Align to the right of the anchor, avoid overflowing outside of the
  73. // page, the best we can do is start to overlap the illustration at
  74. // this point.
  75. let x = anchorRect.x - mainRect.x - wrapperRect.width;
  76. x = x < 30 ? 30 : x;
  77. return {x, y};
  78. }}
  79. {...props}
  80. />
  81. );
  82. }
  83. const FeatureList = styled(List)`
  84. display: grid;
  85. grid-template-columns: 1fr 1fr;
  86. `;
  87. export default withSubscription(DisabledAlertsPage);