| | import { |
| | PLAN_FREE, |
| | PLAN_JETPACK_FREE, |
| | PLAN_P2_PLUS, |
| | getPlan, |
| | isWpComBusinessPlan, |
| | isWpComEcommercePlan, |
| | isFreePlan, |
| | } from '@automattic/calypso-products'; |
| | import { get } from 'lodash'; |
| | import { getByPurchaseId } from 'calypso/state/purchases/selectors'; |
| | import isSiteAutomatedTransfer from 'calypso/state/selectors/is-site-automated-transfer'; |
| | import isSiteWpcomAtomic from 'calypso/state/selectors/is-site-wpcom-atomic'; |
| | import { getCurrentPlan } from 'calypso/state/sites/plans/selectors'; |
| | import { isJetpackSite } from 'calypso/state/sites/selectors'; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | export default function ( state, siteId, planKey ) { |
| | |
| | const freePlan = |
| | isJetpackSite( state, siteId ) && ! isSiteAutomatedTransfer( state, siteId ) |
| | ? PLAN_JETPACK_FREE |
| | : PLAN_FREE; |
| | const plan = getCurrentPlan( state, siteId ); |
| | const purchase = plan?.id ? getByPurchaseId( state, plan.id ) : null; |
| |
|
| | |
| | |
| | const currentPlanSlug = get( plan, [ 'expired' ], false ) |
| | ? freePlan |
| | : get( plan, [ 'productSlug' ], freePlan ); |
| |
|
| | |
| | const isAtomicV1 = |
| | isSiteAutomatedTransfer( state, siteId ) && ! isSiteWpcomAtomic( state, siteId ); |
| | if ( ( isWpComEcommercePlan( planKey ) && isAtomicV1 ) || purchase?.isLocked ) { |
| | return false; |
| | } |
| |
|
| | |
| | if ( |
| | ( isWpComBusinessPlan( planKey ) || isWpComEcommercePlan( planKey ) ) && |
| | isFreePlan( currentPlanSlug ) && |
| | isSiteAutomatedTransfer( state, siteId ) |
| | ) { |
| | return true; |
| | } |
| |
|
| | |
| | if ( PLAN_P2_PLUS === planKey ) { |
| | return false; |
| | } |
| |
|
| | return get( getPlan( planKey ), [ 'availableFor' ], () => false )( currentPlanSlug ); |
| | } |
| |
|