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

Admin Page: Get the connection URL from initial state instead of fetching it #8014

Merged
merged 5 commits into from
Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 3 additions & 5 deletions _inc/client/components/connect-button/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
isUnlinkingUser as _isUnlinkingUser
} from 'state/connection';
import { getSiteRawUrl } from 'state/initial-state';
import QueryConnectUrl from 'components/data/query-connect-url';
import onKeyDownCallback from 'utils/onkeydown-callback';
import JetpackDisconnectDialog from 'components/jetpack-disconnect-dialog';

Expand Down Expand Up @@ -136,14 +135,13 @@ export const ConnectButton = React.createClass( {
render() {
return (
<div>
<QueryConnectUrl />
{ this.renderContent() }
{ this.props.children }
{ ! this.props.isSiteConnected &&
{ ! this.props.isSiteConnected &&
<p className="jp-banner__tos-blurb">
{ __(
{ __(
'By connecting your site you agree to our fascinating {{tosLink}}Terms of Service{{/tosLink}} and to {{shareDetailsLink}}share details{{/shareDetailsLink}} with WordPress.com',
{
{
components: {
tosLink: <a href="https://wordpress.com/tos" rel="noopener noreferrer" target="_blank"/>,
shareDetailsLink: <a href="https://jetpack.com/support/what-data-does-jetpack-sync" rel="noopener noreferrer" target="_blank"/>
Expand Down
6 changes: 1 addition & 5 deletions _inc/client/components/connect-button/test/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ describe( 'ConnectButton', () => {

const wrapper = shallow( <ConnectButton { ...testProps } /> );

it( 'queries URL to connect', () => {
expect( wrapper.find( 'QueryConnectUrl' ) ).to.exist;
} );

it( 'renders a button to connect or link', () => {
expect( wrapper.find( 'Button' ) ).to.have.length( 1 );
} );
Expand Down Expand Up @@ -135,4 +131,4 @@ describe( 'ConnectButton', () => {

} );

} );
} );
4 changes: 2 additions & 2 deletions _inc/client/components/jetpack-connect/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { translate as __ } from 'i18n-calypso';
* Internal dependencies
*/
import ConnectButton from 'components/connect-button';
import { getConnectUrl as _getConnectUrl } from 'state/connection';
import { getConnectUrl as getConnectUrl } from 'state/connection';
import { imagePath } from 'constants';

const JetpackConnect = React.createClass( {
Expand Down Expand Up @@ -214,7 +214,7 @@ const JetpackConnect = React.createClass( {
export default connect(
state => {
return {
connectUrl: _getConnectUrl( state )
connectUrl: getConnectUrl( state )
}
}
)( JetpackConnect );
2 changes: 0 additions & 2 deletions _inc/client/components/jetpack-notices/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { getSiteConnectionStatus, getSiteDevMode, isStaging, isInIdentityCrisis,
import { isDevVersion, userCanManageModules, userIsSubscriber } from 'state/initial-state';
import DismissableNotices from './dismissable';
import { getConnectUrl as _getConnectUrl } from 'state/connection';
import QueryConnectUrl from 'components/data/query-connect-url';
import JetpackBanner from 'components/jetpack-banner';
import { JETPACK_CONTACT_BETA_SUPPORT } from 'constants';

Expand Down Expand Up @@ -192,7 +191,6 @@ const JetpackNotices = React.createClass( {
render() {
return (
<div aria-live="polite">
<QueryConnectUrl />
<NoticesList />
<JetpackStateNotices />
<DevVersionNotice isDevVersion={ this.props.isDevVersion } userIsSubscriber={ this.props.userIsSubscriber } />
Expand Down
2 changes: 2 additions & 0 deletions _inc/client/state/connection/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export const disconnectSite = () => {
disconnectingSite: disconnectingSite
} );
dispatch( removeNotice( 'disconnect-jetpack' ) );
} ).then( () => {
dispatch( fetchConnectUrl() );
} ).catch( error => {
dispatch( {
type: DISCONNECT_SITE_FAIL,
Expand Down
4 changes: 3 additions & 1 deletion _inc/client/state/connection/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import includes from 'lodash/includes';
*/
import {
JETPACK_CONNECTION_STATUS_FETCH,
JETPACK_SET_INITIAL_STATE,
CONNECT_URL_FETCH,
CONNECT_URL_FETCH_FAIL,
CONNECT_URL_FETCH_SUCCESS,
Expand Down Expand Up @@ -42,9 +43,10 @@ export const status = ( state = { siteConnected: window.Initial_State.connection

export const connectUrl = ( state = '', action ) => {
switch ( action.type ) {
case JETPACK_SET_INITIAL_STATE:
return action.initialState.connectUrl;
case CONNECT_URL_FETCH_SUCCESS:
return action.connectUrl;

default:
return state;
}
Expand Down
1 change: 1 addition & 0 deletions _inc/lib/admin-pages/class.jetpack-react-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ function page_admin_scripts() {
'isPublic' => '1' == get_option( 'blog_public' ),
'isInIdentityCrisis' => Jetpack::validate_sync_error_idc_option(),
),
'connectUrl' => Jetpack::init()->build_connect_url( true, false, false ),
'dismissedNotices' => $this->get_dismissed_jetpack_notices(),
'isDevVersion' => Jetpack::is_development_version(),
'currentVersion' => JETPACK__VERSION,
Expand Down