Skip to content

Commit

Permalink
Pass on pressable site status
Browse files Browse the repository at this point in the history
  • Loading branch information
artpi committed Oct 26, 2016
1 parent e85a50c commit 6ac97f6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@
* External dependencies
*/
import React from 'react';
import pick from 'lodash/pick';

/**
* Internal dependencies
*/
import CustomDomainPurchaseDetail from 'my-sites/upgrades/checkout-thank-you/custom-domain-purchase-detail';

export default ( { selectedSite, hasDomainCredit } ) => {
export default ( props ) => {
return (
<div className="product-purchase-features-list__item">
<CustomDomainPurchaseDetail
selectedSite={ selectedSite }
hasDomainCredit={ hasDomainCredit }
/>
<CustomDomainPurchaseDetail { ...pick( props, [ 'selectedSite', 'hasDomainCredit', 'isPressableSite' ] ) } />
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import JetpackSurveysPolls from './jetpack-surveys-polls';
import JetpackWordPressCom from './jetpack-wordpress-com';
import { isWordadsInstantActivationEligible } from 'lib/ads/utils';
import { hasDomainCredit } from 'state/sites/plans/selectors';
import { isPressableSite } from 'state/sites/selectors';
import { getSelectedSite, getSelectedSiteId } from 'state/ui/selectors';

class ProductPurchaseFeaturesList extends Component {
Expand All @@ -51,13 +52,15 @@ class ProductPurchaseFeaturesList extends Component {
getBusinessFeatures() {
const {
selectedSite,
planHasDomainCredit
planHasDomainCredit,
isPressableSite
} = this.props;

return [
<CustomDomain
selectedSite={ selectedSite }
hasDomainCredit={ planHasDomainCredit }
isPressableSite={ isPressableSite }
key="customDomainFeature"
/>,
<AdvertisingRemoved
Expand Down Expand Up @@ -255,6 +258,7 @@ export default connect(

return {
selectedSite,
isPressableSite: !! isPressableSite( state, selectedSiteId ),
planHasDomainCredit: hasDomainCredit( state, selectedSiteId )
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import { localize } from 'i18n-calypso';
import PurchaseDetail from 'components/purchase-detail';
import { hasCustomDomain } from 'lib/site/utils';

const CustomDomainPurchaseDetail = ( { selectedSite, hasDomainCredit, translate } ) => {
const renderClaimCustomDomain = () =>
selectedSite.plan.user_is_owner
? <PurchaseDetail
const CustomDomainPurchaseDetail = ( { selectedSite, hasDomainCredit, translate, isPressableSite } ) => {
if ( hasDomainCredit && selectedSite.plan.user_is_owner && ! isPressableSite ) {
return ( <PurchaseDetail
icon="globe"
title={ translate( 'Select Your Custom Domain' ) }
description={
Expand All @@ -29,10 +28,14 @@ const CustomDomainPurchaseDetail = ( { selectedSite, hasDomainCredit, translate
buttonText={ translate( 'Claim your free domain' ) }
href={ `/domains/add/${ selectedSite.slug }` }
/>
: null;

const renderHasCustomDomain = () =>
<PurchaseDetail
);
} else if ( ! hasDomainCredit && hasCustomDomain( selectedSite ) ) {
const actionButton = {};
if ( ! isPressableSite ) {
actionButton.buttonText = translate( 'Manage my domains' );
actionButton.href = `/domains/manage/${ selectedSite.slug }`;
}
return ( <PurchaseDetail
icon="globe"
title={ translate( 'Custom Domain' ) }
description={ translate(
Expand All @@ -41,31 +44,20 @@ const CustomDomainPurchaseDetail = ( { selectedSite, hasDomainCredit, translate
components: { em: <em /> }
}
) }
buttonText={ translate( 'Manage my domains' ) }
href={ `/domains/manage/${ selectedSite.slug }` }
/>;

const renderCustomDomainDetail = () => {
if ( hasCustomDomain( selectedSite ) ) {
return renderHasCustomDomain();
}

{ ...actionButton }
/> );
} else {
return null;
};

return (
hasDomainCredit
? renderClaimCustomDomain()
: renderCustomDomainDetail()
);
}
};

CustomDomainPurchaseDetail.propTypes = {
selectedSite: React.PropTypes.oneOfType( [
React.PropTypes.bool,
React.PropTypes.object
] ).isRequired,
hasDomainCredit: React.PropTypes.bool
hasDomainCredit: React.PropTypes.bool,
isPressableSite: React.PropTypes.bool
};

export default localize( CustomDomainPurchaseDetail );
4 changes: 2 additions & 2 deletions client/state/sites/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ export function items( state = {}, action ) {
}
return state;

case 'PRESSABLE_ACTIVATE':
case 'PRESSABLE_TEST':
const originalSite = state[ action.siteId ];
if ( originalSite ) {
return Object.assign( {}, state, {
[ action.siteId ]: merge( {}, originalSite, { options: { pressable: true } } )
[ action.siteId ]: merge( {}, originalSite, { jetpack: true, options: { pressable: true } } )
} );
}
return state;
Expand Down

0 comments on commit 6ac97f6

Please sign in to comment.