-
Notifications
You must be signed in to change notification settings - Fork 147
Migrated "import" store to "wp.data" #4982
Conversation
4871e9f
to
13d20d8
Compare
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.
Looking good @octaedro, this is quite the refactor!
I noted a few things, and found some items in testing but I'm not sure if they how they relate to these changes:
I had more orders than the total, which led to an odd UI
Here is a shot of the API response showing the same thing.
It also showed is_importing: false
and the UI said "Finalizing" with the spinner showing, but it remained that way for a long time and continued to poll the server until I refreshed the page. I would have expected it to stop and show some kind of indication of success.
"Delete Previously Imported Data" didn't really do anything until I refreshed the page some time later. I don't know if thats a different issue.
I also got this warning:
Property setImportFinished returned from dispatchMap in useDispatchWithMap must be a function.`
Finally, when the button received the disabled
prop the UI doesn't reflect that, so it can be misleading to the user because the button looks enabled. This obviously is a separate issue to tackle later. Issue here: #5046
noteTypes: 'info,warning,marketing,survey', | ||
}; | ||
|
||
export const TIMEOUT = 3 * SECOND; |
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.
We should use the constants found in packages/data/src/constants.js
.
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.
Good idea! The constants were moved in the commit 2b79e38
* Internal dependencies | ||
*/ | ||
import { formatParams } from './utils'; | ||
import { recordEvent } from '../../../lib/tracks'; |
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.
If you rebase, this code is now at import { recordEvent } from '@woocommerce/tracks';
client/wc-api/wc-api-spec.js
Outdated
...imports.operations.read( resourceNames ), | ||
...items.operations.read( resourceNames ), | ||
]; | ||
return [ ...items.operations.read( resourceNames ) ]; | ||
}, | ||
update( resourceNames, data ) { | ||
return [ ...items.operations.update( resourceNames, data ) ]; |
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.
Items
have now been removed, so this whole file can be removed after a rebase.
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.
Would removing the file client/wc-api/wc-api-spec.js
generate some problems here?
This commit migrates the "import" store to "wp.data" # Conflicts: # client/analytics/settings/historical-data/layout.js # packages/data/src/index.js # Conflicts: # packages/data/src/index.js # Conflicts: # packages/data/src/index.js
This commit adds error handling to the apiFetch
This commit removes old import store files and "wc-api-spec" import references # Conflicts: # client/wc-api/wc-api-spec.js # Conflicts: # client/wc-api/wc-api-spec.js
# Conflicts: # client/analytics/settings/historical-data/index.js
# Conflicts: # client/analytics/settings/historical-data/index.js
# Conflicts: # client/analytics/settings/historical-data/index.js
# Conflicts: # client/analytics/settings/historical-data/index.js
Thank you @psealock for your review. I answered the questions you asked below. I couldn't replicate this issue. I tried with 20 orders and 20 customers and everything worked ok.
This is a preexisting issue, I solved it in the commit d736c7f
Weird, this process usually takes a lot of time but I never experienced something like that. Did refreshing the page fix the problem for you?
The current behavior is inherited from the old version. When the importation process finishes the user will see
This is also inherited. It's working but it doesn't tell the user what is going on in the API side.
Solved in the commit bee9f92
I solved this problem in the commit aada1d3 |
|
||
class HistoricalData extends Component { | ||
constructor() { | ||
super( ...arguments ); | ||
|
||
this.dateFormat = __( 'MM/DD/YYYY', 'woocommerce-admin' ); | ||
this.intervalId = -1; | ||
this.lastImportStopTimestamp = 0; | ||
this.cacheNeedsClearning = true; |
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.
typo
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.
lastImportStartTimestamp | ||
|
||
const isError = Boolean( | ||
getImportError( lastImportStartTimestamp ) || |
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.
is this a || a
?
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.
Nice catch! This was fixed in the commit e417088
! isStatusLoading && | ||
inProgress && | ||
inProgress && | ||
! cacheNeedsClearning && |
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.
same typo as above
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.
Everything looked fine in the first step until it seemed to get stuck when almost completed importing orders and refunds. When I refreshed the page everything was zero-ed out but the re-import data button wasn't present so I couldn't test the second step.
Assuming that this is just a quirk with my setup (I have thousands of customers and orders) this looks fine.
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 @octaedro ! Nice work. I left a comment about the CSS for disabled button, otherwise looking good.
Would removing the file client/wc-api/wc-api-spec.js generate some problems here?
yes probably. I deleted the entire client/wc-api
folder to see what would happen. Theres a lot of conflicts with code still using parts of wc-api. Once this is merged, I think it would good to address those in a follow up.
@@ -112,4 +112,7 @@ | |||
.woocommerce-settings-historical-data__actions { | |||
align-items: center; | |||
display: flex; | |||
button:disabled { | |||
opacity: 0.5 !important; | |||
} |
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 works great, but I think should be removed because its a problem across all wc-admin. Issue to track here: #5046
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.
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.
That last comment was meant to be an approval 🎉
As all the suggested changes were addressed I'll proceed to merge this PR. |
Fixes #3382
This PR migrates the
import
store towp.data
.Also added error handling.
Screenshots
Detailed test instructions:
WooCommerce
|Analytics
|Settings
(URL:/wp-admin/admin.php?page=wc-admin&path=/analytics/settings
)WC-Admin
off, add a new order and turn it on again.customers
andorders and refunds
available to import should be visible.Start
.Re-import data
Re-import data
. Press it.Stop
should be visible until the importation finishes.Be careful when you press
Delete Previously Imported Data
. It could show a false positive since it's a process that runs under the hoodChangelog Note:
Dev: migrate import store to wp.data (don't include this in plugin changelog)