mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge branch 'trunk' into PCP-4102-save-and-display-pay-later-messaging-configuration
This commit is contained in:
commit
855aa9cf9b
16 changed files with 159 additions and 81 deletions
|
@ -6,15 +6,22 @@ import {
|
|||
StylingStoreName,
|
||||
TodosStoreName,
|
||||
} from './index';
|
||||
import { setCompleted } from './onboarding/actions';
|
||||
|
||||
export const addDebugTools = ( context, modules ) => {
|
||||
if ( ! context || ! context?.debug ) {
|
||||
if ( ! context ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
// 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
|
||||
if ( ! context.debug ) { return }
|
||||
*/
|
||||
|
||||
const debugApi = ( window.ppcpDebugger = window.ppcpDebugger || {} );
|
||||
|
||||
// Dump the current state of all our Redux stores.
|
||||
context.dumpStore = async () => {
|
||||
debugApi.dumpStore = async () => {
|
||||
/* eslint-disable no-console */
|
||||
if ( ! console?.groupCollapsed ) {
|
||||
console.error( 'console.groupCollapsed is not supported.' );
|
||||
|
@ -42,7 +49,7 @@ export const addDebugTools = ( context, modules ) => {
|
|||
};
|
||||
|
||||
// Reset all Redux stores to their initial state.
|
||||
context.resetStore = () => {
|
||||
debugApi.resetStore = () => {
|
||||
const stores = [];
|
||||
const { isConnected } = wp.data.select( CommonStoreName ).merchant();
|
||||
|
||||
|
@ -70,13 +77,17 @@ export const addDebugTools = ( context, modules ) => {
|
|||
// eslint-disable-next-line no-console
|
||||
console.log( `Reset store: ${ storeName }...` );
|
||||
|
||||
store.reset();
|
||||
store.persist();
|
||||
try {
|
||||
store.reset();
|
||||
store.persist();
|
||||
} catch ( error ) {
|
||||
console.error( ' ... Reset failed, skipping this store' );
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
// Disconnect the merchant and display the onboarding wizard.
|
||||
context.disconnect = () => {
|
||||
debugApi.disconnect = () => {
|
||||
const common = wp.data.dispatch( CommonStoreName );
|
||||
|
||||
common.disconnectMerchant();
|
||||
|
@ -88,10 +99,13 @@ export const addDebugTools = ( context, modules ) => {
|
|||
};
|
||||
|
||||
// Enters or completes the onboarding wizard without changing anything else.
|
||||
context.onboardingMode = ( state ) => {
|
||||
debugApi.onboardingMode = ( state ) => {
|
||||
const onboarding = wp.data.dispatch( OnboardingStoreName );
|
||||
|
||||
onboarding.setCompleted( ! state );
|
||||
onboarding.persist();
|
||||
};
|
||||
|
||||
// Expose original debug API.
|
||||
Object.assign( context, debugApi );
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue