-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Make BlockManager
component reusable
#67052
base: trunk
Are you sure you want to change the base?
Conversation
Size Change: +58 B (0%) Total Size: 1.82 MB
ℹ️ View Unchanged
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any comment on the master plan, but this PR makes sense and there are no regressions between trunk and this PR when toggling visibility of blocks in the preferences pane 👍🏻
LGTM so far
*/ | ||
export default function BlockManager( { | ||
blockTypes, | ||
selectedBlockTypes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see any errors so it might be a small thing, but I'm wondering that, if this is going to be a shared component, do you think any data validation is appropriate?
If selectedBlockTypes
isn't an array, a bunch of stuff would break.
Part of #62703 (comment)
What?
This PR makes the
BlockManager
component reusable in preparation for building a UI for the allowedBlocks setting.Why?
The current
BlockManager
component is tightly coupled to theshowBlockTypes
andhideBlockTypes
actions and cannot be used for other purposes.How?
Change the
BlockManager
component to receive the following three props.blockTypes
: A list of blocks to display.selectedBlockTypes
: A list of currently selected blocks.onChange
: Called when the selected block is changed.Next, I reconstructed the current "Manage block visibility" settings as a
BlockVisibility
component that wraps theBlockManager
component. TheBlockVisibility
component controls the available blocks using theshowBlockTypes
andhideBlockTypes
via theonChange
prop of theBlockManager
component.Testing Instructions
The "Manage block visibility" setting should continue to work as before. Most of the functionality should be guaranteed by this E2E test.