From 2eb164e6d8c959b9077309bbcaa13cbc1ba6af72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Ventura?= Date: Thu, 20 Apr 2017 12:23:54 +0200 Subject: [PATCH 1/3] GoogleApps: remove sites-list usage. --- .../components/upgrades/google-apps/index.jsx | 68 ++++++++++--------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/client/components/upgrades/google-apps/index.jsx b/client/components/upgrades/google-apps/index.jsx index dee5c2c6aea14..89cf707b3d978 100644 --- a/client/components/upgrades/google-apps/index.jsx +++ b/client/components/upgrades/google-apps/index.jsx @@ -1,46 +1,47 @@ /** * External dependencies */ -var React = require( 'react' ); +import React, { Component, PropTypes } from 'react'; +import { connect } from 'react-redux'; +import { localize } from 'i18n-calypso'; /** * Internal dependencies */ var cartItems = require( 'lib/cart-values' ).cartItems, GoogleAppsDialog = require( './dialog' ), - HeaderCake = require( 'components/header-cake' ), - observe = require( 'lib/mixins/data-observe' ); + HeaderCake = require( 'components/header-cake' ); -var GoogleApps = React.createClass( { - mixins: [ observe( 'sites' ) ], +import { getSelectedSite } from 'state/ui/selectors'; - propTypes: { - sites: React.PropTypes.object, - cart: React.PropTypes.object, - domain: React.PropTypes.string.isRequired, - onGoBack: React.PropTypes.func.isRequired, - productsList: React.PropTypes.object.isRequired, - onAddGoogleApps: React.PropTypes.func.isRequired, - onClickSkip: React.PropTypes.func.isRequired, - onSave: React.PropTypes.func, - initialState: React.PropTypes.object, - analyticsSection: React.PropTypes.string, - initialGoogleAppsCartItem: React.PropTypes.object - }, +class GoogleApps extends Component { - getDefaultProps: function() { + static propTypes = { + cart: PropTypes.object, + domain: PropTypes.string.isRequired, + onGoBack: PropTypes.func.isRequired, + productsList: PropTypes.object.isRequired, + onAddGoogleApps: PropTypes.func.isRequired, + onClickSkip: PropTypes.func.isRequired, + onSave: PropTypes.func, + initialState: PropTypes.object, + analyticsSection: PropTypes.string, + initialGoogleAppsCartItem: PropTypes.object + }; + + getDefaultProps() { return { analyticsSection: 'domains' }; - }, + } - componentDidMount: function() { + componentDidMount() { this.checkDomainInCart(); - }, + } - componentDidUpdate: function() { + componentDidUpdate() { this.checkDomainInCart(); - }, + } - checkDomainInCart: function() { + checkDomainInCart() { if ( ! this.props.cart || ! this.props.cart.hasLoadedFromServer ) { return; } @@ -49,14 +50,13 @@ var GoogleApps = React.createClass( { // Should we handle this more gracefully? this.props.onGoBack(); } - }, + } - render: function() { - var selectedSite = this.props.sites ? this.props.sites.getSelectedSite() : null; + render() { return (
- { this.translate( 'Register %(domain)s', { args: { domain: this.props.domain } } ) } + { this.props.translate( 'Register %(domain)s', { args: { domain: this.props.domain } } ) } ); } -} ); +} -module.exports = GoogleApps; +export default connect( ( state ) => { + return { + selectedSite: getSelectedSite( state ) + }; +} )( localize( GoogleApps ) ); From 6c04c3042ac382e9d9dc674243495dae92804cf8 Mon Sep 17 00:00:00 2001 From: Igor Klimer Date: Fri, 21 Apr 2017 12:29:51 +0200 Subject: [PATCH 2/3] Move defaultProps to a static property --- client/components/upgrades/google-apps/index.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/components/upgrades/google-apps/index.jsx b/client/components/upgrades/google-apps/index.jsx index 89cf707b3d978..1821f3407ab6b 100644 --- a/client/components/upgrades/google-apps/index.jsx +++ b/client/components/upgrades/google-apps/index.jsx @@ -29,9 +29,9 @@ class GoogleApps extends Component { initialGoogleAppsCartItem: PropTypes.object }; - getDefaultProps() { - return { analyticsSection: 'domains' }; - } + static defaultProps = { + analyticsSection: 'domains', + }; componentDidMount() { this.checkDomainInCart(); From 28e9c4818bc90eccbb3ed8dcdf6fac10c24dbcc3 Mon Sep 17 00:00:00 2001 From: Igor Klimer Date: Fri, 21 Apr 2017 12:31:32 +0200 Subject: [PATCH 3/3] Import all the things! --- client/components/upgrades/google-apps/index.jsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/client/components/upgrades/google-apps/index.jsx b/client/components/upgrades/google-apps/index.jsx index 1821f3407ab6b..afa44b9195c0d 100644 --- a/client/components/upgrades/google-apps/index.jsx +++ b/client/components/upgrades/google-apps/index.jsx @@ -8,10 +8,9 @@ import { localize } from 'i18n-calypso'; /** * Internal dependencies */ -var cartItems = require( 'lib/cart-values' ).cartItems, - GoogleAppsDialog = require( './dialog' ), - HeaderCake = require( 'components/header-cake' ); - +import { cartItems } from 'lib/cart-values'; +import GoogleAppsDialog from './dialog'; +import HeaderCake from 'components/header-cake'; import { getSelectedSite } from 'state/ui/selectors'; class GoogleApps extends Component {