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

Refactor beta blocks registration #32815

Merged
merged 42 commits into from
Sep 14, 2023
Merged

Conversation

monsieur-z
Copy link
Contributor

@monsieur-z monsieur-z commented Sep 1, 2023

See #32602

Proposed changes:

Registers the beta blocks (AI Chat, Amazon, Blogroll, Google Docs Embed, Recipe, Create with Voice) by specifying the path to their block.json file. This was made possible by #32697. The goal is to avoid the duplication of block metadata and use block.json as the source of truth.

In more details:

  • Update registerJetpackBlockFromMetadata to redeclare variations icons on the client.
  • Add helper to get a block's name and feature name.
  • For each block (when needed):
    • Write reading direction-agnostic CSS
    • Remove the editorScript property from block.json (automatically added during the build)
    • Convert icon from dashicon to SVG in the icon property of block.json
    • Remove icon.js
    • Import icon helpers from the shared-extension-utils package
    • Register the block client and server sides with block.json
    • Move data from index.js to block.json and editor.js and delete the file
    • Move data from attributes.js to block.json and delete the file
    • Fix JS tests

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

pedMtX-RS-p2

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

No.

Testing instructions:

  • Enable beta blocks in the Jetpack constants section if you're using a JN site, or by adding define( 'JETPACK_BLOCKS_VARIATION', 'beta' ); to your wp-config.php otherwise.
  • Test that the blocks behave as in trunk (some newer ones, such as Blogroll, might not be functional yet). This PR shouldn't change anything from a user's standpoint.

A couple of notes:

  • Blocks metadata don't seem to be localized in production.
  • Blogroll seems to be often updated at the moment. The icons, for instance, don't currently match. I'll make sure to fix that in a subsequent PR.
  • I've removed the links from the Recipe description. It didn't lead to anything and I couldn't find a relevant page to link to.
Screenshot 2023-09-11 at 1 15 21 PM

@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2023

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 > Jetpack and enable the refactor/beta-blocks-registration branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack refactor/beta-blocks-registration
    

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

@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2023

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.
  • ⚠️ All commits were linted before commit.
  • ✅ 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 (other than "Required review") 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.


Jetpack plugin:

  • Next scheduled release: October 3, 2023.
  • Scheduled code freeze: September 25, 2023.

@monsieur-z monsieur-z force-pushed the refactor/business-hours-block-regsitration branch 16 times, most recently from cbf833a to 8a05697 Compare September 7, 2023 18:33
@monsieur-z monsieur-z force-pushed the refactor/beta-blocks-registration branch from 79e58f0 to d86c784 Compare September 7, 2023 21:19
@monsieur-z monsieur-z force-pushed the refactor/beta-blocks-registration branch from ff71727 to b058f18 Compare September 7, 2023 21:31
@monsieur-z monsieur-z force-pushed the refactor/beta-blocks-registration branch from 615d323 to 133828b Compare September 14, 2023 12:08
@monsieur-z monsieur-z merged commit 273fb4c into trunk Sep 14, 2023
50 of 51 checks passed
@monsieur-z monsieur-z deleted the refactor/beta-blocks-registration branch September 14, 2023 12:35
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Sep 14, 2023
mikestottuk pushed a commit that referenced this pull request Sep 18, 2023
* [not verified] Enable block registration by specifying block.json path

* [not verified] Add test for registering block by its metadata file

* [not verified] Fix failing test

* [not verified] Refactor: register business hours block with block.json path

* [not verified] Move logic to render a block icon on the client

* [not verified] Remove deprecated file

* [not verified] Pass package build dir to get_path_to_block_metadata

* [not verified] Move block icon helpers to shared-extension-utils package

* [not verified] Add missing color-studio dependency to shared-extension-utils

* [not verified] Add missing jetpack-constants dep to blocks package

* [not verified] Fix monorepo package version refs

* [not verified] Remove color studio dep in shared-extensions-util

* [not verified] Bump yoast/phpunit-polyfills version in blocks package

* [not verified] Remove unhelpful changelogs

* [not verified] Add missing color-studio dependency to shared-extension-utils

* [not verified] Add tests for blocks helpers functions

* [not verified] Refactor Amazon block registration

* [not verified] Refactor AI Chat block registration

* [not verified] Refactor Blogroll block registration

* [not verified] Refactor Recipe block registration

* [not verified] Refactor Create with Voice block registration

* [not verified] Fix missing imports in Recipe child blocks

* [not verified] Refactor Docs blocks registration

* [not verified] Fix Amazon icon

* [not verified] Use CSS logical properties for i18n

* [not verified] Fix Recipe block not correctly displayed in inserter

* [not verified] Fix Amazon icon alignment

* [not verified] Fix rebasing error

* [not verified] Update path passed to jetpack_register_block

* [not verified] Import icon helpers from shared-extension-utils package

* [not verified] Update path passed to jetpack_register_block

* [not verified] Add changelog

* [not verified] Fix failing JS test

* [not verified] Add helper to get block's feature name

* [not verified] Add changelog

* [not verified] Remove color studio dep

* [not verified] Add helper to get a block's name

* [not verified] Remove deprecated CSS

* [not verified] Add missing Blocks::get_block_feature call

* [not verified] Remove unnecessary export

* [not verified] Fix Google embeds previews

* Revert composer.lock
@monsieur-z monsieur-z mentioned this pull request Oct 11, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants