highlightedFeature.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import styled from '@emotion/styled';
  2. import {t, tct} from 'sentry/locale';
  3. import {space} from 'sentry/styles/space';
  4. import type {Organization} from 'sentry/types/organization';
  5. import PlanFeature from 'getsentry/components/features/planFeature';
  6. import type {Subscription} from 'getsentry/types';
  7. import {displayPlanName, hasPerformance} from 'getsentry/utils/billing';
  8. import type {Feature} from './types';
  9. type Props = {
  10. feature: Feature;
  11. organization: Organization;
  12. subscription: Subscription;
  13. };
  14. const IMAGE_SIZE = {height: 'auto', width: '540px'};
  15. function HighlightedFeature({feature, organization, subscription}: Props) {
  16. return (
  17. <Description data-test-id="highlighted-feature">
  18. <div>{feature.desc}</div>
  19. {feature.image && <FeatureImg src={feature.image} {...IMAGE_SIZE} />}
  20. <PlanContext>
  21. {hasPerformance(subscription.planDetails)
  22. ? tct("You'll need the [plan] or up to enable this feature.", {
  23. plan: (
  24. <PlanFeature
  25. {...{organization, subscription}}
  26. features={feature.planFeatures}
  27. >
  28. {({plan}) => <strong>{t('%s Plan', displayPlanName(plan))}</strong>}
  29. </PlanFeature>
  30. ),
  31. })
  32. : tct(
  33. "You'll need to migrate to a new plan with [strong:Transactions] to enable this feature.",
  34. {
  35. strong: <strong />,
  36. }
  37. )}
  38. {!subscription.isTrial &&
  39. tct(" You're currently on the [current] plan.", {
  40. current: subscription.planDetails.name,
  41. })}
  42. </PlanContext>
  43. </Description>
  44. );
  45. }
  46. const Description = styled('div')`
  47. display: flex;
  48. flex-direction: column;
  49. `;
  50. const FeatureImg = styled('img')`
  51. margin: ${space(2)} 0;
  52. `;
  53. const PlanContext = styled('div')`
  54. font-size: ${p => p.theme.fontSizeExtraSmall};
  55. line-height: 1.5;
  56. `;
  57. export default HighlightedFeature;