Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design Picker: Implement useRedirectDesignSetupOldSlug hook #100534

Merged
merged 3 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useEffect } from 'react';
import { getStepOldSlug } from './get-step-old-slug';
import type { StepperStep, Navigate } from '../internals/types';

const DESIGN_SETUP_SLUG = 'design-setup';

export function useRedirectDesignSetupOldSlug(
currentStep: string,
navigate: Navigate< StepperStep[] >
) {
const oldSlug = getStepOldSlug( DESIGN_SETUP_SLUG );
useEffect( () => {
if ( currentStep === oldSlug ) {
navigate( DESIGN_SETUP_SLUG );
}
}, [ currentStep, navigate, oldSlug ] );
}
5 changes: 3 additions & 2 deletions client/landing/stepper/declarative-flow/import-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useSiteSlugParam } from 'calypso/landing/stepper/hooks/use-site-slug-pa
import { ONBOARD_STORE, USER_STORE } from 'calypso/landing/stepper/stores';
import { ImporterMainPlatform } from 'calypso/lib/importer/types';
import { stepsWithRequiredLogin } from '../utils/steps-with-required-login';
import { useRedirectDesignSetupOldSlug } from './helpers/use-redirect-design-setup-old-slug';
import { STEPS } from './internals/steps';
import {
AssertConditionState,
Expand Down Expand Up @@ -116,6 +117,8 @@ const importFlow: Flow = {
);
};

useRedirectDesignSetupOldSlug( _currentStep, navigate );

const submit = ( providedDependencies: ProvidedDependencies = {}, ...params: string[] ) => {
switch ( _currentStep ) {
case 'importList':
Expand Down Expand Up @@ -169,7 +172,6 @@ const importFlow: Flow = {
}
}

case 'designSetup':
case 'design-setup': {
return navigate( 'processing' );
}
Expand Down Expand Up @@ -306,7 +308,6 @@ const importFlow: Flow = {
case 'importReadyNot':
case 'importReadyWpcom':
case 'importReadyPreview':
case 'designSetup':
case 'design-setup':
return navigate( `import?siteSlug=${ siteSlugParam }` );

Expand Down
5 changes: 0 additions & 5 deletions client/landing/stepper/declarative-flow/internals/steps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ export const STEPS = {
asyncComponent: () => import( './steps-repository/design-setup' ),
},

DESIGN_SETUP_LEGACY: {
slug: 'designSetup',
asyncComponent: () => import( './steps-repository/design-setup' ),
},

DIFM_STARTING_POINT: {
slug: 'difmStartingPoint',
asyncComponent: () => import( './steps-repository/difm-starting-point' ),
Expand Down
6 changes: 3 additions & 3 deletions client/landing/stepper/declarative-flow/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { getLoginUrl } from '../utils/path';
import { stepsWithRequiredLogin } from '../utils/steps-with-required-login';
import { useBigSkyBeforePlans } from './helpers/use-bigsky-before-plans-experiment';
import { useGoalsFirstExperiment } from './helpers/use-goals-first-experiment';
import { useRedirectDesignSetupOldSlug } from './helpers/use-redirect-design-setup-old-slug';
import { recordStepNavigation } from './internals/analytics/record-step-navigation';
import { STEPS } from './internals/steps';
import { AssertConditionState, Flow, ProvidedDependencies } from './internals/types';
Expand Down Expand Up @@ -117,7 +118,6 @@ const onboarding: Flow = {
STEPS.GOALS,
STEPS.DESIGN_CHOICES,
STEPS.DESIGN_SETUP,
STEPS.DESIGN_SETUP_LEGACY,
STEPS.DIFM_STARTING_POINT
);
}
Expand Down Expand Up @@ -166,6 +166,7 @@ const onboarding: Flow = {
} else if ( typeof window !== 'undefined' ) {
window.__a8cBigSkyOnboarding = false;
}

/**
* Returns [destination, backDestination] for the post-checkout destination.
*/
Expand Down Expand Up @@ -199,6 +200,7 @@ const onboarding: Flow = {
};

clearUseMyDomainsQueryParams( currentStepSlug );
useRedirectDesignSetupOldSlug( currentStepSlug, navigate );

const submit = async ( providedDependencies: ProvidedDependencies = {} ) => {
switch ( currentStepSlug ) {
Expand Down Expand Up @@ -228,7 +230,6 @@ const onboarding: Flow = {
}
}

case 'designSetup':
case 'design-setup': {
return navigate( 'domains' );
}
Expand Down Expand Up @@ -428,7 +429,6 @@ const onboarding: Flow = {
}
return navigate( 'design-setup' );
}
case 'designSetup':
case 'design-setup':
if ( isDesignChoicesStepEnabled ) {
return navigate( 'design-choices' );
Expand Down
6 changes: 3 additions & 3 deletions client/landing/stepper/declarative-flow/site-setup-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useSiteData } from '../hooks/use-site-data';
import { useCanUserManageOptions } from '../hooks/use-user-can-manage-options';
import { ONBOARD_STORE, SITE_STORE, USER_STORE } from '../stores';
import { shouldRedirectToSiteMigration } from './helpers';
import { useRedirectDesignSetupOldSlug } from './helpers/use-redirect-design-setup-old-slug';
import { useLaunchpadDecider } from './internals/hooks/use-launchpad-decider';
import { STEPS } from './internals/steps';
import { redirect } from './internals/steps-repository/import/util';
Expand Down Expand Up @@ -60,7 +61,6 @@ const siteSetupFlow: FlowV1 = {
STEPS.OPTIONS,
STEPS.DESIGN_CHOICES,
STEPS.DESIGN_SETUP,
STEPS.DESIGN_SETUP_LEGACY,
STEPS.BLOGGER_STARTING_POINT,
STEPS.COURSES,
STEPS.IMPORT,
Expand Down Expand Up @@ -272,6 +272,8 @@ const siteSetupFlow: FlowV1 = {
navigate,
} );

useRedirectDesignSetupOldSlug( currentStep, navigate );

function submit( providedDependencies: ProvidedDependencies = {}, ...params: string[] ) {
switch ( currentStep ) {
case 'options': {
Expand All @@ -286,7 +288,6 @@ const siteSetupFlow: FlowV1 = {
return navigate( 'bloggerStartingPoint' );
}

case 'designSetup':
case 'design-setup': {
return navigate( 'processing' );
}
Expand Down Expand Up @@ -519,7 +520,6 @@ const siteSetupFlow: FlowV1 = {
case 'courses':
return navigate( 'bloggerStartingPoint' );

case 'designSetup':
case 'design-setup':
if ( intent === SiteIntent.DIFM ) {
return navigate( 'difmStartingPoint' );
Expand Down
6 changes: 4 additions & 2 deletions client/landing/stepper/declarative-flow/update-design.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useQuery } from '../hooks/use-query';
import { useSiteIdParam } from '../hooks/use-site-id-param';
import { useSiteSlug } from '../hooks/use-site-slug';
import { ONBOARD_STORE } from '../stores';
import { useRedirectDesignSetupOldSlug } from './helpers/use-redirect-design-setup-old-slug';
import { STEPS } from './internals/steps';
import { ProcessingResult } from './internals/steps-repository/processing-step/constants';
import { ProvidedDependencies } from './internals/types';
Expand All @@ -24,7 +25,7 @@ const updateDesign: Flow = {
},
isSignupFlow: false,
useSteps() {
return [ STEPS.DESIGN_SETUP, STEPS.DESIGN_SETUP_LEGACY, STEPS.PROCESSING, STEPS.ERROR ];
return [ STEPS.DESIGN_SETUP, STEPS.PROCESSING, STEPS.ERROR ];
},
useSideEffect() {
const { setIntent } = useDispatch( ONBOARD_STORE );
Expand Down Expand Up @@ -55,6 +56,8 @@ const updateDesign: Flow = {
navigate,
} );

useRedirectDesignSetupOldSlug( currentStep, navigate );

function submit( providedDependencies: ProvidedDependencies = {}, ...results: string[] ) {
switch ( currentStep ) {
case 'processing':
Expand All @@ -79,7 +82,6 @@ const updateDesign: Flow = {
} )
);

case 'designSetup':
case 'design-setup':
if ( providedDependencies?.goToCheckout ) {
const destination = `/setup/${ flowToReturnTo }/launchpad?siteSlug=${ providedDependencies.siteSlug }`;
Expand Down