Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plans: Add Single Product Jetpack Backup #14018

Merged
merged 28 commits into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2c2fafd
[not verified] Add products endpoint
robertf4 Nov 8, 2019
0f459c7
[not verified] [not verified] Add error code
robertf4 Nov 13, 2019
ec01c64
[not verified] Add products endpoint
robertf4 Nov 8, 2019
b1f785e
[not verified] [not verified] Add error code
robertf4 Nov 13, 2019
074c95e
[not verified] Add QueryProducts data component and corresponding Red…
robertf4 Nov 11, 2019
cc8402b
[not verified] Changed benefits to products
robertf4 Nov 13, 2019
5f5556c
[not verified] Update _inc/client/state/site/reducer.js
robertf4 Nov 14, 2019
a7fa8f6
Add products endpoint
robertf4 Nov 8, 2019
601a3d3
[not verified] Add error code
robertf4 Nov 13, 2019
2ea4958
Update _inc/lib/class.core-rest-api-endpoints.php
robertf4 Nov 14, 2019
dc67ab3
Update _inc/lib/class.core-rest-api-endpoints.php
robertf4 Nov 14, 2019
e4be64a
Add QueryProducts data component and corresponding Redux and rest API…
robertf4 Nov 11, 2019
b1bee3a
Update _inc/client/state/site/reducer.js
robertf4 Nov 14, 2019
658f8ed
Remove duplicate definition of getProducts
robertf4 Nov 15, 2019
9a7b015
Added yearly single product backup upgrade prompt to the Plans page i…
robertf4 Nov 12, 2019
b8008c8
Change 'Single Products' to 'Solutions'
robertf4 Nov 12, 2019
331e817
Switched to quotes
robertf4 Nov 13, 2019
9ce1820
Factor out calculation of full yearly prices and redo I18N of that
robertf4 Nov 13, 2019
fedfcf6
Make more robust against products not existing
robertf4 Nov 13, 2019
cff63b6
Convert SingleProductBackupBody to class component
robertf4 Nov 13, 2019
4e6f9f0
Rename plans-price__span to plans-price__price-range
robertf4 Nov 13, 2019
7efb572
Change slashed to discounted
robertf4 Nov 13, 2019
3362ba9
Destructure props instead of declaring a props parameter
robertf4 Nov 13, 2019
493d09f
Changed upgrade links to use getUpgradeUrl
robertf4 Nov 13, 2019
b015600
Flatten CSS class names
robertf4 Nov 14, 2019
9e919b6
Rename single-product-backup__accented-card-container to plans-sectio…
robertf4 Nov 14, 2019
a2d4b36
Add single-product-backup__header-title CSS class
robertf4 Nov 14, 2019
6715027
Fix merge issues
robertf4 Nov 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions _inc/client/plans/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,45 @@
*/
import React from 'react';
import { connect } from 'react-redux';
import { get } from 'lodash';

/**
* Internal dependencies
*/
import { getSiteConnectionStatus } from 'state/connection';
import PlanGrid from './plan-grid';
import QuerySite from 'components/data/query-site';
import { SingleProductBackup } from './single-product-backup';
import QueryProducts from 'components/data/query-products';
import QuerySite from 'components/data/query-site';
import { getUpgradeUrl } from 'state/initial-state';
import { getProducts, getSitePlan } from 'state/site';

export class Plans extends React.Component {
render() {
const { dailyBackupUpgradeUrl, products, realtimeBackupUpgradeUrl } = this.props;

const upgradeLinks = {
daily: dailyBackupUpgradeUrl,
'real-time': realtimeBackupUpgradeUrl,
};

return (
<div>
<React.Fragment>
jeherve marked this conversation as resolved.
Show resolved Hide resolved
<QueryProducts />
<QuerySite />
<div>
<PlanGrid />
</div>
</div>
{ products && 'jetpack_free' === get( this.props.sitePlan, 'product_slug' ) && (
<SingleProductBackup products={ products } upgradeLinks={ upgradeLinks } />
) }
<PlanGrid />
</React.Fragment>
);
}
}

export default connect( state => {
return {
getSiteConnectionStatus: () => getSiteConnectionStatus( state ),
dailyBackupUpgradeUrl: getUpgradeUrl( state, 'jetpack-backup-daily' ),
products: getProducts( state ),
realtimeBackupUpgradeUrl: getUpgradeUrl( state, 'jetpack-backup-realtime' ),
sitePlan: getSitePlan( state ),
};
} )( Plans );
59 changes: 58 additions & 1 deletion _inc/client/plans/single-product-backup.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/**
* External dependencies
*/
import React from 'react';
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { getCurrencyDefaults } from '@automattic/format-currency';
import { translate as __ } from 'i18n-calypso';
import { get } from 'lodash';

