Automattic / wp-calypso

The JavaScript and API powered WordPress.com
https://developer.wordpress.com
GNU General Public License v2.0
12.4k stars 1.98k forks source link

New Onboarding: redirect new users to use-your-domain flow #51137

Closed razvanpapadopol closed 2 years ago

razvanpapadopol commented 3 years ago

What

Add the option to redirect to the existing use-your-domain flow on DomainStep in New onboarding for new (logged-out) users.

Why

Allow users to create wp com sites using their own domain

A/C

How

Refactor useOnLogin and useOnSignup hooks to stop creating the site by default at signup/login and do any action set by the Gutenboarding app.

Examples of such actions:

Basically we currently have createSite as the action X in the diagram below and we want it to be a configurable action.

Screenshot 2021-03-17 at 17 11 03

Additional context PR that added this feature for existing users (already logged-in): https://github.com/Automattic/wp-calypso/pull/48692 Main issue: https://github.com/Automattic/wp-calypso/issues/44645

ciampo commented 3 years ago

Note to self on next steps, after some investigation today:

  1. Refactor the hooks without changing functionality:

    • Extract logic for the createSite function out of the useOnLogin and useOnSignup hooks
    • Modify both hooks to accept a callback to execute. The callback will be a function that gets certain parameters (like userId and siteId). These parameters are going to be provided by the hooks
    • Pass the extracted createSite function as a callback to the hooks
  2. Introduce the "Use a domain I own" button for logged out users

    • Show login/signup modal when clicking the button
    • Create a callback to redirect the user for the useOnLogin and useOnSignup hooks

Steps 1 and 2 should probably happen in 2 separate PR, to facilitate the review process

razvanpapadopol commented 3 years ago

Idea for handling Calypso Login success: pass the URL (/start/domains/use-your-domain?source=${ window.location.href }) to SignupForm and use it at https://github.com/Automattic/wp-calypso/blob/trunk/client/landing/gutenboarding/components/signup-form/index.tsx#L193