Problem/Motivation
Everytime the relevant entity type for a Gutenberg enabled entity is save, it automatically adds in new changes in the config for every new block instance it finds, which can be annoying if you have loads of derivative fields e.g. block content blocks.
Steps to reproduce
Enable Gutenberg on your Node entity type, save then export the configuration.
Then introduce a new block type instance, e.g. an exposed filter block or a new content block.
Then once you resave the Node entity type, it'll automatically add those new block instances into the config like this in your config diff:
+ 'block_content:f5c762e6-962a-42cf-841b-611e5ee40204': 0
+ 'block_content:ced96c38-d1a0-4d34-ba1f-946de1291938': 0
+ 'block_content:b5bfb9e5-8a8f-4db3-a343-7e3d8522feb6': 0
+ 'block_content:59437793-d207-4182-bf96-52fa8c04755a': 0
Proposed resolution
Remove irrelevant config on save, as well as a post update hook to clean up the existing config.
We should ideally store these inside the individual Node entity's third_party_settings, that way it can be modelled consistently in the config schema, just like it was previously done in #3163200: Make Gutenberg entity-type-agnostic, but that's work to be in a future major release since it's a big change to the current data structure.
Remaining tasks
Provide update hook and MR.
User interface changes
N/A
API changes
N/A
Data model changes
Inactive blocks will no longer be exported in the config.
Issue fork gutenberg-3415218
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3415218-clean-up-gutenberg.settings-2.x-dev
changes, plain diff MR !206
- 3415218-clean-up-gutenberg.settings-3.x-dev
changes, plain diff MR !215
- 3415218-clean-up-gutenberg.settings-2.8
compare
- 3415218-clean-up-gutenberg.settings-2.x
compare
- 3.0.x
compare
- 8.x-2.x
compare
- 3415218-clean-up-gutenberg.settings
changes, plain diff MR !104 /
changes, plain diff MR !95
- revert-4bbb6c98
changes, plain diff MR !96
- revert-93c85c9e
compare
Comments
Comment #2
codebymikey commentedPushed an update normalizing the config, providing an update hook to apply it, as well as removing the redundant
gutenberg.mediaeditconfig.The current and new configuration schema can be reviewed using the https://www.drupal.org/project/config_inspector
Comment #5
marcofernandes commentedHmm.. something went wrong when merging dev. It updated from 2.x. I'll try to revert and do things properly.
Comment #9
marcofernandes commentedThis change affects the way the editor loads the configuration to register the blocks. Ex: /js/overrides/register-core-blocks.jsx
Comment #15
marcofernandes commentedBecause of these changes on the config structure, UpdateAddMediaTest::testMediaUpdate() had to be disabled for now. Follow-up on https://www.drupal.org/project/gutenberg/issues/3418917
Comment #20
codebymikey commentedReopened to address some config normalization issues related to the #3340209: Limit available image styles for image related blocks feature which was added, but doesn't currently have a valid schema.
Comment #27
codebymikey commentedIn the spirit of making the image size support more complete, I've added a commit to the merge request which incorporates changes from #3229848: Allow API to restrict which image styles are available to users and #3341296: Followup: SVG's should not use image styles
Comment #33
codebymikey commentedMerged both the 2.0.x and 3.0.x MRs.