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

Launchpad: "first_post_published" task links to first post if you have one #39259

Merged
merged 4 commits into from
Sep 11, 2024

Conversation

renancarvalho
Copy link
Contributor

@renancarvalho renancarvalho commented Sep 5, 2024

Fixes Automattic/wp-calypso#94086

Proposed changes:

Some flows allow the user to start writing before they reach the Launchpad, if that is the case, users can have a Draft post when they arrive at the Launchpad. As reported in Automattic/wp-calypso#94086, the user can find themselves in an onboarding flow loop: they draft a first post, head back to the launchpad, click "write your first post", draft a new post, head back to the launchpad, etc. etc.
The user should be more successful completing the task if they don't end up in a loop.

This PR adds checks on the Launchpad API and to return the correct task URL:

  • Links to either an existing draft or an empty editor
  • Links to either wp-admin or Calypso editors depending on flow and site options
  • Returns different copy depending on whether an existing draft exists.

This PR works in concert with Automattic/wp-calypso#94259 which updates the client logic so that it respects the URL returned by the server. That's why extra logic for start-writing and design-first flows have been added to the server, because it replicates logic that used to be present in Calypso.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

No

Testing instructions:

The same testing instructions as the Calypso PR Automattic/wp-calypso#94259 replicated below for convenience.

Extra things to test for this PR are to using logging or some other mechanism to confirm the caching in the new wpcom_launchpad_get_latest_draft_id function works as expected.

* Add the Jetpack changes to your sandbox * Sandbox `public-api` * Run `bin/jetpack-downloader test jetpack-mu-wpcom-plugin feat/launchpad_draft_post` * See PCYsg-Osp-p2 for more details * Build Calypso changes locally * Test `write` flow with a draft post * Create new site using `/start` * When asked about goals choose **Write & Publish** * Continue on flow and choose **Draft your first post: Start writing** button * Confirm the suggested writing ideas modal appears when the editor loads * This is controlled by the `new_prompt=true` query param * Save your post as draft but *do not publish* * Preview the draft in a new tab * In the new tab click **Next steps** * You are taken to launchpad, at this point you'll need to change the page domain back to `calypso.localhost:3000` * Confirm the **Continue to write your first post** button links back to the editor * It should re-open your existing post * It should use the Calypso editor * There is no `new_prompt` modal when the editor loads * Now test in `wp-admin` mode * Jump straight to `/settings/general/{{ site slug }}` and change the admin interface to **classic** * Click **My Home** in the sidebar to get redirected to the launchpad (confirm your still looking at `calypso.localhost:3000`) * Confirm the **Continue to write your first post** button links back to the editor * It should re-open your existing post * It should use the`wp-admin` editor * There is no `new_prompt` modal when the editor loads * Test `write` flow with no draft post in Calypso site * Create new site using `/start` * When asked about goals choose **Write & Publish** * Continue on flow and choose **Draft your first post: Start writing** button * Confirm the suggested writing ideas modal appears when the editor loads * This is controlled by the `new_prompt=true` query param * *do not save a draft*, leave the editor with the (W) button * You are taken to launchpad, at this point you'll need to change the page domain back to `calypso.localhost:3000` * Confirm the **Write your first post** button links back to the editor * It opens a blank editor * It should use the Calypso editor * This is a `new_prompt` modal when the editor loads (they might have accidentally dropped out of the flow earlier so I think it's reasonable to show it to them here) * Now test in `wp-admin` mode * Jump straight to `/settings/general/{{ site slug }}` and change the admin interface to **classic** * Click **My Home** in the sidebar to get redirected to the launchpad (confirm your still looking at `calypso.localhost:3000`) * Confirm the **Continue to write your first post** button links back to the editor * It should open a blank editor * It should use the`wp-admin` editor * There is a `new_prompt` modal when the editor loads * Test `start-writing` or `design-first` flow * Create a new site using `/setup/start-writing` * You are eventually taken to the launchpad * Confirm the **Write your first post** button links to the editor * It should open a blank editor * It should use the `wp-admin` editor (remember these flows are special cased to use `wp-admin`) * There is no `new_prompt` modal * An `origin` query param has been added * Save and preview a draft post * In the new tab click **Next steps** * Back in the launchpad (confirm you're on `calypso.localhost:3000`) check the **Continue to write your first post** button * It should open the existing draft * It should use the `wp-admin` editor (remember these flows are special cased to use `wp-admin`) * There is no `new_prompt` modal * An `origin` query param has been added

Copy link
Contributor

github-actions bot commented Sep 5, 2024

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!

Copy link
Contributor

github-actions bot commented Sep 5, 2024

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the feat/launchpad_draft_post branch.

    • For jetpack-mu-wpcom changes, also add define( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN', true ); to your wp-config.php file.
  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack-mu-wpcom-plugin feat/launchpad_draft_post
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@p-jackson p-jackson self-assigned this Sep 9, 2024
The logic for looking up existing draft posts is shifted to
wpcom_launchpad_get_latest_draft_id(). This allows the get_title()
function to also use it to determine which button label to present to
the user.
p-jackson pushed a commit to Automattic/wp-calypso that referenced this pull request Sep 10, 2024
The first_post_published task was using the calypso_path returned by the
server, expect for `starting-writing` and `design-first` flows, which
wanted to always open the wp-admin editor.
In Automattic/jetpack#39259 the server now always returns a wp-admin
path for these flows, so the special casing is no longer required.
@p-jackson p-jackson added the Groundskeeping Worked on by Dotcom Groundskeeping label Sep 10, 2024
@p-jackson p-jackson marked this pull request as ready for review September 10, 2024 04:22
@p-jackson p-jackson changed the title Launchpad: Return draft post if user has it Launchpad: "first_post_published" task links to first post if you have one Sep 10, 2024
Copy link
Contributor

@arthur791004 arthur791004 left a comment

Choose a reason for hiding this comment

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

Tested and it works as expected. I can the copy of the task changes to "Continue to write your first post" and it links to my draft correctly

image

@p-jackson p-jackson merged commit 1ea6041 into trunk Sep 11, 2024
61 of 62 checks passed
@p-jackson p-jackson deleted the feat/launchpad_draft_post branch September 11, 2024 04:14
p-jackson pushed a commit to Automattic/wp-calypso that referenced this pull request Sep 11, 2024
…ve one (#94259)

* Use API url

* All flows using first_post_published path returned by server

The first_post_published task was using the calypso_path returned by the
server, expect for `starting-writing` and `design-first` flows, which
wanted to always open the wp-admin editor.
In Automattic/jetpack#39259 the server now always returns a wp-admin
path for these flows, so the special casing is no longer required.

* Adjust tests to match new first_post_published behaviour

---------

Co-authored-by: Philip Jackson <philip@Philips-MacBook-Pro.local>
gogdzl pushed a commit that referenced this pull request Oct 25, 2024
…e one (#39259)

* Check if draft post exist and return

* changelog

* first_post_published copy depends on existence of existing draft

The logic for looking up existing draft posts is shifted to
wpcom_launchpad_get_latest_draft_id(). This allows the get_title()
function to also use it to determine which button label to present to
the user.

---------

Co-authored-by: Philip Jackson <philip@Philips-MacBook-Pro.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Groundskeeping Worked on by Dotcom Groundskeeping [mu wpcom Feature] Launchpad [Package] Jetpack mu wpcom WordPress.com Features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Onboarding: if you draft a post, preview it, and hit "next steps" it asks you to write a post again
3 participants