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

Launch: use step-by-step launch flow after new onboarding with free plan #47493

Merged
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
Expand Up @@ -21,9 +21,7 @@ interface CalypsoifyWindow extends Window {
launchUrl?: string;
isGutenboarding?: boolean;
isSiteUnlaunched?: boolean;
isNewLaunchMobile?: boolean;
isExperimental?: boolean;
isPersistentLaunchButton?: boolean;
[ key: string ]: unknown;
};
}
Expand All @@ -38,18 +36,14 @@ domReady( () => {
let handled = false;
function updateEditor() {
const isGutenboarding = window?.calypsoifyGutenberg?.isGutenboarding;
const isPersistentLaunchButton = window?.calypsoifyGutenberg?.isPersistentLaunchButton;

if (
// Don't proceed if this function has already run
handled ||
// Don't proceed if the site has already been launched
! window?.calypsoifyGutenberg?.isSiteUnlaunched ||
// Don't proceed if the launch URL is missing
! window?.calypsoifyGutenberg?.launchUrl ||
// Don't proceed is the site wasn't created through Gutenbaording,
// or if the create/persistent-launch-button flag is enabled
! ( isGutenboarding || isPersistentLaunchButton )
! window?.calypsoifyGutenberg?.launchUrl
) {
return;
}
Expand All @@ -63,10 +57,6 @@ function updateEditor() {
}
clearInterval( awaitSettingsBar );

const BREAK_MEDIUM = 782;
const isMobileViewport = window.innerWidth < BREAK_MEDIUM;
// Enables the "step by step" flow also for mobile viewports
const isNewLaunchMobile = window?.calypsoifyGutenberg?.isNewLaunchMobile;
const isExperimental = window?.calypsoifyGutenberg?.isExperimental;

// Assert reason: We have an early return above with optional and falsy values. This should be a string.
Expand All @@ -82,15 +72,18 @@ function updateEditor() {
// Disable href navigation
e.preventDefault();

// Clicking on the persisten "Launch" button (when added to the UI)
// would normally open the control launch flow by redirecting the
// page to `launchUrl`.
// But if the site was created via Gutenboarding (/new),
// and potentially depending on the browser's viewport, the control
// launch flow gets replaced by the "Step by Step" launch flow,
// appering in a modal on top of the editor (no redirect needed)
const shouldOpenStepByStepLaunch =
isGutenboarding && ( ! isMobileViewport || ( isMobileViewport && isNewLaunchMobile ) );
/*
* Default:
* Clicking on the "Launch" button would open the control launch flow
* by redirecting the page to `launchUrl`.
*
* New Onboarding (with a free plan):
* If the site was created via New Onboarding flow (starting at /new) with a free plan,
* the control launch flow gets replaced by the "Step by Step" launch flow,
* displayed in a modal on top of the editor (no redirect needed)
*/
const shouldOpenStepByStepLaunch = isGutenboarding;

// This currently comes from a feature flag, but should eventually be
// replaced with A/B testing logic
const shouldOpenFocusedLaunch = window?.calypsoifyGutenberg?.isFocusedLaunchFlow;
Expand Down
10 changes: 6 additions & 4 deletions client/gutenberg/editor/calypsoify-iframe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,14 @@ class CalypsoifyIframe extends Component<
}

if ( EditorActions.GetGutenboardingStatus === action ) {
const isGutenboarding = this.props.siteCreationFlow === 'gutenboarding' && ! this.props.plan;
const isGutenboarding =
this.props.siteCreationFlow === 'gutenboarding' &&
( ! this.props.plan || this.props.plan.is_free ); // prevent showing StepByStepLaunch on sites with paid plans
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting the ( ! this.props.plan || this.props.plan.is_free ) check here may cause some confusion, since the isGutenboarding variable now carries a different meaning that is not just to do with the site creation flow.

Would it be better move the check under a separate siteHasFreePlan variable, and pass that variable to calypsoifyGutenberg?
The code on the Editing Toolkit side could then check for isGutenboarding && siteHasFreePlan, making the code more explicit on what's going on

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree there is a better way to do this and also prevent confusion. Opened #47504 to unblock current PR so we can quickly fix the issue from the Calypso side and then implement a more solid solution that involves deploying ETK and WBE.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Thank you for opening a separate issue to track this.

const isSiteUnlaunched = this.props.isSiteUnlaunched;
const launchUrl = `${ window.location.origin }/start/launch-site?siteSlug=${ this.props.siteSlug }`;
const isNewLaunchMobile = config.isEnabled( 'gutenboarding/new-launch-mobile' );
const isExperimental = config.isEnabled( 'gutenboarding/feature-picker' );
const isPersistentLaunchButton = config.isEnabled( 'create/persistent-launch-button' );
const isNewLaunchMobile = config.isEnabled( 'gutenboarding/new-launch-mobile' ); // TODO: remove after ETK 2.8.6 is released
const isExperimental = config.isEnabled( 'gutenboarding/feature-picker' ); // TODO: remove after ETK 2.8.6 is released
const isPersistentLaunchButton = config.isEnabled( 'create/persistent-launch-button' ); // TODO: remove after ETK 2.8.6 is released
ciampo marked this conversation as resolved.
Show resolved Hide resolved
const isFocusedLaunchFlow = config.isEnabled( 'create/focused-launch-flow' );

ports[ 0 ].postMessage( {
Expand Down