disabledDiscover2Page.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 {displayPlanName} from 'getsentry/utils/billing';
  9. import DiscoverBackground from './illustrations/discoverBackground';
  10. import PageUpsellOverlay from './pageUpsellOverlay';
  11. import PlanFeature from './planFeature';
  12. type Props = React.PropsWithChildren<{
  13. features: string[];
  14. organization: Organization;
  15. }>;
  16. const TextWrapper = styled('div')`
  17. width: 550px;
  18. `;
  19. function DisabledDiscover2Page({
  20. organization,
  21. children: _children,
  22. features,
  23. ...props
  24. }: Props) {
  25. const requiredPlan = tct(
  26. `You'll need a [basicPlan] to view your events in Discover, or
  27. a [queryPlan] to unlock the full functionality of Discover.`,
  28. {
  29. basicPlan: (
  30. <PlanFeature organization={organization} features={['discover-basic']}>
  31. {({plan}) => (
  32. <strong data-test-id="upsell-planid">
  33. {t('%s Plan', displayPlanName(plan))}
  34. </strong>
  35. )}
  36. </PlanFeature>
  37. ),
  38. queryPlan: (
  39. <PlanFeature organization={organization} features={['discover-query']}>
  40. {({plan}) => (
  41. <strong data-test-id="upsell-planid">
  42. {t('%s Plan', displayPlanName(plan))}
  43. </strong>
  44. )}
  45. </PlanFeature>
  46. ),
  47. }
  48. );
  49. const description = (
  50. <Fragment>
  51. <p>
  52. {t(
  53. "This isn't just any query builder. Discover helps you go back in time to connect the dots and prevent future mistakes."
  54. )}
  55. </p>
  56. <FeatureList
  57. symbol={<IconBusiness size="sm" />}
  58. data-test-id="discover-feature-list"
  59. >
  60. <ListItem>{t('Define custom functions')}</ListItem>
  61. <ListItem>{t('Export query results')}</ListItem>
  62. <ListItem>{t('Save and share queries')}</ListItem>
  63. <ListItem>{t('Visualize top results')}</ListItem>
  64. </FeatureList>
  65. </Fragment>
  66. );
  67. return (
  68. <PageUpsellOverlay
  69. name={t('Like time travel for queries')}
  70. source="discover2"
  71. description={description}
  72. data-test-id="mock-discover2-page"
  73. organization={organization}
  74. requiredPlan={requiredPlan}
  75. features={features}
  76. background={DiscoverBackground}
  77. defaultUpsellSelection="discover-query"
  78. animateDelay={0.8}
  79. customWrapper={TextWrapper}
  80. positioningStrategy={({mainRect, anchorRect, wrapperRect}) => {
  81. // Center within the anchor on the x axis, until the wrapper is larger
  82. // than the anchor, then align the wrapper to the right within anchor.
  83. let x =
  84. (anchorRect.width - wrapperRect.width) /
  85. (anchorRect.width > wrapperRect.width ? 2 : 1) +
  86. anchorRect.x -
  87. mainRect.x;
  88. // Avoid overflowing onto the left of the page
  89. x = x < 30 ? 30 : x;
  90. return {x, y: anchorRect.y};
  91. }}
  92. {...props}
  93. />
  94. );
  95. }
  96. const FeatureList = styled(List)`
  97. display: grid;
  98. grid-template-columns: 1fr 1fr;
  99. `;
  100. export default DisabledDiscover2Page;