import { isEnabled } from '@automattic/calypso-config'; import { getPlan, GROUP_WPCOM, GROUP_JETPACK, TYPE_ECOMMERCE, TYPE_BUSINESS, TYPE_PREMIUM, TYPE_PERSONAL, TYPE_BLOGGER, TYPE_FREE, PLAN_BUSINESS_2_YEARS, PLAN_BUSINESS_ONBOARDING_EXPIRE, PLAN_BUSINESS_2Y_ONBOARDING_EXPIRE, TYPE_SECURITY_DAILY, TYPE_SECURITY_REALTIME, TYPE_ALL, TERM_MONTHLY, getPlans, TYPE_PRO, WPCOM_FEATURES_WORDADS, TYPE_WOOEXPRESS_MEDIUM, TYPE_WOOEXPRESS_SMALL, TYPE_100_YEAR, TYPE_STARTER, } from '@automattic/calypso-products'; import PropTypes from 'prop-types'; import { Component, Fragment } from 'react'; import { connect } from 'react-redux'; import { withLocalizedMoment } from 'calypso/components/localized-moment'; import { recordTracksEvent } from 'calypso/state/analytics/actions'; import { canCurrentUser } from 'calypso/state/selectors/can-current-user'; import getConciergeScheduleId from 'calypso/state/selectors/get-concierge-schedule-id'; import isSiteAutomatedTransfer from 'calypso/state/selectors/is-site-automated-transfer'; import siteHasFeature from 'calypso/state/selectors/site-has-feature'; import { hasDomainCredit, getCurrentPlan } from 'calypso/state/sites/plans/selectors'; import { getSelectedSite, getSelectedSiteId } from 'calypso/state/ui/selectors'; import AdvertisingRemoved from './advertising-removed'; import BusinessOnboarding from './business-onboarding'; import CustomCSS from './custom-css'; import CustomDomain from './custom-domain'; import CustomizeTheme from './customize-theme'; import FindNewTheme from './find-new-theme'; import GoogleAnalyticsStats from './google-analytics-stats'; import GoogleMyBusiness from './google-my-business'; import HappinessSupportCard from './happiness-support-card'; import JetpackPublicize from './jetpack-publicize'; import MobileApps from './mobile-apps'; import MonetizeSite from './monetize-site'; import SellOnlinePaypal from './sell-online-paypal'; import SiteActivity from './site-activity'; import UploadPlugins from './upload-plugins'; import VideoAudioPosts from './video-audio-posts'; import './style.scss'; const PLANS_LIST = getPlans(); export class ProductPurchaseFeaturesList extends Component { static propTypes = { plan: PropTypes.oneOf( Object.keys( PLANS_LIST ) ).isRequired, isPlaceholder: PropTypes.bool, }; static defaultProps = { isPlaceholder: false, }; // TODO: Define feature list. getEcommerceFeatures() { const { isMonthlyPlan, isPlaceholder, plan, planHasDomainCredit, selectedSite } = this.props; return ( { ! isMonthlyPlan && ( ) } { isEnabled( 'themes/premium' ) && } ); } getBusinessFeatures() { const { canActivateWordadsInstant, isPlaceholder, isMonthlyPlan, plan, currentPlan, planHasDomainCredit, selectedSite, scheduleId, } = this.props; let hasBusinessOnboardingExpired; if ( currentPlan ) { const expiryDateMoment = this.props.moment( currentPlan.expiryDate ); const is2YearPlan = plan === PLAN_BUSINESS_2_YEARS; const businessOnboardingExpiration = this.props.moment( is2YearPlan ? PLAN_BUSINESS_2Y_ONBOARDING_EXPIRE : PLAN_BUSINESS_ONBOARDING_EXPIRE ); hasBusinessOnboardingExpired = businessOnboardingExpiration.diff( expiryDateMoment ) < 0; } const hasIncludedSessions = scheduleId === 1; const hasPurchasedSessions = scheduleId > 1; const isBusinessOnboardingAvailable = hasPurchasedSessions || ( hasIncludedSessions && ! hasBusinessOnboardingExpired ); return ( { ! isMonthlyPlan && ( ) } { isBusinessOnboardingAvailable && ( ) } { canActivateWordadsInstant && } { isEnabled( 'themes/premium' ) && } ); } getPremiumFeatures() { const { canActivateWordadsInstant, isPlaceholder, isMonthlyPlan, plan, planHasDomainCredit, selectedSite, } = this.props; return ( { ! isMonthlyPlan && ( ) } { canActivateWordadsInstant && } { isEnabled( 'themes/premium' ) && } ); } getPersonalFeatures() { const { isPlaceholder, isMonthlyPlan, selectedSite, planHasDomainCredit } = this.props; return ( { ! isMonthlyPlan && ( ) } ); } getBloggerFeatures() { const { isPlaceholder, selectedSite, planHasDomainCredit } = this.props; return ( ); } getProFeatuers() { const { canActivateWordadsInstant, isPlaceholder, selectedSite, plan, planHasDomainCredit } = this.props; return ( { canActivateWordadsInstant && } { isEnabled( 'themes/premium' ) && } ); } getJetpackFreeFeatures() { const { isAutomatedTransfer, isPlaceholder, selectedSite } = this.props; return ( ); } getJetpackPremiumFeatures() { const { isAutomatedTransfer, isPlaceholder, selectedSite } = this.props; return ( { isEnabled( 'jetpack/concierge-sessions' ) && ( ) } ); } getJetpackPersonalFeatures() { const { isAutomatedTransfer, isPlaceholder, selectedSite } = this.props; return ( ); } getJetpackBusinessFeatures() { const { isAutomatedTransfer, isPlaceholder, selectedSite } = this.props; return ( { isEnabled( 'jetpack/concierge-sessions' ) && ( ) } ); } getJetpackSecurityFeatures() { const { isAutomatedTransfer, isPlaceholder, selectedSite } = this.props; return ( ); } getJetpackCompleteFeatures() { const { isAutomatedTransfer, isPlaceholder, selectedSite } = this.props; return ( ); } // Features of the legacy Starter plan in WPCOM that was launched along with the Pro plan in 2022. getWPCOMLegacyStarterFeatures() { const { selectedSite, planHasDomainCredit } = this.props; return ( ); } getFeatures() { const { plan, isPlaceholder } = this.props; if ( isPlaceholder ) { return null; } const { group, type } = getPlan( plan ); const lookup = { [ GROUP_WPCOM ]: { [ TYPE_ECOMMERCE ]: () => this.getEcommerceFeatures(), [ TYPE_WOOEXPRESS_MEDIUM ]: () => this.getEcommerceFeatures(), [ TYPE_WOOEXPRESS_SMALL ]: () => this.getEcommerceFeatures(), [ TYPE_BUSINESS ]: () => this.getBusinessFeatures(), [ TYPE_PREMIUM ]: () => this.getPremiumFeatures(), [ TYPE_PERSONAL ]: () => this.getPersonalFeatures(), [ TYPE_BLOGGER ]: () => this.getBloggerFeatures(), [ TYPE_PRO ]: () => this.getProFeatuers(), [ TYPE_100_YEAR ]: () => this.getBusinessFeatures(), [ TYPE_STARTER ]: () => this.getWPCOMLegacyStarterFeatures(), }, [ GROUP_JETPACK ]: { [ TYPE_BUSINESS ]: () => this.getJetpackBusinessFeatures(), [ TYPE_PREMIUM ]: () => this.getJetpackPremiumFeatures(), [ TYPE_PERSONAL ]: () => this.getJetpackPersonalFeatures(), [ TYPE_FREE ]: () => this.getJetpackFreeFeatures(), [ TYPE_SECURITY_DAILY ]: () => this.getJetpackSecurityFeatures(), [ TYPE_SECURITY_REALTIME ]: () => this.getJetpackSecurityFeatures(), [ TYPE_ALL ]: () => this.getJetpackCompleteFeatures(), }, }; const lookupGroup = lookup[ group ]; const callback = lookupGroup ? lookupGroup[ type ] : null; return callback ? callback() : null; } handleBusinessOnboardingClick = () => { this.props.recordTracksEvent( 'calypso_plan_features_onboarding_click' ); }; handleMobileAppsClick = () => { this.props.recordTracksEvent( 'calypso_plan_features_getapps_click' ); }; render() { return
{ this.getFeatures() }
; } } export default connect( ( state, ownProps ) => { const selectedSite = getSelectedSite( state ); const selectedSiteId = getSelectedSiteId( state ); const isAutomatedTransfer = isSiteAutomatedTransfer( state, selectedSiteId ); return { canActivateWordadsInstant: canCurrentUser( state, selectedSiteId, 'activate_wordads' ) && siteHasFeature( state, selectedSiteId, WPCOM_FEATURES_WORDADS ), isAutomatedTransfer, selectedSite, planHasDomainCredit: hasDomainCredit( state, selectedSiteId ), currentPlan: getCurrentPlan( state, selectedSiteId ), scheduleId: getConciergeScheduleId( state ), isMonthlyPlan: TERM_MONTHLY === getPlan( ownProps.plan )?.term, }; }, { recordTracksEvent, } )( withLocalizedMoment( ProductPurchaseFeaturesList ) );