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

Dotcom Patterns: Hide categories that start with an underscore #36763

Merged
merged 3 commits into from
Apr 10, 2024

Conversation

miksansegundo
Copy link
Contributor

@miksansegundo miksansegundo commented Apr 5, 2024

Fixes https://github.com/Automattic/dotcom-forge/issues/6073

Proposed changes:

  • Hide Dotcom categories that start with an underscore (in their slug not their title)
  • Clean some used code

Note

We are hiding the category, not the patterns in it.

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:

  • This PR does not introduce any visual changes. We still don't have any hidden categories.
  • Go to the editor to verify the categories have not changed in
    • the patterns inserter [+]
    • the patterns page
Screenshot 2567-04-05 at 20 23 59 Screenshot 2567-04-05 at 20 23 10

@miksansegundo miksansegundo requested review from fredrikekelund and a team April 5, 2024 18:25
@miksansegundo miksansegundo self-assigned this Apr 5, 2024
@miksansegundo miksansegundo added the [Status] Needs Team Review Obsolete. Use Needs Review instead. label Apr 5, 2024
Copy link
Contributor

github-actions bot commented Apr 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.


Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Mu Wpcom plugin:

  • Next scheduled release: May 7, 2024.
  • Scheduled code freeze: April 29, 2024.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link
Contributor

github-actions bot commented Apr 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 add/hidden-categories-with-underscore-prefix 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 add/hidden-categories-with-underscore-prefix
    

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

}
}

// Unregister existing categories so that we can insert them in the desired order (alphabetically).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't control the order of categories. That's controlled by the editor. See Automattic/wp-calypso#77130 (comment).

Copy link
Contributor

Choose a reason for hiding this comment

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

This is new territory for me, so forgive me if I ask silly questions, but why doesn't this affect the order of categories in the Assembler?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because in Assembler we force the order here

foreach ( $pattern_categories as $slug => &$category_properties ) {
// Rename category labels.
if ( 'posts' === $slug ) {
$category_properties['label'] = __(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need this anymore because we overwrite the existing categories with Dotcom categories.

);

// Move the Featured category to be the first category.
if ( isset( $pattern_categories['featured'] ) ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The featured category will be moved to the top in WordPress/gutenberg#60210. For now, we cannot control that ordering.

@github-actions github-actions bot added the [Plugin] mu wpcom jetpack-mu-wpcom plugin label Apr 5, 2024
@miksansegundo
Copy link
Contributor Author

I think the following test is failing because this PR removes the categories' alphabetical order.

I have raised a diff to make that test independent of the categories' order because the API should return them in the order they were registered. See D144551-code

Screenshot 2567-04-05 at 21 10 59

arthur791004
arthur791004 previously approved these changes Apr 9, 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.

Looks good to me!

@miksansegundo miksansegundo force-pushed the add/hidden-categories-with-underscore-prefix branch from 6ec0390 to ef7b698 Compare April 10, 2024 10:45
Copy link
Contributor

@fredrikekelund fredrikekelund left a comment

Choose a reason for hiding this comment

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

Apologies that it took me a minute to get through this review, @miksansegundo. Jetpack testing is new to me.

  • I was able to test these changes on a simple site. I didn't manage to do it on Atomic, but the changes are so small that I don't think I need to go through the hoops required to do that testing.
  • I verified that the Assembler looks the same, as well as the pattern inserter flyout panel in the block editor.
  • The API endpoint now returns patterns in a different order than before. I take it this is expected, @miksansegundo? We are essentially saying that all API consumers will need to handle ordering themselves, right?

As I noted in https://github.com/Automattic/dotcom-forge/issues/6073, we'll need to update the /ptk/categories endpoint separately to implement the corresponding changes for the pattern library.

@miksansegundo
Copy link
Contributor Author

The API endpoint now returns patterns in a different order than before. I take it this is expected, @miksansegundo? We are essentially saying that all API consumers will need to handle ordering themselves, right?

That's right. Patterns and categories are going to be returned in the order they are registered, and API consumers have the responsibility to change that, as the editor does it here.

@miksansegundo miksansegundo merged commit a494b6c into trunk Apr 10, 2024
54 checks passed
@miksansegundo miksansegundo deleted the add/hidden-categories-with-underscore-prefix branch April 10, 2024 10:58
@github-actions github-actions bot removed the [Status] Needs Team Review Obsolete. Use Needs Review instead. label Apr 10, 2024
TimBroddin pushed a commit that referenced this pull request Apr 10, 2024
* Hide Dotcom categories that start with underscore

* changelog

* Fix version
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.

3 participants