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

Improve Google Verification Service integration #10143

Merged
merged 22 commits into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3994f0f
Do not verify site on page load
Tug Sep 14, 2018
ce12e14
Show error notice on google site verification error response
Tug Sep 14, 2018
4063d9c
Do not disable editing the meta tag even when site is verified
Tug Sep 14, 2018
4574b80
Improve design for google site verification
Tug Sep 18, 2018
5cad344
Align google verified checkbox vertically
cbauerman Sep 18, 2018
dbea585
Only update site verification token on load if it's not set yet
Tug Sep 19, 2018
dd15d2b
Do not revert to Site is verified immediately when user saves a custo…
Tug Sep 19, 2018
630d9a3
Add a little bit of space between the input and the bottom message fo…
Tug Sep 19, 2018
f1fffb7
Increase size of external icon
Tug Sep 19, 2018
af5edcf
Track click on the 2 google site verification options
Tug Sep 19, 2018
1743b7f
Get the google search console admin url from the api response
Tug Sep 20, 2018
f59c439
Add message to unverify site
Tug Sep 21, 2018
16b651e
Do not continue if the check verify endpoint returns an error
Tug Sep 21, 2018
c00bb05
Simplify true props in jsx
Tug Sep 21, 2018
7a00bf2
Remove border left
Tug Sep 24, 2018
fe62fc0
Make sure users who cannot access the site keyring do not see the aut…
Tug Sep 24, 2018
95e315e
Rename state properties to use snakeCase
Tug Sep 24, 2018
238245c
Track user saving after manually editing
Tug Sep 24, 2018
da1dc42
change copy of Auto verify with Google to Auto-verify with Google
Tug Sep 24, 2018
0e0307f
Revert to the default UI after save in every case
Tug Sep 24, 2018
43b29e9
Display an helpful message when another admin tried to edit the HTML …
Tug Sep 24, 2018
3daae34
Display the default text field for the google meta tag if user is dis…
Tug Sep 24, 2018
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
4 changes: 0 additions & 4 deletions _inc/client/state/site-verify/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ export const checkVerifyStatusGoogle = () => {
type: JETPACK_SITE_VERIFY_GOOGLE_STATUS_FETCH_FAIL,
error: error.response,
} );

return Promise.reject( error.response );
} );
};
};
Expand All @@ -59,8 +57,6 @@ export const verifySiteGoogle = () => {
type: JETPACK_SITE_VERIFY_GOOGLE_REQUEST_FAIL,
error: error.response,
} );

return Promise.reject( error.response );
} );
};
};
Expand Down
4 changes: 4 additions & 0 deletions _inc/client/state/site-verify/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,7 @@ export function isConnectedToGoogleSiteVerificationAPI( state ) {
export function isSiteVerifiedWithGoogle( state ) {
return get( state, 'jetpack.siteVerify.google.verified', false );
}

export function getGoogleSiteVerificationError( state ) {
return get( state, 'jetpack.siteVerify.google.error', null );
}
42 changes: 32 additions & 10 deletions _inc/client/traffic/verification-services.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ import {
isFetchingGoogleSiteVerify,
isConnectedToGoogleSiteVerificationAPI,
isSiteVerifiedWithGoogle,
isVerifyingGoogleSite
isVerifyingGoogleSite,
getGoogleSiteVerificationError,
} from 'state/site-verify';
import { userCanManageOptions } from 'state/initial-state';
import { createNotice } from 'components/global-notices/state/notices/actions';

class VerificationServicesComponent extends React.Component {
static serviceIds = {
Expand Down Expand Up @@ -84,20 +86,37 @@ class VerificationServicesComponent extends React.Component {
}

componentWillMount() {
this.checkVerifySite();
this.props.checkVerifyStatusGoogle().then( ( { token } ) => {
if ( token !== this.props.getSettingCurrentValue( 'google' ) ) {
return this.props.updateOptions( { google: token } );
}
} );
}

Choose a reason for hiding this comment

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

We should be using componentDidMount() to run side effects like this one. componentWillMount() has been deprecated.


checkVerifySite() {
checkAndVerifySite() {
this.props.checkVerifyStatusGoogle().then( ( { token } ) => {
if ( token !== this.props.getSettingCurrentValue( 'google' ) ) {
return this.props.updateOptions( { google: token } );
}
} ).then( () => {
if ( ! this.props.isSiteVerifiedWithGoogle ) {
this.props.verifySiteGoogle();
this.props.verifySiteGoogle().then( () => {
if ( this.props.googleSiteVerificationError ) {
this.props.createNotice(
'is-error',
__( 'Site failed to verify: %(error)s', {
args: {
error: this.props.googleSiteVerificationError.message
}
} ),
{
id: 'verify-site-google-error',
duration: 5000
}
);
}
} );
}
} ).catch( () => {
// ignore error
} );
}

Expand All @@ -108,12 +127,12 @@ class VerificationServicesComponent extends React.Component {

if ( ! this.props.isConnectedToGoogle ) {
requestExternalAccess( this.props.googleSiteVerificationConnectUrl, () => {
this.checkVerifySite();
this.checkAndVerifySite();
} );
return;
}

this.checkVerifySite();
this.checkAndVerifySite();
};

renderGoogleVerifyButton() {
Expand Down Expand Up @@ -244,10 +263,11 @@ class VerificationServicesComponent extends React.Component {
value={ this.getSiteVerificationValue( 'google' ) }
placeholder={ this.getMetaTag( 'google', '1234' ) }
className="code"
disabled={ this.props.isUpdating( 'google' ) || this.props.isSiteVerifiedWithGoogle }
disabled={ this.props.isUpdating( 'google' ) }
onChange={ this.props.onOptionChange } />
{ this.renderGoogleVerifyButton() }
</FormLabel>
<div>hello</div>
<FormLabel
className="jp-form-input-with-prefix"
key="verification_service_bing">
Expand Down Expand Up @@ -301,11 +321,13 @@ export const VerificationServices = connect(
isConnectedToGoogle: isConnectedToGoogleSiteVerificationAPI( state ),
isSiteVerifiedWithGoogle: isSiteVerifiedWithGoogle( state ),
isVerifyingGoogleSite: isVerifyingGoogleSite( state ),
userCanManageOptions: userCanManageOptions( state )
userCanManageOptions: userCanManageOptions( state ),
googleSiteVerificationError: getGoogleSiteVerificationError( state ),
};
},
{
checkVerifyStatusGoogle,
createNotice,
verifySiteGoogle,
}
)( moduleSettingsForm( VerificationServicesComponent ) );