mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
🧑💻 Debug tool “reset” respects onboarding state
This commit is contained in:
parent
5173954776
commit
99d93888e1
2 changed files with 23 additions and 1 deletions
|
@ -33,12 +33,32 @@ export const addDebugTools = ( context, modules ) => {
|
|||
/* eslint-enable no-console */
|
||||
};
|
||||
|
||||
// Reset all Redux stores to their initial state.
|
||||
context.resetStore = () => {
|
||||
const stores = [ OnboardingStoreName, CommonStoreName ];
|
||||
const stores = [];
|
||||
const { isConnected } = wp.data.select( CommonStoreName ).merchant();
|
||||
|
||||
if ( isConnected ) {
|
||||
// Make sure the Onboarding wizard is "completed".
|
||||
const onboarding = wp.data.dispatch( OnboardingStoreName );
|
||||
onboarding.setCompleted( true );
|
||||
onboarding.persist();
|
||||
|
||||
// Reset all stores, except for the onboarding store.
|
||||
stores.push( CommonStoreName );
|
||||
// TODO: Add other stores here once they are available.
|
||||
} else {
|
||||
// Only reset the common & onboarding stores to restart the onboarding wizard.
|
||||
stores.push( CommonStoreName );
|
||||
stores.push( OnboardingStoreName );
|
||||
}
|
||||
|
||||
stores.forEach( ( storeName ) => {
|
||||
const store = wp.data.dispatch( storeName );
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log( `Reset store: ${ storeName }...` );
|
||||
|
||||
store.reset();
|
||||
store.persist();
|
||||
} );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue