-
Notifications
You must be signed in to change notification settings - Fork 22
Free Listings + Paid Ads: Combine the audience and shipping steps #1616
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
Free Listings + Paid Ads: Combine the audience and shipping steps #1616
Conversation
…t into SetupFreeListings for the editing free listings page
@@ -1,5 +1,11 @@ | |||
// Jest Snapshot v1, https://goo.gl/fbAQLP | |||
|
|||
exports[`checkErrors Audience When the audience countries array is empty and the value of audience location option is 'selected', should not pass 1`] = `"Please select at least one country."`; |
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.
💅 Out of this PR and opinionated
Maybe to consider migration to unit testing?
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.
Do you mean replacing expect( errors.countries ).toBe( 'Please select at least one country.' );
with expect( errors.countries ).toMatchSnapshot();
? If so, some related discussions can be found in #893 (comment) and #927 (comment).
shipping_rate: 'automatic', | ||
shipping_time: 'flat', |
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.
❓ Not a suggestion, just curious. Why we are not adding the default values inside data store DEFAULT_STATE ?
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.
I saw we use null values as checkers for other stuff... probably because of that
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.
The intent here is to trigger API to save the form's default values. It would be easier and more suitable to handle the intent here.
In addition, moving the default values of form layer to wp-data store layer will also bring different abstraction of data/states isolation. Since isResolving
and hasFinishedResolution
are not enough to cover all statuses of a state in wp-store (see issue #438.), and considering the "statuses" of states in wp-data haven't yet had a consistent definition/convention, for now, the default value in a wp-data state is more like the status that tells the state is not ready to be used. And after receiving the data from API, the state will be changed to that data, which will also change the status of that state to "the status of the state is ready, and the data is the state itself".
IMO, before a consistent definition/convention of the statuses, states, and data in wp-data is created, it's probably hard to say how to set a default value would be a good practice.
@@ -58,6 +100,15 @@ const SavedSetupStepper = ( { savedStep, onRefetchSavedStep = () => {} } ) => { | |||
} | |||
}; | |||
|
|||
function handleFormChange( errorMessage, newValue ) { | |||
this( newValue ).catch( () => createNotice( 'error', errorMessage ) ); |
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.
💅 it was a bit confusing to understand what this
was doing here. I saw after in the code that we bind the action to be called in SetupFreeListings
.
However, would be nice to add a JSDOC in this function explaining whats going on.
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.
Added in d8ecc08.
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.
Now is perfect! thanks
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.
- I checked the behaviour. Tested locally and I didn't find any error. All the combos worked fine for me.
- I checked also the code. Since there is a lot of files deleted and moved around mixed with changes in those files. It was a bit hard to differentiate what was added/changed and what was just a copy paste for the deleted files. However everything looks good for me... left a few comments and minor questions
I was unable to save with empty value in the audience selector. 🤔 I guess do you mean it shows an error when the autosave runs when the selector is empty? |
Thanks for the review, @puntope
Sorry for the inconvenience, I was trying to separate this as smaller PRs but the second one would only be including file deletions. So I ended up choosing to use deal with it altogether. There are no deleted file changes that were caused by copy-and-paste. All deleted files were actually deleted (20e758f). And two deleted-and-added files are completely different:
Yes. UI allows the operation to clear the value in the audience selector but then it causes an error. It may confuse merchants. I will check it later while working on this project and open a follow-up issue if needed. |
I agree |
Changes proposed in this Pull Request:
It's a part of 📌 Adjust the setting sections in the onboarding steps in #1610. Mainly focus on combining the audience and shipping steps for the onboarding flow and the editing free listings page. Most visual and wording changes are not included.
SetupFreeListings
component of editing free listings to the shared directory.ChooseAudience
toChooseAudienceSection
and merge it intoSetupFreeListings
with corresponding validations for the editing free listings.SetupFreeListings
with the shared one for the onboarding flow.use-debounce
.It also handles some issues:
useGetRemainingCountryCodes
hooks after this PR.ChooseAudience
andSetupFreeListings
with the shared components, the auto-saving mechanism is implemented withon*Change
callbacks instead. All auto-saving hooks and debouncing are no longer in need.onChange
handler #1335Screenshots:
📷 Onboarding flow
📷 Edit free listings
Detailed test instructions:
Onboarding flow
Edit free listings
Additional details:
mc/target_audience
will respond with an 400 error if saving with empty countries. From my memory, it should be ok before because the UI allows merchants to unselect all. 🤔Changelog entry