mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
🧑💻 Expose debubg API in new object
This commit is contained in:
parent
1f3049e2eb
commit
de71c31bc6
1 changed files with 13 additions and 8 deletions
|
@ -13,13 +13,15 @@ export const addDebugTools = ( context, modules ) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// TODO - enable this condition for version 3.0.1
|
// TODO - enable this condition for version 3.0.1
|
||||||
// In version 3.0.0 we want to have the debug tools available on every installation
|
// In version 3.0.0 we want to have the debug tools available on every installation
|
||||||
if ( ! context.debug ) { return }
|
if ( ! context.debug ) { return }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const debugApi = ( window.ppcpDebugger = window.ppcpDebugger || {} );
|
||||||
|
|
||||||
// Dump the current state of all our Redux stores.
|
// Dump the current state of all our Redux stores.
|
||||||
context.dumpStore = async () => {
|
debugApi.dumpStore = async () => {
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
if ( ! console?.groupCollapsed ) {
|
if ( ! console?.groupCollapsed ) {
|
||||||
console.error( 'console.groupCollapsed is not supported.' );
|
console.error( 'console.groupCollapsed is not supported.' );
|
||||||
|
@ -47,7 +49,7 @@ export const addDebugTools = ( context, modules ) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Reset all Redux stores to their initial state.
|
// Reset all Redux stores to their initial state.
|
||||||
context.resetStore = () => {
|
debugApi.resetStore = () => {
|
||||||
const stores = [];
|
const stores = [];
|
||||||
const { isConnected } = wp.data.select( CommonStoreName ).merchant();
|
const { isConnected } = wp.data.select( CommonStoreName ).merchant();
|
||||||
|
|
||||||
|
@ -85,7 +87,7 @@ export const addDebugTools = ( context, modules ) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Disconnect the merchant and display the onboarding wizard.
|
// Disconnect the merchant and display the onboarding wizard.
|
||||||
context.disconnect = () => {
|
debugApi.disconnect = () => {
|
||||||
const common = wp.data.dispatch( CommonStoreName );
|
const common = wp.data.dispatch( CommonStoreName );
|
||||||
|
|
||||||
common.disconnectMerchant();
|
common.disconnectMerchant();
|
||||||
|
@ -97,10 +99,13 @@ export const addDebugTools = ( context, modules ) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Enters or completes the onboarding wizard without changing anything else.
|
// Enters or completes the onboarding wizard without changing anything else.
|
||||||
context.onboardingMode = ( state ) => {
|
debugApi.onboardingMode = ( state ) => {
|
||||||
const onboarding = wp.data.dispatch( OnboardingStoreName );
|
const onboarding = wp.data.dispatch( OnboardingStoreName );
|
||||||
|
|
||||||
onboarding.setCompleted( ! state );
|
onboarding.setCompleted( ! state );
|
||||||
onboarding.persist();
|
onboarding.persist();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Expose original debug API.
|
||||||
|
Object.assign( context, debugApi );
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue