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: register business hours block with block.json path #32698

Merged
merged 30 commits into from
Sep 14, 2023

Conversation

monsieur-z
Copy link
Contributor

@monsieur-z monsieur-z commented Aug 25, 2023

See #32602

Proposed changes:

Registers the Business Hours block by specifying the path to its 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:

  • Server side
    • Add a helper method to get the path to a block's metadata file (in the build folder)
    • Add tests
    • Register the block by specifying the path to block.json
  • Client side
    • Remove editorScript from block.json file (automatically added during the build)
    • Move metadata from index.js to block.json
    • Delete index.js
    • Create a function that reads the icon from the metadata and generates a React component, in shared-extension-utils
    • Create a helper to register blocks by passing the metadata object
    • Register the block by passing the metadata
    • Write i18n-friendly CSS
    • Update block 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:

Test that the Business Hours block behaves as in production.

Screenshot 2023-09-13 at 3 50 35 PM

Note: blocks metadata don't seem to be localized at the moment in production.

@monsieur-z monsieur-z changed the base branch from trunk to add/enable-block-registration-by-path August 25, 2023 20:16
@github-actions
Copy link
Contributor

github-actions bot commented Aug 25, 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/business-hours-block-regsitration branch.

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

    bin/jetpack-downloader test jetpack refactor/business-hours-block-regsitration
    

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 github-actions bot added [Block] Business Hours [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress labels Aug 25, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 25, 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 requested a review from a team August 25, 2023 20:40
@monsieur-z monsieur-z self-assigned this Aug 25, 2023
@monsieur-z monsieur-z marked this pull request as ready for review August 25, 2023 20:41
@monsieur-z monsieur-z force-pushed the add/enable-block-registration-by-path branch from 2d37e5e to 61f2abf Compare August 28, 2023 17:55
@monsieur-z monsieur-z force-pushed the refactor/business-hours-block-regsitration branch from 21784c9 to b6c3022 Compare August 28, 2023 18:22
@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Aug 28, 2023
@monsieur-z monsieur-z force-pushed the add/enable-block-registration-by-path branch from 861d7ba to bfcfea7 Compare August 29, 2023 22:11
@monsieur-z monsieur-z force-pushed the refactor/business-hours-block-regsitration branch from 5f5bc9f to fb2e82e Compare August 30, 2023 17:37
@monsieur-z monsieur-z force-pushed the add/enable-block-registration-by-path branch from bfcfea7 to 100c54d Compare August 31, 2023 17:07
@monsieur-z monsieur-z force-pushed the refactor/business-hours-block-regsitration branch from ffc5868 to 3e88fae Compare August 31, 2023 17:30
@monsieur-z monsieur-z removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Aug 31, 2023
@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Aug 31, 2023
@monsieur-z monsieur-z force-pushed the refactor/business-hours-block-regsitration branch from 7b0f5c3 to da6a8e0 Compare September 13, 2023 18:57
Copy link
Contributor

@fgiannar fgiannar left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, Kevin!

I tested this as follows:

  1. Added a business hours block on latest stable
  2. Made a few changes and switched to the current branch
  3. Confirmed the block is there and my changes persisted
  4. Added a new business hours block and confirmed it behaves as expected
  5. Confirmed no related errors in console

The only thing I found confusing (though doesn't look related to your changes) is that when editing the block the hours seem to be in my timezone but in view mode they appear in UTC
Screenshot 2023-09-14 at 10 32 08

Screenshot 2023-09-14 at 10 32 18

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Let's give this a try! 🚢

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Team Review labels Sep 14, 2023
@monsieur-z monsieur-z merged commit 8a706d0 into trunk Sep 14, 2023
65 checks passed
@monsieur-z monsieur-z deleted the refactor/business-hours-block-regsitration branch September 14, 2023 11:55
@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
…n path (#32698)

* [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] Make block CSS right-to-left compatible

* [not verified] Remove hardcoded editorScript value in business hours block.json

* [not verified] Move code to get block metadata path in Blocks

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

* [not verified] Remove deprecated file

* [not verified] Add changelogs

* [not verified] Fix failing JS test

* [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] changelog

* [not verified] Add missing import

* [not verified] Update package version

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

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

* [not verified] Remove call to realpath from get_block_metadata_from_file

* [not verified] Fix monorepo package version refs

* [not verified] Pass path to source block.json to jetpack_register_block

* [not verified] Fix wrong getIconColor import

* [not verified] Falls back to reading block.json in source directory

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

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

* [not verified] Update composer.lock in Jetpack plugin

* [not verified] Remove unhelpful changelogs

* [not verified] Add fallback logic to get_path_to_block_metadata

* Update package version

* Fix styling issues caused by span in getBlockIconComponent
@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.

3 participants