-
Notifications
You must be signed in to change notification settings - Fork 21
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
Onboarding: Create New Google Combo Accounts Card. #2601
Merged
ankitrox
merged 19 commits into
feature/2590-consolidate-google-account-cards
from
feature/2566-google-combo-card
Sep 18, 2024
Merged
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b5574cb
Onboarding: Create New Google Combo Accounts Card.
ankitrox 303aeb4
Fix linting issues.
ankitrox fdcadb4
Fix linting issues.
ankitrox 4b9ee7a
Fix js lint.
ankitrox 71fb4c7
Disable eslint error.
ankitrox 4f7f967
Resolve conflicts with base.
ankitrox 0dcb4a5
Fix failing tests.
ankitrox 85dadb0
Update links.
ankitrox 780daf2
Add E2E tests for combo card.
ankitrox 3cfb09e
Styling changes
ankitrox 204a3da
Use label prop for checkbox.
ankitrox 52eaa9b
Styling fixes.
ankitrox 6e5e09f
Remove unused variable.
ankitrox 8a152ba
Update connect-google-combo-account-card.js
ankitrox f9564ad
Update css class names and fix tests.
ankitrox 5356633
Merge branch 'feature/2566-google-combo-card' of https://github.com/w…
ankitrox 301c5e0
Fix: e2e checkbox locator.
ankitrox f396487
Fix: JS lint.
ankitrox 1b8940f
Remove redundant css rules.
ankitrox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
111 changes: 111 additions & 0 deletions
111
js/src/components/google-combo-account-card/connect-google-combo-account-card.js
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,111 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { createInterpolateElement, useState } from '@wordpress/element'; | ||
import { CheckboxControl } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { glaData } from '.~/constants'; | ||
import AccountCard, { APPEARANCE } from '.~/components/account-card'; | ||
import AppButton from '.~/components/app-button'; | ||
import readMoreLink from '../google-account-card/read-more-link'; | ||
import useGoogleConnectFlow from '../google-account-card/use-google-connect-flow'; | ||
import AppDocumentationLink from '../app-documentation-link'; | ||
|
||
/** | ||
* @param {Object} props React props | ||
* @param {boolean} props.disabled | ||
* @fires gla_google_account_connect_button_click with `{ action: 'authorization', context: 'reconnect' }` | ||
* @fires gla_google_account_connect_button_click with `{ action: 'authorization', context: 'setup-mc' }` | ||
* @fires gla_documentation_link_click with `{ context: 'setup-mc-accounts', link_id: 'required-google-permissions', href: 'https://woocommerce.com/document/google-for-woocommerce/get-started/setup-and-configuration/#required-google-permissions' }` | ||
* @fires gla_documentation_link_click with `{ context: 'setup-mc-accounts', link_id: 'google-mc-terms-of-service', href: 'https://support.google.com/merchants/answer/160173' }` | ||
* @fires gla_documentation_link_click with `{ context: 'setup-ads', link_id: 'google-ads-terms-of-service', href: 'https://support.google.com/adspolicy/answer/54818' }` | ||
*/ | ||
const ConnectGoogleComboAccountCard = ( { disabled } ) => { | ||
const pageName = glaData.mcSetupComplete ? 'reconnect' : 'setup-mc'; | ||
const [ handleConnect, { loading, data } ] = | ||
useGoogleConnectFlow( pageName ); | ||
const [ termsAccepted, setTermsAccepted ] = useState( false ); | ||
|
||
const checkboxId = 'gla-account-card-terms-conditions'; | ||
asvinb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return ( | ||
<AccountCard | ||
appearance={ APPEARANCE.GOOGLE } | ||
className="google-combo-account-card" | ||
eason9487 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
disabled={ disabled } | ||
alignIcon="top" | ||
description={ | ||
<> | ||
<p> | ||
{ __( | ||
'Required to sync with Google Merchant Center and Google Ads.', | ||
'google-listings-and-ads' | ||
) } | ||
</p> | ||
<CheckboxControl | ||
id={ checkboxId } | ||
label={ createInterpolateElement( | ||
__( | ||
'I accept the terms and conditions of <linkMerchant>Merchant Center</linkMerchant> and <linkAds>Google Ads</linkAds>', | ||
'google-listings-and-ads' | ||
), | ||
{ | ||
linkMerchant: ( | ||
<AppDocumentationLink | ||
context="setup-mc-accounts" | ||
linkId="google-mc-terms-of-service" | ||
href="https://support.google.com/merchants/answer/160173" | ||
/> | ||
), | ||
linkAds: ( | ||
<AppDocumentationLink | ||
context="setup-ads" | ||
linkId="google-ads-terms-of-service" | ||
href="https://support.google.com/adspolicy/answer/54818" | ||
/> | ||
), | ||
} | ||
) } | ||
checked={ termsAccepted } | ||
onChange={ setTermsAccepted } | ||
disabled={ disabled } | ||
/> | ||
<p className="google-combo-account-card-description"> | ||
eason9487 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<em> | ||
{ createInterpolateElement( | ||
__( | ||
'You will be prompted to give WooCommerce access to your Google account. Please check all the checkboxes to give WooCommerce all required permissions. <link>Read more</link>', | ||
'google-listings-and-ads' | ||
), | ||
{ | ||
link: readMoreLink, | ||
joemcgill marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
) } | ||
eason9487 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</em> | ||
</p> | ||
</> | ||
} | ||
alignIndicator="top" | ||
indicator={ | ||
<AppButton | ||
isSecondary | ||
disabled={ disabled || ! termsAccepted } | ||
loading={ loading || data } | ||
eventName="gla_google_account_connect_button_click" | ||
eventProps={ { | ||
context: pageName, | ||
action: 'authorization', | ||
} } | ||
text={ __( 'Connect', 'google-listings-and-ads' ) } | ||
onClick={ handleConnect } | ||
/> | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export default ConnectGoogleComboAccountCard; |
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,34 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import useGoogleAccount from '.~/hooks/useGoogleAccount'; | ||
import AppSpinner from '.~/components/app-spinner'; | ||
import AccountCard from '.~/components/account-card'; | ||
import RequestFullAccessGoogleAccountCard from '../google-account-card/request-full-access-google-account-card'; | ||
import { ConnectedGoogleAccountCard } from '../google-account-card'; | ||
import ConnectGoogleComboAccountCard from './connect-google-combo-account-card'; | ||
import './index.scss'; | ||
eason9487 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export default function GoogleComboAccountCard( { disabled = false } ) { | ||
const { google, scope, hasFinishedResolution } = useGoogleAccount(); | ||
|
||
if ( ! hasFinishedResolution ) { | ||
return <AccountCard description={ <AppSpinner /> } />; | ||
} | ||
|
||
const isConnected = google?.active === 'yes'; | ||
|
||
if ( isConnected && scope.glaRequired ) { | ||
return <ConnectedGoogleAccountCard googleAccount={ google } />; | ||
} | ||
|
||
if ( isConnected && ! scope.glaRequired ) { | ||
return ( | ||
<RequestFullAccessGoogleAccountCard | ||
additionalScopeEmail={ google.email } | ||
/> | ||
); | ||
} | ||
|
||
return <ConnectGoogleComboAccountCard disabled={ disabled } />; | ||
} |
eason9487 marked this conversation as resolved.
Show resolved
Hide resolved
|
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,6 @@ | ||
.google-combo-account-card { | ||
|
||
.google-combo-account-card-description { | ||
color: $gray-700; | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 accounts for the
readMoreLink
component. Will need to add two additional ones for the two newAppDocumentationLink
components.