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

Feature/2590 consolidate google account cards #2633

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
baf38d3
Removes initial cards as part of refactoring
dsawardekar Sep 5, 2024
dd17d97
Fixes linter warnings
dsawardekar Sep 5, 2024
465c090
Merge pull request #2585 from woocommerce/update/2565-remove-google-m…
joemcgill Sep 9, 2024
b5574cb
Onboarding: Create New Google Combo Accounts Card.
ankitrox Sep 11, 2024
303aeb4
Fix linting issues.
ankitrox Sep 11, 2024
fdcadb4
Fix linting issues.
ankitrox Sep 11, 2024
4b9ee7a
Fix js lint.
ankitrox Sep 11, 2024
71fb4c7
Disable eslint error.
ankitrox Sep 11, 2024
664d6d7
Merge branch 'feature/2458-streamline-onboarding' into feature/2458-c…
joemcgill Sep 11, 2024
4f7f967
Resolve conflicts with base.
ankitrox Sep 11, 2024
0dcb4a5
Fix failing tests.
ankitrox Sep 11, 2024
85dadb0
Update links.
ankitrox Sep 11, 2024
780daf2
Add E2E tests for combo card.
ankitrox Sep 12, 2024
3cfb09e
Styling changes
ankitrox Sep 12, 2024
204a3da
Use label prop for checkbox.
ankitrox Sep 13, 2024
52eaa9b
Styling fixes.
ankitrox Sep 13, 2024
6e5e09f
Remove unused variable.
ankitrox Sep 13, 2024
8a152ba
Update connect-google-combo-account-card.js
ankitrox Sep 13, 2024
f9564ad
Update css class names and fix tests.
ankitrox Sep 18, 2024
5356633
Merge branch 'feature/2566-google-combo-card' of https://github.com/w…
ankitrox Sep 18, 2024
301c5e0
Fix: e2e checkbox locator.
ankitrox Sep 18, 2024
f396487
Fix: JS lint.
ankitrox Sep 18, 2024
1b8940f
Remove redundant css rules.
ankitrox Sep 18, 2024
52a53f4
Merge pull request #2601 from woocommerce/feature/2566-google-combo-card
ankitrox Sep 18, 2024
345e6b1
Merge branch 'feature/2458-streamline-onboarding' into feature/2590-c…
joemcgill Sep 30, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/**
* 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';
import './connect-google-combo-account-card.scss';

/**
* @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 );

return (
<AccountCard
appearance={ APPEARANCE.GOOGLE }
className="gla-connect-google-combo-account-card"
disabled={ disabled }
alignIcon="top"
description={
<>
<p>
{ __(
'Required to sync with Google Merchant Center and Google Ads.',
'google-listings-and-ads'
) }
</p>
<CheckboxControl
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 }
/>
</>
}
helper={ 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,
}
) }
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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.gla-connect-google-combo-account-card {

.gla-account-card__helper {
font-size: $gla-font-base;
}
}
33 changes: 33 additions & 0 deletions js/src/components/google-combo-account-card/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* 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';

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 } />;
}
22 changes: 9 additions & 13 deletions js/src/setup-mc/setup-stepper/setup-accounts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import Section from '.~/wcdl/section';
import AppDocumentationLink from '.~/components/app-documentation-link';
import VerticalGapLayout from '.~/components/vertical-gap-layout';
import WPComAccountCard from '.~/components/wpcom-account-card';
import GoogleAccountCard from '.~/components/google-account-card';
import GoogleMCAccountCard from '.~/components/google-mc-account-card';
import GoogleAdsAccountCard from '.~/components/google-ads-account-card';
import GoogleComboAccountCard from '.~/components/google-combo-account-card';
import Faqs from './faqs';
import './index.scss';
import useGoogleAdsAccount from '.~/hooks/useGoogleAdsAccount';
Expand Down Expand Up @@ -159,17 +157,9 @@ const SetupAccounts = ( props ) => {
{ ! isJetpackActive && (
<WPComAccountCard jetpack={ jetpack } />
) }
<GoogleAccountCard disabled={ ! isJetpackActive } />
<GoogleAdsAccountCard />
<GoogleComboAccountCard disabled={ ! isJetpackActive } />
</VerticalGapLayout>
</Section>
<Section
className="gla-google-mc-account-section"
description={ <GoogleMCDisclaimer /> }
disabledLeft={ ! isGMCPreconditionReady }
>
<GoogleMCAccountCard />
</Section>

<StepContentFooter>
<StepContentActions>
Expand All @@ -181,8 +171,14 @@ const SetupAccounts = ( props ) => {
{ __( 'Continue', 'google-listings-and-ads' ) }
</AppButton>
</StepContentActions>
<Faqs />
</StepContentFooter>
<Section
className="gla-google-mc-account-section"
description={ <GoogleMCDisclaimer /> }
disabledLeft={ ! isGMCPreconditionReady }
>
<Faqs />
</Section>
</StepContent>
);
};
Expand Down
Loading