Skip to content

My Jetpack: Onboarding i3 - Init tab panel #43595

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

Conversation

manzoorwanijk
Copy link
Member

@manzoorwanijk manzoorwanijk commented May 23, 2025

Completes MYJP-129

Proposed changes:

  • Adds the initial tab panel component to My Jetpack

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?

Testing instructions:

  • Go to My Jetpack after completing the connection
  • Confirm that you see the tab panel
  • Navigate to the tabs
  • Confirm that the URL gets updated
  • Reload the page
  • Confirm that the select tab is preserved
Screen.Recording.2025-05-23.at.5.22.06.PM.mov

@manzoorwanijk manzoorwanijk requested a review from a team May 23, 2025 11:54
@manzoorwanijk manzoorwanijk self-assigned this May 23, 2025
@manzoorwanijk manzoorwanijk added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Team Review Obsolete. Use Needs Review instead. Enhancement labels May 23, 2025
Copy link
Contributor

github-actions bot commented May 23, 2025

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 WoA dev 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 (Jetpack), and enable the add/my-jetpack/onboarding-i3-basic-tab-panel branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/my-jetpack/onboarding-i3-basic-tab-panel

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

Copy link
Contributor

github-actions bot commented May 23, 2025

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 Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label May 23, 2025
Copy link

jp-launch-control bot commented May 23, 2025

Code Coverage Summary

No summary data is available for parent commit 72a9ac1, so cannot calculate coverage changes. 😴

If that commit is a feature branch rather than a trunk commit, this is expected. Otherwise, this should be updated once coverage for 72a9ac1 is available.

Full summary · PHP report · JS report

Copy link
Contributor

@robertsreberski robertsreberski left a comment

Choose a reason for hiding this comment

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

Works good, thanks for the quick implementation!

I'm leaving some of the feedback below; most urgent functional feedback is that we should probably explicitly mention which paths are supported by tab system - or revert to the default path if some custom not existing one is provided.

@@ -4,7 +4,7 @@ export const MY_JETPACK_MY_PLANS_PURCHASE_NO_SITE_SOURCE = 'my-jetpack-my-plans-
export const MY_JETPACK_PRODUCT_CHECKOUT = 'my-jetpack-product-checkout';

export const MyJetpackRoutes = {
Home: '/',
Home: '/:tab',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be more exhaustive here which options for tabs are available? As I understand, currently it might match anything other than defined paths?

Copy link
Member Author

Choose a reason for hiding this comment

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

React Router does not support pattern matching here, but we can validate the value when using it.

[ navigate, params.tab ]
);

const tabRenderer = useCallback( ( tab: { name: string; title: string } ) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can benefit from more explicit typing here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you have any suggestions about it?

const navigate = useNavigate();

const onTabSelect = useCallback(
( tabName: string ) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can benefit from more explicit typing here.

return (
<TabPanel
className={ styles[ 'tab-panel' ] }
initialTabName={ params.tab || 'overview' }
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we perhaps also replace the path to /overview if the initial tab name is not provided?

Also, I would probably go for some globally defined constant "DEFAULT_INITIAL_TAB" instead of hardcoding it here in code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it defaults to /overview if nothing is provided or if an invalid tab name is supplied.

Comment on lines 49 to 62
tabs={ [
{
name: 'overview',
title: __( 'Overview', 'jetpack-my-jetpack' ),
},
{
name: 'products',
title: __( 'Products', 'jetpack-my-jetpack' ),
},
{
name: 'help',
title: __( 'Help', 'jetpack-my-jetpack' ),
},
] }
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's better to define it as a variable outside of the component?

I also lack (type) connection between this array and tabComponentMap. It could be more exhaustive that options provided here should match the mapping and vice-versa.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it's better to define it as a variable outside of the component?

That doesn't play nice with translations as the components update but the variable outside the component never updates/re-renders.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have extracted it to a function instead of a variable that works well with translations.

@manzoorwanijk manzoorwanijk removed the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label May 23, 2025
@manzoorwanijk manzoorwanijk requested a review from a team May 23, 2025 14:05
@manzoorwanijk manzoorwanijk force-pushed the add/my-jetpack/onboarding-i3-basic-tab-panel branch from 20aba9b to 557e310 Compare May 23, 2025 14:33
Copy link
Contributor

@robertsreberski robertsreberski left a comment

Choose a reason for hiding this comment

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

I believe it's almost there but still would recommend the routing to be more in sync with UI.

Comment on lines +21 to +23
if ( tabName !== params.section ) {
navigate( `/${ tabName }` );
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should we have a guard here, to prevent setting random tab names (and blank page)?

or better, use replaceState() to keep the url in sync? otherwise /blabla will display "Overview" page, while not critical - it's not perfect as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

But since we control the tabs, where will the random value come from?

Copy link
Contributor

Choose a reason for hiding this comment

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

right, that's true! thanks, I think then the only case is if I input manually #/foobar

Copy link
Member Author

Choose a reason for hiding this comment

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

the only case is if I input manually #/foobar

That won't do anything because no route is registered corresponding that path

Copy link
Member Author

@manzoorwanijk manzoorwanijk May 26, 2025

Choose a reason for hiding this comment

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

I have fixed it in ae26423

You can see what happens if I update the URL manually. The key prop will reset the state when the URL is updated manually.

Screen.Recording.2025-05-26.at.7.02.34.PM.mov

Comment on lines +33 to +35
const initialTab = isValidMyJetpackSection( params.section )
? params.section
: MY_JETPACK_SECTION_OVERVIEW;
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we could have this value behind useState( () => return initialTab and maybe do replaceState() )

Copy link
Member Author

@manzoorwanijk manzoorwanijk May 26, 2025

Choose a reason for hiding this comment

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

Why? The URL should reflect immediately because TabPanel calls that onSelect with the initialTabName on mount and it in turn updates the URL accordingly. We don't need to manage any state here.

Copy link
Contributor

Choose a reason for hiding this comment

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

alright, thanks for making it clear, what do you think about the replaceState() in case isValidMyJetpackSection() === false?

Copy link
Member Author

Choose a reason for hiding this comment

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

It already happens, the URL is reflected immediately on mount. We don't need to perform any magic here.

Screen.Recording.2025-05-26.at.6.58.05.PM.mov

Copy link
Contributor

@robertsreberski robertsreberski left a comment

Choose a reason for hiding this comment

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

Thanks, that is ready to be a base for all other PRs!

@manzoorwanijk manzoorwanijk merged commit 49b56b1 into feature/my-jetpack/onboarding-i3 May 26, 2025
52 checks passed
@manzoorwanijk manzoorwanijk deleted the add/my-jetpack/onboarding-i3-basic-tab-panel branch May 26, 2025 13:36
@github-actions github-actions bot removed the [Status] Needs Team Review Obsolete. Use Needs Review instead. label May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement [Package] My Jetpack [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants