-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' of github.com:Automattic/wp-calypso into fix/tri…
…m-double-quotes-in-command-palette
- Loading branch information
Showing
768 changed files
with
5,872 additions
and
2,690 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { useTranslate } from 'i18n-calypso'; | ||
import './style.scss'; | ||
|
||
const FormDivider = () => { | ||
const translate = useTranslate(); | ||
|
||
return ( | ||
<div className="auth-form__separator"> | ||
<div className="auth-form__separator-text">{ translate( 'or' ) }</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FormDivider; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,2 @@ | ||
import { useTranslate } from 'i18n-calypso'; | ||
import './style.scss'; | ||
|
||
export const FormDivider = () => { | ||
const translate = useTranslate(); | ||
|
||
return ( | ||
<div className="auth-form__separator"> | ||
<div className="auth-form__separator-text">{ translate( 'or' ) }</div> | ||
</div> | ||
); | ||
}; | ||
export { default as FormDivider } from './form-divider'; | ||
export { default as SocialAuthenticationForm } from './social'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import config from '@automattic/calypso-config'; | ||
import { useTranslate } from 'i18n-calypso'; | ||
import { useSelector } from 'react-redux'; | ||
import AppleLoginButton from 'calypso/components/social-buttons/apple'; | ||
import GoogleSocialButton from 'calypso/components/social-buttons/google'; | ||
import { preventWidows } from 'calypso/lib/formatting'; | ||
import { isWooOAuth2Client } from 'calypso/lib/oauth2-clients'; | ||
import { isWpccFlow } from 'calypso/signup/utils'; | ||
import { getCurrentOAuth2Client } from 'calypso/state/oauth2-clients/ui/selectors'; | ||
import getCurrentRoute from 'calypso/state/selectors/get-current-route'; | ||
import isWooCommerceCoreProfilerFlow from 'calypso/state/selectors/is-woocommerce-core-profiler-flow'; | ||
import SocialToS from './social-tos'; | ||
import type { IAppState } from 'calypso/state/types'; | ||
|
||
interface SocialAuthenticationFormProps { | ||
compact?: boolean; | ||
handleGoogleResponse: ( response: any ) => void; | ||
handleAppleResponse: ( response: any ) => void; | ||
getRedirectUri: ( service: string ) => string; | ||
trackLoginAndRememberRedirect: ( service: string ) => void; | ||
socialService: string; | ||
socialServiceResponse: string; | ||
children: JSX.Element; | ||
disableTosText?: boolean; | ||
flowName: string; | ||
} | ||
|
||
const SocialAuthenticationForm = ( { | ||
compact, | ||
handleGoogleResponse, | ||
handleAppleResponse, | ||
getRedirectUri, | ||
trackLoginAndRememberRedirect, | ||
socialService, | ||
socialServiceResponse, | ||
children, | ||
disableTosText, | ||
flowName, | ||
}: SocialAuthenticationFormProps ) => { | ||
const translate = useTranslate(); | ||
|
||
const { currentRoute, oauth2Client, isWoo } = useSelector( ( state: IAppState ) => { | ||
return { | ||
currentRoute: getCurrentRoute( state ), | ||
oauth2Client: getCurrentOAuth2Client( state ), | ||
isWoo: | ||
isWooOAuth2Client( getCurrentOAuth2Client( state ) ) || | ||
isWooCommerceCoreProfilerFlow( state ), | ||
}; | ||
} ); | ||
|
||
const shouldUseRedirectFlow = () => { | ||
// If calypso is loaded in a popup, we don't want to open a second popup for social signup or login | ||
// let's use the redirect flow instead in that case | ||
let isPopup = typeof window !== 'undefined' && window.opener && window.opener !== window; | ||
|
||
// Jetpack Connect-in-place auth flow contains special reserved args, so we want a popup for social signup and login. | ||
// See p1HpG7-7nj-p2 for more information. | ||
if ( isPopup && [ '/jetpack/connect/authorize', '/log-in/jetpack' ].includes( currentRoute ) ) { | ||
isPopup = false; | ||
} | ||
|
||
// disable for oauth2 flows for now | ||
return ! oauth2Client && isPopup; | ||
}; | ||
|
||
const uxMode = shouldUseRedirectFlow() ? 'redirect' : 'popup'; | ||
const uxModeApple = config.isEnabled( 'sign-in-with-apple/redirect' ) ? 'redirect' : uxMode; | ||
|
||
return ( | ||
// Note: we allow social sign-in on the Desktop app, but not social sign-up. Existing config flags do | ||
// not distinguish between sign-in and sign-up but instead use the catch-all `signup/social` flag. | ||
// Therefore we need to make an exception for the desktop app directly in this component because there | ||
// are many places in which the social signup form is rendered based only on the presence of the | ||
// `signup/social` config flag. | ||
! config.isEnabled( 'desktop' ) && ( | ||
<div className="auth-form__social"> | ||
{ ! compact && <p>{ preventWidows( translate( 'Or create an account using:' ) ) }</p> } | ||
|
||
<div className="auth-form__social-buttons"> | ||
<GoogleSocialButton | ||
clientId={ config( 'google_oauth_client_id' ) } | ||
responseHandler={ handleGoogleResponse } | ||
uxMode={ uxMode } | ||
redirectUri={ getRedirectUri( 'google' ) } | ||
onClick={ () => { | ||
trackLoginAndRememberRedirect( 'google' ); | ||
} } | ||
socialServiceResponse={ socialService === 'google' ? socialServiceResponse : null } | ||
startingPoint="signup" | ||
/> | ||
|
||
<AppleLoginButton | ||
clientId={ config( 'apple_oauth_client_id' ) } | ||
responseHandler={ handleAppleResponse } | ||
uxMode={ uxModeApple } | ||
redirectUri={ getRedirectUri( 'apple' ) } | ||
onClick={ () => { | ||
trackLoginAndRememberRedirect( 'apple' ); | ||
} } | ||
socialServiceResponse={ socialService === 'apple' ? socialServiceResponse : null } | ||
originalUrlPath={ | ||
// Since the signup form is only ever called from the user step, currently, we can rely on window.location.pathname | ||
// to return back to the user step, which then allows us to continue on with the flow once the submitSignupStep action is called within the user step. | ||
window?.location?.pathname | ||
} | ||
// Attach the query string to the state so we can pass it back to the server to show the correct UI. | ||
// We need this because Apple doesn't allow to have dynamic parameters in redirect_uri. | ||
queryString={ isWpccFlow( flowName ) ? window.location.search.slice( 1 ) : null } | ||
/> | ||
{ children } | ||
{ ! isWoo && ! disableTosText && <SocialToS /> } | ||
</div> | ||
{ isWoo && ! disableTosText && <SocialToS /> } | ||
</div> | ||
) | ||
); | ||
}; | ||
|
||
export default SocialAuthenticationForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.