🧑‍💻 Improve Redux debugging

This commit is contained in:
Philipp Stracker 2025-01-23 17:42:07 +01:00
parent 09ca3d0871
commit cbdf0c23e6
No known key found for this signature in database

View file

@ -2,7 +2,10 @@ import {
OnboardingStoreName,
CommonStoreName,
PaymentStoreName,
SettingsStoreName,
StylingStoreName,
} from './index';
import { setCompleted } from './onboarding/actions';
export const addDebugTools = ( context, modules ) => {
if ( ! context || ! context?.debug ) {
@ -50,9 +53,10 @@ export const addDebugTools = ( context, modules ) => {
// Reset all stores, except for the onboarding store.
stores.push( CommonStoreName );
// TODO: Add other stores here once they are available.
stores.push( PaymentStoreName );
} else {
stores.push( PaymentStoreName );
stores.push( SettingsStoreName );
stores.push( StylingStoreName );
} else {
// Only reset the common & onboarding stores to restart the onboarding wizard.
stores.push( CommonStoreName );
stores.push( OnboardingStoreName );
@ -80,4 +84,12 @@ export const addDebugTools = ( context, modules ) => {
window.location.reload();
};
// Enters or completes the onboarding wizard without changing anything else.
context.onboardingMode = ( state ) => {
const onboarding = wp.data.dispatch( OnboardingStoreName );
onboarding.setCompleted( ! state );
onboarding.persist();
};
};