mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +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
|
@ -77,6 +77,8 @@ const commonReducer = createReducer( defaultTransient, defaultPersistent, {
|
||||||
|
|
||||||
// Keep "read-only" details and initialization flags.
|
// Keep "read-only" details and initialization flags.
|
||||||
cleanState.wooSettings = { ...state.wooSettings };
|
cleanState.wooSettings = { ...state.wooSettings };
|
||||||
|
cleanState.merchant = { ...state.merchant };
|
||||||
|
cleanState.features = { ...state.features };
|
||||||
cleanState.isReady = true;
|
cleanState.isReady = true;
|
||||||
|
|
||||||
return cleanState;
|
return cleanState;
|
||||||
|
|
|
@ -33,12 +33,32 @@ export const addDebugTools = ( context, modules ) => {
|
||||||
/* eslint-enable no-console */
|
/* eslint-enable no-console */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Reset all Redux stores to their initial state.
|
||||||
context.resetStore = () => {
|
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 ) => {
|
stores.forEach( ( storeName ) => {
|
||||||
const store = wp.data.dispatch( storeName );
|
const store = wp.data.dispatch( storeName );
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log( `Reset store: ${ storeName }...` );
|
||||||
|
|
||||||
store.reset();
|
store.reset();
|
||||||
store.persist();
|
store.persist();
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue