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

Add blurb to inform users to connect Google Ads child account and not a parent MCC account #1359

Merged
merged 7 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
Expand Up @@ -6,25 +6,24 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import useExistingGoogleAdsAccounts from '.~/hooks/useExistingGoogleAdsAccounts';
import AppSelectControl from '.~/components/app-select-control';
import toAccountText from '.~/utils/toAccountText';

const AdsAccountSelectControl = ( props ) => {
const { existingAccounts = [] } = useExistingGoogleAdsAccounts();
const { accounts, ...rest } = props;

const options = [
{
value: '',
label: __( 'Select one', 'google-listings-and-ads' ),
},
...existingAccounts.map( ( acc ) => ( {
...accounts.map( ( acc ) => ( {
value: acc,
label: toAccountText( acc ),
} ) ),
];

return <AppSelectControl options={ options } { ...props } />;
return <AppSelectControl options={ options } { ...rest } />;
};

export default AdsAccountSelectControl;
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
/**
* External dependencies
*/
import { useState } from '@wordpress/element';
import { useState, createInterpolateElement } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Button, CardDivider } from '@wordpress/components';

/**
* Internal dependencies
*/
import AdsAccountSelectControl from '.~/components/ads-account-select-control';
import AccountCard, { APPEARANCE } from '.~/components/account-card';
import AppButton from '.~/components/app-button';
import AppDocumentationLink from '.~/components/app-documentation-link';
import ContentButtonLayout from '.~/components/content-button-layout';
import LoadingLabel from '.~/components/loading-label';
import Section from '.~/wcdl/section';
import Subsection from '.~/wcdl/subsection';
import useApiFetchCallback from '.~/hooks/useApiFetchCallback';
import useDispatchCoreNotices from '.~/hooks/useDispatchCoreNotices';
import useGoogleAdsAccount from '.~/hooks/useGoogleAdsAccount';
import AdsAccountSelectControl from './ads-account-select-control';
import './index.scss';

const ConnectAds = ( props ) => {
const { onCreateNew = () => {} } = props;
const { accounts, onCreateNew = () => {} } = props;
const [ value, setValue ] = useState();
const [ isLoading, setLoading ] = useState( false );
const [ fetchConnectAdsAccount ] = useApiFetchCallback( {
Expand All @@ -32,6 +33,14 @@ const ConnectAds = ( props ) => {
const { refetchGoogleAdsAccount } = useGoogleAdsAccount();
const { createNotice } = useDispatchCoreNotices();

/**
* Boolean to display blurb message to advise users
* to connect Google Ads sub-account and not manager account.
*
* The message is displayed when there are more than one Google Ads account.
*/
const displayMessage = accounts.length > 1;

const handleConnectClick = async () => {
if ( ! value ) {
return;
Expand Down Expand Up @@ -64,12 +73,32 @@ const ConnectAds = ( props ) => {
<Section.Card.Body>
<Subsection.Title>
{ __(
'Connect your Google Ads account',
'Select an existing account',
'google-listings-and-ads'
) }
</Subsection.Title>
{ displayMessage && (
<Subsection.Body>
{ createInterpolateElement(
__(
'If you manage multiple sub-accounts in Google Ads, please connect the relevant sub-account, not a manager account. <link>Learn more</link>',
'google-listings-and-ads'
),
{
link: (
<AppDocumentationLink
context="setup-ads-connect-account"
linkId="connect-sub-account"
href="https://support.google.com/google-ads/answer/6139186"
/>
),
}
) }
</Subsection.Body>
) }
<ContentButtonLayout>
<AdsAccountSelectControl
accounts={ accounts }
value={ value }
onChange={ setValue }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@
.app-select-control {
flex-grow: 1;
}

.wcdl-subsection-body {
margin-bottom: 8px;

a {
text-decoration: none;
ecgan marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ const NonConnected = () => {
setIgnoreExisting( true );
};

return <ConnectAds onCreateNew={ handleCreateNew } />;
return (
<ConnectAds
accounts={ existingAccounts }
onCreateNew={ handleCreateNew }
/>
);
};

export default NonConnected;