-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Jetpack Connect: Redirect Pressable partner plan connection after authorize #20025
Conversation
|
||
// Redirect sites hosted on Pressable with a partner plan to some URL. | ||
// 51652 is a testing partner ID. | ||
if ( 49640 === partnerId || 51652 === partnerId ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move those magic numbers to a constant somewhere ( for example,
* Constants |
I added the correct URL in 71e9c16. Please remember to wall off that flow from non-a12s until we ship to customers. |
71e9c16
to
739ca22
Compare
I've updated the PR per your feedback @johnHackworth. This should be ready for review now. |
You can append |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left some questions and suggestions.
Testing works well for me, I see a branded connect page and I'm sent to a NUX flow I've never seen before after connect.
Connecting a "normal" site continues to work… normally 🙂
@@ -185,6 +197,18 @@ class LoggedInForm extends Component { | |||
return startsWith( get( props, [ 'authorizationData', 'queryObject', 'from' ] ), 'jpo' ); | |||
} | |||
|
|||
shouldRedirectJetpackStart( props ) { | |||
const partnerId = parseInt( get( props, 'partnerId' ), 10 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
props
should always be an object, get(...)
shouldn't add any value, we can access directly, often we'll use destructuring assignment:
shouldRedirectJetpackStart( props ) {
const { partnerId } = props;
// …
}
// or even
shouldRedirectJetpackStart( { partnerId } ) {
// partnerId is already assigned!
// …
}
parseInt
should be redundant, it's in the selector:
wp-calypso/client/state/selectors/get-jetpack-connect-partner-id.js
Lines 18 to 20 in 875df39
export default function getJetpackConnectPartnerId( state ) { | |
return parseInt( get( getAuthorizationRemoteQueryData( state ), 'partner_id', 0 ), 10 ); | |
} |
// Redirect sites hosted on Pressable with a partner plan to some URL. | ||
if ( | ||
config.isEnabled( 'jetpack/connect-redirect-pressable-credential-approval' ) && | ||
PRESSABLE_CLIENT_ID === parseInt( partnerId, 10 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseInt
is redundant, it's in the selector:
wp-calypso/client/state/selectors/get-jetpack-connect-partner-id.js
Lines 18 to 20 in 875df39
export default function getJetpackConnectPartnerId( state ) { | |
return parseInt( get( getAuthorizationRemoteQueryData( state ), 'partner_id', 0 ), 10 ); | |
} |
|
||
/** | ||
* Constants | ||
*/ | ||
const MAX_AUTH_ATTEMPTS = 3; | ||
const PLANS_PAGE = '/jetpack/connect/plans/'; | ||
const debug = debugModule( 'calypso:jetpack-connect:authorize-form' ); | ||
const PRESSABLE_CLIENT_ID = 49640; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be PRESSABLE_PARTNER_ID
?
config/wpcalypso.json
Outdated
@@ -41,6 +41,7 @@ | |||
"help/courses": true, | |||
"jetpack/activity-log": true, | |||
"jetpack/api-cache": true, | |||
"jetpack/connect-redirect-pressable-credential-approval": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a public environment. Is that OK?
config/horizon.json
Outdated
@@ -39,6 +39,7 @@ | |||
"help/courses": true, | |||
"jetpack/activity-log": true, | |||
"jetpack/api-cache": true, | |||
"jetpack/connect-redirect-pressable-credential-approval": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a public environment. Is that OK?
e75c6c1
to
52d2bfd
Compare
Thanks for the review @sirreal. I've updated the PR per your feedback and have rebased against master to get rid of a merge conflict. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed the testing instructions and this works well. I left a comment regarding a block that was tricky for me to decipher, feel free to do with that as you wish.
Ready to 🚢 at will, thanks!
// If the redirect flag is set, then we conditionally redirect the Pressable client to | ||
// a credential approval screen. Otherwise, we need to redirect all other partners back | ||
// to wp-admin. | ||
return partnerRedirectFlag ? partnerId && PRESSABLE_PARTNER_ID !== partnerId : partnerId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's taken me several readings to appreciate what's going on here. This should return true
if we have a partnerId
and it's not the PRESSABLE_PARTNER_ID
, otherwise false
. Is that right?
Do you think something like the following better expresses the intent?
shouldRedirectJetpackStart( { partnerId } ) {
if ( ! partnerId ) {
return false;
}
// Pressable sites have a special NUX behind a flag
if ( config.isEnabled( 'jetpack/connect-redirect-pressable-credential-approval' ) ) {
return PRESSABLE_PARTNER_ID !== partnerId
}
return true;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that. I'd prefer to merge for now, but will be glad to address in a follow-up PR.
As part of activity log and rewind, we need users to approve credential collection after authorizing the connection to their new site. This PR will redirect all Pressable sites that are connecting for a partner plan to a separate authorize screen to approve the rewind connection.
To test:
npm start
.wordpress.com
withcalypso.localhost:3000
and then go to that URL 🤦♂️/me
. We need the updated URL from the Activity Log folks