Skip to content

Jetpack REST connection log into wp.com #22115

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

Merged
merged 32 commits into from
Aug 12, 2025
Merged

Conversation

nbradbury
Copy link
Contributor

@nbradbury nbradbury commented Aug 8, 2025

This PR provides the first step of the Jetpack REST connection flow, which is to log into WordPress.com.

To test

  • Enable application password and Jetpack connection experimental features
  • Select a self-hosted site that doesn't have Jetpack installed
  • My Site > Stats
  • Start the connection flow
  • Note the wp.com login flow starts
  • Log into wp.com
  • Note after logging in the Jetpack flow shows success and moves to the next step
  • My Site > Stats
  • Start the connection flow
  • Back out of the wp.com login flow
  • Note the step shows as failed and further steps are pursued
  • Tap retry and verify wp.com login flow starts again

Keep in mind that the remaining steps are simulated at this point.

nbradbury and others added 29 commits August 5, 2025 12:05
* Added shell for JetpackConnectionViewModel

* Added shell for JetpackConnectionScreen

* Fleshed out JetpackConnectionScreen

* Minor tweaks

* Added canInitiateJetpackConnection

* Updated comment

* Renamed const

* Removed wpApiClient

* Added activity shell

* Added activity to manifest

* Handle close

* Pass states rather than the view model

* Pass states rather than the view model,p2

* Dummy code to simulate login

* Dummy code to simulate login, p2

* Added done button

* Animate Done button, added Failed status

* Use light MaterialTheme.colorScheme.error color background for failed steps

* Animate changes to ConnectionStepItem

* Added startNextStep

* Added startNextStep, p2

* Added startNextStep, p3

* Fixed UI testing

* Fixed UI testing, p2

* Changed color for completed and in-progress cards

* Changed color for completed and in-progress cards again

* Removed elevation and changed card to column

* First pass at Retry

* Second pass at Retry

* Third pass at Retry

* Added error states

* Combined states

* Fixed Detekt errors

* Replaced hard-coded hex color values

* Minor formatting changes

* Minor formatting changes, p2

* Minor formatting changes, p3

* Updated preview to use JetpackConnectionScreen

* Simplified ConnectionStepItem

* Moved Screen to ScreenWithTopAppBarM3

* Added modifier

* Changed two icons

* Fix the done/retry button to the bottom

* Removed the heading and changed the screen title

* Increase elevation of in-progress step, remove elevation animation

* First pass at confirming cancellation

* Second pass at confirming cancellation

* Fixed detekt warnings

* Fixed detekt warnings

* Changed fun name

* Fixed isActive check

* Use ErrorEvent instead of a string

* Fixed new Detekt warnings

* Renamed variable

* Retry starts at the failed step

* Moved getNextStep to its own fun

* Simplified retrying from step

* Added optional message to ErrorType

* Updated wp.com error message

* Moved color constants to color resources

* Use existing color resources for in-progress step

* Don't use !! for selected site

* Replaced throwing exception with error() to resolve Detekt warning

* Simplified JetpackConnectionViewModel

* Simplified JetpackConnectionScreen

* Simplified JetpackConnectionActivity
* Rely on isUsingSelfHostedRestApi to determine whether we can use the new JP REST connection

* Removed starting the flow from the main activity

* Launch the new flow from stats if available

* Simplified canInitiateJetpackConnection

* Renamed feature to Experimental Jetpack *REST* Connection to avoid confusion with existing web-based flow

* Fixed Detekt line length warnings

* Add "Simulated" to screen title to make it clear there's nothing happening

* Renamed experimental key
…-Android into feature/jp-rest-connect-wpcom

Conflicts:
	WordPress/src/main/java/org/wordpress/android/ui/jetpackrestconnection/JetpackRestConnectionActivity.kt
	WordPress/src/main/java/org/wordpress/android/ui/jetpackrestconnection/JetpackRestConnectionScreen.kt
	WordPress/src/main/java/org/wordpress/android/ui/jetpackrestconnection/JetpackRestConnectionViewModel.kt
	WordPress/src/main/res/values/strings.xml
@nbradbury nbradbury requested a review from Copilot August 8, 2025 17:07
@dangermattic
Copy link
Collaborator

dangermattic commented Aug 8, 2025

2 Warnings
⚠️ strings.xml files should only be updated on release branches, when the translations are downloaded by our automation.
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the first step of the Jetpack REST connection flow by adding WordPress.com login functionality. It introduces a new login mode specifically for the Jetpack REST connection process and updates the UI to handle login flow completion.

Key changes:

  • Adds JETPACK_REST_CONNECT login mode to support the new flow
  • Implements WordPress.com login step in the connection process
  • Updates error handling to distinguish between login and connection failures

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
LoginMode.java Adds new JETPACK_REST_CONNECT enum value for the login mode
strings.xml Splits generic connection error into specific login and connection error messages
JetpackRestConnectionViewModel.kt Implements WordPress.com login step with proper state management and error handling
JetpackRestConnectionScreen.kt Updates UI to show error messages instead of status text when failures occur
JetpackRestConnectionActivity.kt Handles login activity result and integrates with the connection flow
LoginActivity.java Adds support for the new login mode with appropriate result handling
ActivityLauncher.java Provides utility method to launch WordPress.com login for Jetpack REST connection

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Aug 8, 2025

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr22115-efc81fb
Commitefc81fb
Direct Downloadwordpress-prototype-build-pr22115-efc81fb.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Aug 8, 2025

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr22115-efc81fb
Commitefc81fb
Direct Downloadjetpack-prototype-build-pr22115-efc81fb.apk
Note: Google Login is not supported on these builds.

Copy link

codecov bot commented Aug 8, 2025

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.43%. Comparing base (8724988) to head (efc81fb).
⚠️ Report is 2 commits behind head on trunk.

Files with missing lines Patch % Lines
...ava/org/wordpress/android/ui/ActivityLauncher.java 0.00% 6 Missing ⚠️
...in/java/org/wordpress/android/login/LoginMode.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #22115   +/-   ##
=======================================
  Coverage   39.43%   39.43%           
=======================================
  Files        2149     2149           
  Lines      101872   101872           
  Branches    15604    15604           
=======================================
  Hits        40177    40177           
  Misses      58126    58126           
  Partials     3569     3569           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nbradbury nbradbury marked this pull request as ready for review August 8, 2025 18:14
@nbradbury nbradbury requested a review from adalpari August 8, 2025 18:14
Comment on lines 50 to 52
private var _isWaitingForWPComLogin = false
val isWaitingForWPComLogin: Boolean
get() = _isWaitingForWPComLogin
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ How come using a getter form an internal variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching that! I'm assuming that change was made by Claude and I somehow missed it. Resolved in efc81fb.

Copy link
Contributor

@adalpari adalpari left a comment

Choose a reason for hiding this comment

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

LGTM and works as expected!

Copy link

@nbradbury nbradbury merged commit fa1fa2a into trunk Aug 12, 2025
26 checks passed
@nbradbury nbradbury deleted the feature/jp-rest-connect-wpcom branch August 12, 2025 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants