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

Move the reusable blocks buttons to the editor module #14387

Merged
merged 5 commits into from
Mar 26, 2019

Conversation

youknowriad
Copy link
Contributor

Related #14043

This PR moves the reusable blocks related components (buttons) to the editor module. It leverages the fact that we can extend the block settings menu using a slot.

It also includes a new selector getSelectedBlockClientIds which was needed in a few other places too (it fixes some rerenderings as we were regenerating a new array in several withSelect callbakcs)

The main goal of this PR is to avoid relying on core/editor in the block editor module. We still have three remaining usage of this store there that should be handled in separate PRs.

Testing instructions

  • Check that the reusable blocks "convertion", "removal"... work as expected.

@youknowriad youknowriad changed the title This PR moves the reusable blocks buttons to the editor module Move the reusable blocks buttons to the editor module Mar 14, 2019
@youknowriad youknowriad self-assigned this Mar 19, 2019
@youknowriad youknowriad force-pushed the update/move-reusable-block-buttons-to-editor branch from f35ad70 to e28c708 Compare March 19, 2019 08:42
packages/block-editor/src/store/selectors.js Outdated Show resolved Hide resolved
packages/block-editor/src/store/selectors.js Show resolved Hide resolved
packages/block-editor/src/store/selectors.js Outdated Show resolved Hide resolved
packages/block-editor/src/store/selectors.js Show resolved Hide resolved
<_BlockSettingsMenuPluginsExtension.Slot fillProps={ { clientIds, onClose } } />
<div className="editor-block-settings-menu__separator block-editor-block-settings-menu__separator" />
{ count === 1 && (
Copy link
Member

Choose a reason for hiding this comment

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

I guess with this change, "Remove from Reusable Blocks" is moved to before the horizontal line in the menu, ungrouped from Remove Block. I don't see it being much an issue (grouped with reusable convert button vs. grouped with remove block button), but worth pointing out.

Before After
Before After

*
* @param {Object} state Editor state.
*
* @return {Array} Multi-selected block client IDs.
*/
export const getMultiSelectedBlockClientIds = createSelector(
export const getSelectedBlockClientIds = createSelector(
Copy link
Member

Choose a reason for hiding this comment

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

Could do for some separate unit tests to distinguish the two functions.

Aside: This selector function confuses me as to what its doing with the slices and root traversal below.

@aduth aduth added [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Package] Editor /packages/editor [Package] Block editor /packages/block-editor labels Mar 25, 2019
@aduth
Copy link
Member

aduth commented Mar 25, 2019

Needs a rebase.

Might be fair to add "Performance" label, if you think it qualifies to help for future filtering reference.

@youknowriad youknowriad added the [Type] Performance Related to performance efforts label Mar 26, 2019
@youknowriad youknowriad force-pushed the update/move-reusable-block-buttons-to-editor branch from d6bfd8c to 1ffcefc Compare March 26, 2019 08:09
@youknowriad youknowriad merged commit 59e56dc into master Mar 26, 2019
@youknowriad youknowriad deleted the update/move-reusable-block-buttons-to-editor branch March 26, 2019 08:22
@youknowriad youknowriad added this to the 5.4 (Gutenberg) milestone Mar 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Package] Block editor /packages/block-editor [Package] Editor /packages/editor [Type] Performance Related to performance efforts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants