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

[Patterns]: Support the blockTypes prop for patterns fetched from Pattern Directory #47677

Merged
merged 3 commits into from
Feb 2, 2023

Conversation

ntsekouras
Copy link
Contributor

@ntsekouras ntsekouras commented Feb 2, 2023

What?

This PR adds support for the blockTypes prop
The changes here are from this PR: #32113 and is just here to move things faster in order to land this for 6.2.

props @ryelle 🙇

Without this change, the patterns fetched from Pattern Directory wouldn't use this prop when they were registered. This become more obvious with this issue for adding more Query Loop patterns and it affects the header, footer patterns that are now fetched from Pattern Directory here: #46017

Also noting that the added patterns from #46017, seem to still don't have the blockTypes prop in PD and they would need to be updated to include this.

Before

Screen.Recording.2023-02-02.at.11.35.59.AM.mov

After

Screen.Recording.2023-02-02.at.11.36.55.AM.mov

Testing Instructions

  1. Insert a Heading block
  2. Open the block switcher menu
  3. Observe that there is a pattern suggested, coming from Pattern Directory

@ntsekouras ntsekouras added [Type] Bug An existing feature does not function as intended [Priority] High Used to indicate top priority items that need quick attention Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Feature] Pattern Directory The Pattern Directory, a place to find patterns labels Feb 2, 2023
@ntsekouras ntsekouras self-assigned this Feb 2, 2023
@github-actions
Copy link

github-actions bot commented Feb 2, 2023

Flaky tests detected in 3e2d823.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4073154985
📝 Reported issues:

Copy link
Contributor

@carolinan carolinan left a comment

Choose a reason for hiding this comment

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

The feature with the transform works well.
I am unable to review the test.

In gutenberg_load_remote_block_patterns the viewport_width setting seems unrelated to enabling block types -but I don't see a reason to remove it if it speeds things up.

@ntsekouras
Copy link
Contributor Author

In gutenberg_load_remote_block_patterns the viewport_width setting seems unrelated to enabling block types -but I don't see a reason to remove it if it speeds things up.

Yes, it is, but it was caught from @ryelle and I think it's land this too.

unset( $settings['block_types'] );
}

if ( isset( $settings['viewport_width'] ) ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This setting is not directly related to the main block_types change, but it's okay fix this too.

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

I left a few minor notes, but the fix works as expected. PHPUnit tests are passing locally as well ✅

lib/compat/wordpress-6.2/block-patterns.php Outdated Show resolved Hide resolved
lib/compat/wordpress-6.2/rest-api.php Show resolved Hide resolved
@ntsekouras ntsekouras force-pushed the add/block-types-prop-pattern-directory-controller branch from 9ffb359 to 06f6b16 Compare February 2, 2023 11:38
@Mamaduka
Copy link
Member

Mamaduka commented Feb 2, 2023

Thank you, Nik. Updates look good 🚢

@ntsekouras ntsekouras merged commit 54a5890 into trunk Feb 2, 2023
@ntsekouras ntsekouras deleted the add/block-types-prop-pattern-directory-controller branch February 2, 2023 13:29
@github-actions github-actions bot added this to the Gutenberg 15.2 milestone Feb 2, 2023
@Mamaduka Mamaduka added the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Feb 3, 2023
@ntsekouras ntsekouras removed the [Priority] High Used to indicate top priority items that need quick attention label Feb 3, 2023
Mamaduka pushed a commit that referenced this pull request Feb 3, 2023
…attern Directory (#47677)

* [Patterns]: Support the `blockTypes` prop for patterns fetched from Pattern Directory

* update all remote calls

* get registry once
@Mamaduka
Copy link
Member

Mamaduka commented Feb 3, 2023

I just cherry-picked this PR to the release/15.1 branch to get it included in the next release: f0c0581

@Mamaduka Mamaduka removed Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Pattern Directory The Pattern Directory, a place to find patterns [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants