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

Merge feature/contact-info branch into trunk #943

Merged
merged 106 commits into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
7d8ae4c
Add the fourth step page for MC setup
eason9487 Jul 29, 2021
c13654c
Change values of MC steps to string type and add the fourth step key/…
eason9487 Jul 29, 2021
3adc30a
Change MC setup to have four steps
eason9487 Jul 29, 2021
2833a4b
Add API endpoints to update and fetch contact information
nima-karimi Jul 29, 2021
d289a9e
Move address comparison to a utility class
nima-karimi Jul 30, 2021
c80986f
Make sure the addresses aren't null before comparison
nima-karimi Jul 30, 2021
ad11cb1
Add unit tests for AddressUtility class
nima-karimi Jul 30, 2021
b8a2b7c
Add missing dependency for unit test
nima-karimi Jul 30, 2021
c558b2f
Create separate methods to update phone number and address
nima-karimi Jul 30, 2021
36b3413
Set source when creating issues
mikkamp Jul 28, 2021
f37670b
Helper function for getting contact info setup url
mikkamp Jul 28, 2021
0cde320
Add setting for contact info setup
mikkamp Jul 28, 2021
65e6519
Helper function for when contact info is setup
mikkamp Jul 28, 2021
c56528b
Notification when contact info is not set
mikkamp Jul 29, 2021
42e9ce6
Increase action_url size in DB table
mikkamp Jul 29, 2021
67ed5f3
Add issue to table when contact info is not set
mikkamp Jul 29, 2021
118a968
Check MC to determine if contact info is setup
mikkamp Jul 29, 2021
ea160e1
Check address and phone number
mikkamp Jul 30, 2021
6b7c335
Clear transient when updating contact details
mikkamp Jul 30, 2021
73f8d18
Add transients to MerchantVerification test
mikkamp Jul 30, 2021
600b629
Rename MerchantVerification
mikkamp Jul 30, 2021
f624d33
Save option once user has been fully setup
mikkamp Jul 30, 2021
0b7efd2
Update tests/Unit/API/Site/Controllers/MerchantCenter/ContactInformat…
nima-karimi Jul 30, 2021
e9e371f
Merge pull request #919 from woocommerce/feature/contact-info-rest-api
nima-karimi Jul 30, 2021
95116f3
Merge pull request #914 from woocommerce/feature/863-mc-setup-flow
eason9487 Aug 2, 2021
05ba64b
Add 'libphonenumber-js' to dependencies
eason9487 Jul 29, 2021
5ba451b
Decode HTML entities within countey names
eason9487 Jul 29, 2021
5de074b
Add a hook to get all supported country calling codes
eason9487 Jul 29, 2021
18cd8fa
Add a hook to get user's MC phone number
eason9487 Jul 29, 2021
17d5581
Add 'hideIcon' prop to AccountCard and make its className extendable
eason9487 Jul 29, 2021
71ef39f
Add new appearance to AccountCard for phone number
eason9487 Jul 29, 2021
2deed28
Implement the shared components of PhoneNumberCard and ContactInforma…
eason9487 Jul 29, 2021
2d4ec07
Add URLs to utils for settings and edit contact info pages
eason9487 Jul 30, 2021
425e86d
Add a hook to get store address via the core options API
eason9487 Jul 29, 2021
4debb52
Implement ContactInformationPreview for the main page of settings
eason9487 Jul 30, 2021
ce980a8
Fix icon size and gap between icon and text when icon on right side f…
eason9487 Jul 29, 2021
8c4a932
Implement the EditContactInformation page
eason9487 Jul 30, 2021
6e4d5ba
Add new appearance to AccountCard for store address
eason9487 Jul 29, 2021
f654554
Add ContactInformationPreview and EditContactInformation to settings …
eason9487 Jul 30, 2021
20c70b0
Implement the shared StoreAddressCard component
eason9487 Jul 29, 2021
e9de8d5
Update wording
eason9487 Jul 30, 2021
2eca6d2
Add StoreAddressCard to ContactInformation
eason9487 Jul 29, 2021
53f1e64
Update the URL of "Learn more" links
eason9487 Jul 30, 2021
a10f071
Update notification wording
mikkamp Aug 2, 2021
41d6b92
Integrate data store with the backend contact info API
eason9487 Aug 2, 2021
ca035de
Change the data source of useStoreAddress to the contact info API
eason9487 Aug 2, 2021
c8c2823
Add isValid and isDirty to the callback param of onPhoneNumberChange
eason9487 Aug 2, 2021
a08de81
Implement the data submission of EditContactInformation
eason9487 Aug 2, 2021
af9790b
Implement the data submission of StoreRequirements
eason9487 Aug 2, 2021
08692e0
Revert transient and rely only on option
mikkamp Aug 2, 2021
058af69
Revert unnecessary changes in test
mikkamp Aug 2, 2021
1f649ff
Move PreLaunchChecklist and related code out from the step 3 of MC setup
eason9487 Aug 2, 2021
5c3fa22
Add PreLaunchChecklist to the step 4 of MC setup
eason9487 Aug 2, 2021
945115f
Merge pull request #912 from woocommerce/feature/910-contact-info-not…
mikkamp Aug 2, 2021
8f42c78
Rename parameter and simplify conditional `setState` calls
eason9487 Aug 3, 2021
2a59a99
Use @wordpress/html-entities instead
eason9487 Aug 3, 2021
6e839d8
Rename useCountryCallingCodes to useCountryCallingCodeOptions and rem…
eason9487 Aug 3, 2021
2a5ab61
Remove useGoogleMCPhoneNumber from PhoneNumberCard
eason9487 Aug 3, 2021
051e2c7
Rename className for AppButton
eason9487 Aug 3, 2021
ebfc4fe
Move the store address check
nima-karimi Aug 3, 2021
8d76e77
Add fourth value for MC Setup step 'store_requirements'
layoutd Aug 2, 2021
770e03d
Hold rendering before settings data loaded for StoreRequirements
eason9487 Aug 3, 2021
0c9bd95
Split tests of unset value and invalid value.
eason9487 Aug 3, 2021
0fc2b84
Remove the TODO comment for 'store_requirements' constant due to back…
eason9487 Aug 3, 2021
7879f75
Refactor `…/pre-launch-checklist/checkErrors.test.js `.
tomalec Aug 3, 2021
6e0199c
Make the icon a horizontal center of focus area
eason9487 Aug 4, 2021
2e95109
Use SpinnerCard instead
eason9487 Aug 4, 2021
ffba448
Use SpinnerCard instead for the DisconnectAccounts to make all loadin…
eason9487 Aug 4, 2021
3dbc1fa
Simplify the else condition for ContactInformationPreview
eason9487 Aug 4, 2021
bf236cb
Add event tracking for the "Learn more" link in the NoContactInformat…
eason9487 Aug 4, 2021
5b7cad4
Merge pull request #917 from woocommerce/feature/863-mc-phone-number
eason9487 Aug 4, 2021
39e1069
Merge pull request #918 from woocommerce/feature/863-mc-store-address
eason9487 Aug 4, 2021
34e6f62
Pass phone number data as phoneNumber prop to PhoneNumberCard
eason9487 Aug 4, 2021
dfc4be1
Merge pull request #921 from woocommerce/feature/863-settings-contact…
eason9487 Aug 4, 2021
d03a8ec
Merge pull request #926 from woocommerce/feature/863-integrate-api
eason9487 Aug 4, 2021
d1d1b51
Merge pull request #927 from woocommerce/feature/863-pre-launch-check…
eason9487 Aug 4, 2021
b377bf8
Handle loading state within PhoneNumberCard
eason9487 Aug 5, 2021
e7f5bf9
Add JSDoc for PhoneNumberCard
eason9487 Aug 5, 2021
47440cd
Don't default to `flat` for shipping settings check
layoutd Aug 5, 2021
81d1ab4
Comment fixes
layoutd Aug 5, 2021
eed3293
!isset instead of is_null
layoutd Aug 5, 2021
c1f9aee
Merge pull request #928 from woocommerce/add/four-onboarding-steps
layoutd Aug 5, 2021
3897636
Show the divider when loading
eason9487 Aug 6, 2021
63460f7
Add a comment for the handling of initEditing = null
eason9487 Aug 6, 2021
968ab62
Simplify the if else statements
eason9487 Aug 6, 2021
967e010
Merge pull request #934 from woocommerce/feature/phone-number-card-lo…
eason9487 Aug 6, 2021
856274d
Fix calling .split() on null value in the useStoreAddress
eason9487 Aug 6, 2021
dae81d7
Fix that unable to save if only changes address
eason9487 Aug 6, 2021
b6a86eb
Check if the GMC address is filled in the ContactInformationPreview
eason9487 Aug 6, 2021
18cd80b
Merge pull request #936 from woocommerce/fix/null-store-address
ecgan Aug 9, 2021
6c40313
Merge pull request #937 from woocommerce/fix/edit-contact-info-save-l…
ecgan Aug 9, 2021
6ebb3d5
Make `useStoreAddress` cater for `mc_address` being `null`
tomalec Aug 9, 2021
c38d19d
Merge pull request #938 from woocommerce/fix/check-required-mc-address
tomalec Aug 9, 2021
aedeadf
Check whether phone number exists and call track event.
ecgan Aug 9, 2021
451b1ed
Track event when users click on phone number edit button.
ecgan Aug 9, 2021
703ed63
Track "edit store address button clicked" event,
tomalec Aug 9, 2021
ae0f9a5
Code refactor with usePhoneNumberCheckTrackEventEffect.
ecgan Aug 9, 2021
d00773a
Specify view="settings" for PhoneNumberCard in ContactInformationPrev…
ecgan Aug 9, 2021
1bcbf58
Add docs for phone number track events.
ecgan Aug 9, 2021
4caf4bc
Add docs for edit_mc_store_address track event.
ecgan Aug 9, 2021
51a10f0
Fix docs for edit_mc_store_address track event.
ecgan Aug 9, 2021
7e6b35f
Merge pull request #944 from woocommerce/add/863-track-store
tomalec Aug 9, 2021
e27bb51
Use path instead of view in usePhoneNumberCheckTrackEventEffect.
ecgan Aug 9, 2021
f563fa3
Add track event for contact_information_save_button_click.
ecgan Aug 9, 2021
400fcc4
Merge pull request #945 from woocommerce/feature/phone-number-track-e…
ecgan Aug 9, 2021
c2e9863
Merge pull request #946 from woocommerce/feature/save-contact-info-tr…
tomalec Aug 9, 2021
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
25 changes: 21 additions & 4 deletions js/src/components/account-card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import classnames from 'classnames';
import { Flex, FlexItem, FlexBlock } from '@wordpress/components';
import GridiconPhone from 'gridicons/dist/phone';
import { Icon, store as storeIcon } from '@wordpress/icons';

/**
* Internal dependencies
Expand All @@ -25,11 +28,13 @@ const googleLogoURL =
*/
export const APPEARANCE = {
GOOGLE: 'google',
PHONE: 'phone',
ADDRESS: 'address',
};

const appearanceDict = {
[ APPEARANCE.GOOGLE ]: {
logo: (
icon: (
<img
src={ googleLogoURL }
alt={ __( 'Google Logo', 'google-listings-and-ads' ) }
Expand All @@ -39,30 +44,42 @@ const appearanceDict = {
),
title: __( 'Google account', 'google-listings-and-ads' ),
},
[ APPEARANCE.PHONE ]: {
icon: <GridiconPhone size={ 32 } />,
title: __( 'Phone number', 'google-listings-and-ads' ),
},
[ APPEARANCE.ADDRESS ]: {
icon: <Icon icon={ storeIcon } size={ 32 } />,
title: __( 'Store address', 'google-listings-and-ads' ),
},
};

/**
* Renders a Card component with account info and status.
*
* @param {Object} props React props.
* @param {string} [props.className] Additional CSS class name to be appended.
* @param {APPEARANCE} props.appearance Kind of account to indicate the card appearance.
* @param {JSX.Element} props.description Content below the card title.
* @param {boolean} [props.hideIcon=false] Whether hide the leading icon.
* @param {JSX.Element} [props.indicator] Indicator of actions or status on the right side of the card.
* @param {Array<JSX.Element>} [props.children] Children to be rendered if needs more content within the card.
*/
export default function AccountCard( {
className,
appearance,
description,
hideIcon = false,
indicator,
children,
} ) {
const { logo, title } = appearanceDict[ appearance ];
const { icon, title } = appearanceDict[ appearance ];

return (
<Section.Card className="gla-account-card">
<Section.Card className={ classnames( 'gla-account-card', className ) }>
<Section.Card.Body>
<Flex gap={ 4 }>
<FlexItem>{ logo }</FlexItem>
{ ! hideIcon && <FlexItem>{ icon }</FlexItem> }
<FlexBlock>
<Subsection.Title>{ title }</Subsection.Title>
<div>{ description }</div>
Expand Down
7 changes: 6 additions & 1 deletion js/src/components/app-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ const AppButton = ( props ) => {
onClick( ...args );
};

const classes = [ 'app-button', className ];
if ( rest.iconPosition === 'right' ) {
classes.push( 'app-button--fix-icon-position-right' );
}

return (
<Button
className={ classnames( 'app-button', className ) }
className={ classnames( ...classes ) }
disabled={ disabled || loading }
onClick={ handleClick }
{ ...rest }
Expand Down
11 changes: 9 additions & 2 deletions js/src/components/app-button/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@
white-space: nowrap;

svg {
width: inherit;
height: inherit;
max-width: inherit;
max-height: inherit;

circle {
stroke: currentColor;
}
}

/**
* Fix that the SVG icon gap to text should be on the left side.
* @see https://github.com/WordPress/gutenberg/blob/%40wordpress/components%4012.0.8/packages/components/src/button/style.scss#L309-L311
*/
&--fix-icon-position-right.has-icon.has-text svg {
margin-right: 0;
margin-left: 8px;
}
}
116 changes: 116 additions & 0 deletions js/src/components/contact-information/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { getHistory } from '@woocommerce/navigation';

/**
* Internal dependencies
*/
import { getEditContactInformationUrl } from '.~/utils/urls';
import useGoogleMCPhoneNumber from '.~/hooks/useGoogleMCPhoneNumber';
import useStoreAddress from '.~/hooks/useStoreAddress';
import Section from '.~/wcdl/section';
import VerticalGapLayout from '.~/components/vertical-gap-layout';
import AppDocumentationLink from '.~/components/app-documentation-link';
import SpinnerCard from '.~/components/spinner-card';
import PhoneNumberCard from './phone-number-card';
import StoreAddressCard from './store-address-card';
import NoContactInformationCard from './no-contact-information-card';
import usePhoneNumberCheckTrackEventEffect from './usePhoneNumberCheckTrackEventEffect';

const learnMoreLinkId = 'contact-information-read-more';
const learnMoreUrl =
'https://docs.woocommerce.com/document/google-listings-and-ads/#contact-information';

const description = __(
'Your contact information is required by Google for verification purposes. It will be shared with the Google Merchant Center and will not be displayed to customers.',
'google-listings-and-ads'
);

const mcTitle = __( 'Enter contact information', 'google-listings-and-ads' );
const settingsTitle = __( 'Contact information', 'google-listings-and-ads' );

export function ContactInformationPreview() {
const phone = useGoogleMCPhoneNumber();
const address = useStoreAddress( 'mc' );

const handleEditClick = () => {
getHistory().push( getEditContactInformationUrl() );
};

let sectionContent = <SpinnerCard />;

if ( phone.loaded && address.loaded ) {
if ( phone.data.isValid && address.data.isAddressFilled ) {
sectionContent = (
<VerticalGapLayout size="overlap">
<PhoneNumberCard
view="settings"
isPreview
phoneNumber={ phone }
onEditClick={ handleEditClick }
/>
<StoreAddressCard isPreview />
</VerticalGapLayout>
);
} else {
sectionContent = (
<NoContactInformationCard
onEditClick={ handleEditClick }
learnMoreUrl={ learnMoreUrl }
learnMoreLinkId={ learnMoreLinkId }
/>
);
}
}

return (
<Section title={ settingsTitle } description={ description }>
{ sectionContent }
</Section>
);
}

export default function ContactInformation( { view, onPhoneNumberChange } ) {
const phone = useGoogleMCPhoneNumber();
const isSetupMC = view === 'setup-mc';

const initEditing = isSetupMC ? null : true;
const title = isSetupMC ? mcTitle : settingsTitle;
const trackContext = isSetupMC
? 'setup-mc-contact-information'
: 'settings-contact-information';

usePhoneNumberCheckTrackEventEffect( phone );

return (
<Section
title={ title }
description={
<div>
<p>{ description }</p>
<p>
<AppDocumentationLink
context={ trackContext }
linkId={ learnMoreLinkId }
href={ learnMoreUrl }
>
{ __( 'Learn more', 'google-listings-and-ads' ) }
</AppDocumentationLink>
</p>
</div>
}
>
<VerticalGapLayout size="large">
<PhoneNumberCard
view={ view }
phoneNumber={ phone }
initEditing={ initEditing }
onPhoneNumberChange={ onPhoneNumberChange }
/>
<StoreAddressCard />
</VerticalGapLayout>
</Section>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import GridiconNotice from 'gridicons/dist/notice';

/**
* Internal dependencies
*/
import Subsection from '.~/wcdl/subsection';
import Section from '.~/wcdl/section';
import AppButton from '.~/components/app-button';
import './no-contact-information-card.scss';

export default function NoContactInformationCard( {
onEditClick,
learnMoreUrl,
learnMoreLinkId,
} ) {
return (
<Section.Card className="gla-no-contact-information-card">
<Section.Card.Body>
<Subsection>
<Subsection.Title>
<div>
<GridiconNotice />
</div>
{ __(
'Please add your contact information',
'google-listings-and-ads'
) }
</Subsection.Title>
<Subsection.Body>
{ __(
'Google requires the phone number and store address for all stores using Google Merchant Center.',
'google-listings-and-ads'
) }
</Subsection.Body>
</Subsection>
<Subsection>
<Subsection.Body>
<AppButton isPrimary onClick={ onEditClick }>
{ __(
'Add information',
'google-listings-and-ads'
) }
</AppButton>
<AppButton
isTertiary
target="_blank"
eventName="gla_google_mc_link_click"
eventProps={ {
context:
'settings-no-contact-information-notice',
link_id: learnMoreLinkId,
href: learnMoreUrl,
} }
href={ learnMoreUrl }
>
{ __( 'Learn more', 'google-listings-and-ads' ) }
</AppButton>
</Subsection.Body>
</Subsection>
</Section.Card.Body>
</Section.Card>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.gla-no-contact-information-card {
.wcdl-subsection-title > div {
margin-bottom: 8px;
}

.wcdl-subsection-body {
color: $gray-700;
}

.gridicons-notice {
fill: $alert-red;
}

.components-button {
margin-right: $grid-unit-30;
}
}
Loading