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

When the core/buttons block is registered, migrate from the coblocks/buttons block #1241

Merged
merged 7 commits into from
Jan 22, 2020

Conversation

AnthonyLedesma
Copy link
Member

@AnthonyLedesma AnthonyLedesma commented Jan 8, 2020

Closes #1235
With the release of Gutenberg 7.2 a new buttons block has been introduced. The new core/buttons block seems to have conflicts with the coblocks/buttons block as shown in this screenshot.

Before
image

This PR adds logic to automatically convert the CoBlocks Buttons block to the Core Buttons block if available.

After
image

@AnthonyLedesma AnthonyLedesma added [Type] Bug Something that is not working as expected [Block] Buttons labels Jan 8, 2020
@AnthonyLedesma AnthonyLedesma self-assigned this Jan 8, 2020
Copy link
Contributor

@mmtr mmtr left a comment

Choose a reason for hiding this comment

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

This is looking good!

I wonder if it'd be good to make the CoBlocks Buttons block non-insertable, so users don't get confused about having 2 blocks with the same name on the inserter.

Gutenberg supports a inserter option in the supports block settings that can be used to prevent the block from being inserted while maintaining support for existing posts containing it.

src/blocks/buttons/edit.js Outdated Show resolved Hide resolved
src/blocks/buttons/edit.js Outdated Show resolved Hide resolved
@jrtashjian jrtashjian added this to the Next Release milestone Jan 10, 2020
@mmtr
Copy link
Contributor

mmtr commented Jan 16, 2020

Seems this is not converting the Hero's Buttons child block. Likely because the new core/buttons block is not allowed:

const ALLOWED_BLOCKS = [ 'core/heading', 'core/paragraph', 'core/spacer', 'core/button', 'core/list', 'core/image', 'coblocks/alert', 'coblocks/gif', 'coblocks/social', 'coblocks/row', 'coblocks/column', 'coblocks/buttons' ];

Copy link
Member

@jrtashjian jrtashjian left a comment

Choose a reason for hiding this comment

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

This is working well!

It would be nice to figure out a way to auto-transform our blocks into the Core versions so that we could minimize the amount of code left behind. But for this block we actually still need to keep this code around since the core/buttons block is not merged into WordPress Core yet.

This is a great method of deprecating our blocks to prefer the core versions and I'm looking forward to improving on this over time. Great work @AnthonyLedesma!

@jrtashjian jrtashjian changed the title Allow Buttons block to convert to core/buttons block When the core/buttons block is registered, migrate uses of the coblocks/buttons block to it Jan 22, 2020
@jrtashjian jrtashjian changed the title When the core/buttons block is registered, migrate uses of the coblocks/buttons block to it When the core/buttons block is registered, migrate from the coblocks/buttons Jan 22, 2020
@jrtashjian jrtashjian changed the title When the core/buttons block is registered, migrate from the coblocks/buttons When the core/buttons block is registered, migrate from the coblocks/buttons block Jan 22, 2020
@jrtashjian jrtashjian merged commit 3b2073e into master Jan 22, 2020
@jrtashjian jrtashjian deleted the buttons-deprecation-gb branch January 22, 2020 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug Something that is not working as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ISNBAT use the CoBlocks buttons block in Gutenberg 7.2.0
4 participants