Overview
If the user cannot edit config (asset library, code components) the preview does not render. That is because the preview gets those config from auto-save which requires `edit` permission. The GET routes should use `.view`.
Proposed resolution
Example of our fix
$collection->get('experience_builder.api.config.auto-save.get.js')
?->setRequirement('_entity_access', 'xb_config_entity.view');
$collection->get('experience_builder.api.config.auto-save.get.css')
?->setRequirement('_entity_access', 'xb_config_entity.view');
User interface changes
Issue fork experience_builder-3533461
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:
Comments
Comment #2
effulgentsia commented"view" as the entity operation makes sense, but I think if we do that, we need to also make sure that the access handler uses a permission like "view unpublished" or "view latest version" (see Content Moderation for reference) if the entity is the one that's in auto-save.
Comment #3
mglamanThe problematic entities were config entities which don't support revisions. Not the actual entity being edited itself. I don't know if this effects regular conponen config for SDCs
Comment #4
mglamanFlagging for tests. There must be existing tests that have missing coverage.
Comment #5
wim leersThis title is very misleading 😅😬
This was introduced in #3500386: Code Components should render with their auto-saved state (if any) when rendered in the XB UI.
So I went to investigate how we agreed this was supposed to work: when should code components load their auto-saved vs live CSS+JS code? 🕵️
I wrote ~4 months ago at #3500386-35: Code Components should render with their auto-saved state (if any) when rendered in the XB UI:
Which @effulgentsia disagreed with at #3500386-38: Code Components should render with their auto-saved state (if any) when rendered in the XB UI:
The underline (added by me) is what #3529924: Add access check for using Experience Builder at all: if >=1 content entity type with an XB field can be created or edited. is about to land! 🥳
We then agreed at #3500386-39: Code Components should render with their auto-saved state (if any) when rendered in the XB UI to do this in #3508694: Permissions for XB config entity types, but we never did — or rather: in #3508694 we did change the route requirement for the routes discussed here like so:
So … once #3529924: Add access check for using Experience Builder at all: if >=1 content entity type with an XB field can be created or edited. lands, this should become trivial to support :)
Comment #6
lauriiiComment #7
wim leersPushed solution. Test coverage should be trivial to add in
\Drupal\Tests\experience_builder\Functional\AssetLibraryAttachmentTest::test().Note that the MR will fail until #3529924: Add access check for using Experience Builder at all: if >=1 content entity type with an XB field can be created or edited.'s lands.
Comment #9
wim leers#3529924: Add access check for using Experience Builder at all: if >=1 content entity type with an XB field can be created or edited. just landed 🥳
Comment #10
thoward216 commentedComment #11
wim leersTest-only CI job failed 👍
Reviewing in-depth…
Comment #12
wim leersSee https://git.drupalcode.org/project/experience_builder/-/merge_requests/1... — now you can review to see if it all makes (hopefully MUCH) more sense? 🤞
Comment #14
wim leers