/**
* Internal dependencies
Expand All @@ -13,6 +15,61 @@ import ExternalLink from 'components/external-link';

import './single-product-backup.scss';

export function SingleProductBackup( { products, upgradeLinks } ) {
const [ selectedBackupType, setSelectedBackupType ] = useState( 'real-time' );

const backupPlanPrices = {
jetpack_backup_daily: {
monthly: get( products, [ 'jetpack_backup_daily_monthly', 'cost' ], '' ),
yearly: get( products, [ 'jetpack_backup_daily', 'cost' ], '' ),
},
jetpack_backup_realtime: {
monthly: get( products, [ 'jetpack_backup_realtime_monthly', 'cost' ], '' ),
yearly: get( products, [ 'jetpack_backup_realtime', 'cost' ], '' ),
},
};

const currency_code = get( products, [ 'jetpack_backup_daily', 'currency_code' ], '' );
const currencySymbol = getCurrencyDefaults( currency_code ).symbol;

return (
<React.Fragment>
<h1 className="plans-section__header">{ __( 'Solutions' ) }</h1>
<h2 className="plans-section__subheader">
{ __( "Just looking for backups? We've got you covered." ) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"We've got you covered." may work well in the US, but I don't know that it's an ideal phrase to use, it feels colloquial.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eeeeevon13 thoughts on this?

</h2>
<div className="plans-section__single-product">
<div className="single-product-backup__accented-card">
<div className="single-product-backup__accented-card-header">
<SingleProductBackupHeader
currencySymbol={ currencySymbol }
backupPlanPrices={ backupPlanPrices }
/>
</div>
<div className="single-product-backup__accented-card-body">
<SingleProductBackupBody
backupPlanPrices={ backupPlanPrices }
currencySymbol={ currencySymbol }
selectedBackupType={ selectedBackupType }
setSelectedBackupType={ setSelectedBackupType }
upgradeLinks={ upgradeLinks }
/>
</div>
</div>
</div>
</React.Fragment>
);
}

function SingleProductBackupHeader( { currencySymbol, backupPlanPrices } ) {
return (
<div className="single-product-backup__header-container">
<h3 className="single-product-backup__header-title">{ __( 'Jetpack Backup' ) }</h3>
<PlanPriceDisplay currencySymbol={ currencySymbol } backupPlanPrices={ backupPlanPrices } />
</div>
);
}

export function PlanPriceDisplay( { backupPlanPrices, currencySymbol } ) {
const dailyBackupYearlyPrice = backupPlanPrices.jetpack_backup_daily.yearly;
const dailyBackupMonthlyPrice = backupPlanPrices.jetpack_backup_daily.monthly;
Expand Down
74 changes: 67 additions & 7 deletions _inc/client/plans/single-product-backup.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.single-product-backup__options-header {
font-size: 14px;
color: #747474;
border-bottom: solid 2px #e6e6e6;
@import '../scss/variables/_colors.scss';

.plan-radio-button__label {
display: flex;
}

input[type='radio'].plan-radio-button__input {
margin-top: 0px;
}

.plans-price__container {
Expand Down Expand Up @@ -43,10 +47,66 @@
align-content: center;
}

.plan-radio-button__label {
.single-product-backup__options-header {
font-size: 14px;
color: $gray-text-min;
border-bottom: solid 2px #e6e6e6;
}

.plans-section__header {
text-align: center;
font-weight: normal;
font-size: 22px;
}

.plans-section__subheader {
color: $gray-text-min;
text-align: center;
font-weight: normal;
font-size: 14px;
}

.plans-section__single-product {
display: flex;
justify-content: center;
margin-bottom: 10px;
}

input[type='radio'].plan-radio-button__input {
margin-top: 0px;
.single-product-backup__header-container {
display: flex;
flex-direction: row;
justify-content: space-between;
align-content: center;
}

.single-product-backup__radio-buttons-container {
display: flex;
flex-direction: row;
justify-content: space-evenly;
}

.single-product-backup__upgrade-button-container {
text-align: center;
margin-top: 23px;
margin-bottom: 10px;
}

.single-product-backup__accented-card {
max-width: 518px;
min-height: 313px;
background-color: #fff;
border: solid 1px #e6e6e6;
}

.single-product-backup__accented-card-header {
padding: 15px;
border-bottom: solid 2px $blue-medium;
}

.single-product-backup__header-title {
font-size: 17px;
}

.single-product-backup__accented-card-body {
padding: 15px;
}