-
Notifications
You must be signed in to change notification settings - Fork 143
Refactor task tax to use promise chain #4683
Conversation
|
If we can simply add a "by installing Jetpack and WooCommerce Services you agree to the TOS" line somewhere, and preserve plugin installation in this step, that would be worth it imo. |
|
Closing and reopening to kick off a Travis CI build. Sorry for the noise! |
|
This needs to be rebased from |
psealock
left a comment
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 is awesome @joshuatf. What was happening to cause the redirect?
I came across an error.
Here is the error in minified code:
Looks like its coming from
woocommerce-admin/client/dashboard/utils.js
Lines 19 to 25 in 0b68c1d
| export function getCountryCode( countryState ) { | |
| if ( ! countryState ) { | |
| return null; | |
| } | |
| return countryState.split( ':' )[ 0 ]; | |
| } |
To reproduce:
- Remove Address field from WC settings
- Tax Task
- Enter address and continue
- See the error. If you refresh and try again, it succeeds.
Otherwise the original bug is no longer there.
|
Thanks for the review, @psealock! I wasn't able to reproduce the address bug. Any other tricks that might help? What country did you have selected?
Your guess (discussed in Slack) as to why this was happening was correct. The previous method of checking was to monitor changes to options and redirect when a change occurred. componentDidUpdate() {
...
const {
woocommerce_calc_taxes: prevCalcTaxes,
} = prevProps.generalSettings;
if ( prevCalcTaxes === 'no' && calcTaxes === 'yes' ) {
window.location = getAdminLink(
'admin.php?page=wc-settings&tab=tax§ion=standard'
);
}
}Now that we have wp data actions returning promises, the The logic in this task was generally a mess from previous development without promises, so I took this as an opportunity to refactor the whole thing. We have quite a few other places in onboarding that are still in need of this, which I'll make note of in #2959. Besides async patterns that could use some patching from the days of wc-api, we also have some leftover error handling that won't work as expected. |
|
Also noting I added the change that @jameskoster requested in 024cf76. This shows the plugin step if plugins are needed or if opt-in to TOS is needed to enable automatic taxes. Testing steps should be mostly identical, but disable Jetpack or WCS to also note that the plugins step will appear. |
I tried again and wasn't able to do so consistently. I'm not sure what changed, but I tried it maybe 10 times and reproduced once. I'm ok with shipping this and seeing if we get reports of it happening in the wild.
Thats what I figured, but was thrown off by
This part is working well for me. I did notice one thing. When click "Install and enable" or "Continue" when having to enter my address, the Success screen showed and automatically moved on. Maybe thats because I already chose that option? |
Great catch! I think this is happening because we call I removed that snippet in ab1f19a as every step has a way of manually exiting this flow. Testing this seems to work well, but could use your 👀 to double check. |
|
Thanks for taking the time to look at this @jameskoster! Updated styling for captions in 3567fbf |
psealock
left a comment
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.
Changes look good, thanks for addressing ![]()




Fixes #4631
Fixes #4667
After the wp data transition, we now have access to async updates. Since the
awaitis now working, this caused some odd behavior on component update.The logic in this component became tricky to follow and similar to other various updates around onboarding, this PR makes use of returned promises from wp data actions and attempts to minimize the state.
@pmcpinto @jameskoster It looks like with the current behavior, plugins only get installed on the tax step if TOS is already accepted, which currently will only occur if they opt in on the benefits screen from the profiler. This seems redundant- should we remove the plugins step from here or is it possible to allow plugin installation and opt in to TOS from this step?
Detailed test instructions: