Closed (fixed)
Project:
Drupal core
Version:
8.8.x-dev
Component:
layout_builder.module
Priority:
Normal
Category:
Plan
Assigned:
Unassigned
Reporter:
Created:
16 May 2018 at 17:51 UTC
Updated:
25 Mar 2019 at 14:49 UTC
Jump to comment: Most recent
Comments
Comment #2
johnwebdev commentedComment #3
johnwebdev commentedWhen using Content Moderation revisions are required on entities and a new revision must be created when the entity is updated.
This could imply that override layout probably should have the same behaviour when used together with Content Moderation.
You can configure a workflow and its transitions to not allow it to transition to its current state.
For example, the Editoral workflow 'Archived' state must be transitioned to either Draft or Published.
To solve that, the Layout Builder layout override must then allow the user to choose a given state to be transitioned to?
What are the implications of bypassing this behaviour?
Comment #4
johnwebdev commentedSo me and @tedbow had a chat about Content Moderation
Currently
\Drupal\content_moderation\Entity\Handler\ModerationHandler::onPresavemakes sure that a new revision is created when saving the moderated entity.Some ideas we talked about:
$entity->validate()when saving layout, then if the transiton is not correct we would get an error and not save$entity->validate()on the layout override page.So if the entity moderation state is not correct, it could have a message like something like "The entity is not in a proper state to have its layout saved"
however @tedbow added to this:
it is kind of weird to call
$entity->validate()when you are not about to save. like what if some of the custom `presave` hooks are in charge of massaging the data so it validates. then these would not be fired so it wouldn’t validateComment #5
berdir> it is kind of weird to call $entity->validate() when you are not about to save. like what if some of the custom `presave` hooks are in charge of massaging the data so it validates. then these would not be fired so it wouldn’t validate
There is no such thing. Validate is *not* in any way tied to saving. presave can *not* affect the result of validate(). validate() must be called manually before calling save(), presave is part of save(). In fact, it is easily possible in presave() to to things that would fail validation.
Comment #6
tedbow#5 @Berdir thanks for the clarification.
I guess my point was calling
$entity->validate()when you are not about to save.what @johndevman and I talked about in regards to
Is that while
does prevent the user from saving an invalid transition state or other violations the user would not know this when they get the layout override page.
They could do a lot work layout and then when they clicked "Save layout" they would be told the transition is not valid or other violations.
One way to avoid this situation would be to call
$entity->validate()when the layout override form is being presented to the user.Then could filter out any violations for the
layout_builder__layoutfield and then present any other violations to the user so they don't start changing the layout.The problem I see with this is that a lot could happen between when we first present the layout override page and calling
$entity->validate()right before save. even between clicking "save layout" and$entity->validate(). or event changes tolayout_builder__layoutmight be the thing that would cause the violations to go away.Comment #7
berdirI have to say I have not actually used the layout builder yet, so I don't really know how the UI works.
That said, how is this any worse than editing any other field? I can go to the edit form of a node, work on it for an hour and then I get a validation error on save that someone already saved that node?
The normal edit form limits validation errors that actually prevent saving to the fields that are being displayed and are accessible to the user. I guess this could do the same, or as you said, specifically track the validation errors that already exist before and only allow to save if there are new errors due to the changes.
Comment #8
timmillwoodAfter finding out from @tim.plunkett that entity specific layout overrides are stored in a field on the entity, I don't think there will be any issues.
Content Moderation example:
There would now be two revisions with different layout. The published revision is the default revision the user sees and the draft revision is the latest pending revision.
Workspace example
There would now be a version of the content in live, and a version in stage. Both are the same content, but have different layouts. This uses the default / pending revision system. The live workspace has the default revision, the stage workspace is loading the pending revision.
Comment #9
johnwebdev commented@timmillwood
Regarding Content Moderation I still think
is something we need to deal with. So if the entity is in Archived state, and you are saving the layout you are violating that transition constraint.
Comment #10
tedbowCreated a related issue #2973860: When there is an entity forward revision for Content Moderation and a layout override is saved the revision is no longer latest
From that issue
If we there is a forward revision I think there would be problems editing the layout.
$entity->save()on LatestRevision.Comment #12
tim.plunkettComment #13
sam152 commentedSorry to cross post this bit, but there are a bunch of issues related to layout builder and content moderation, so I'm not sure who has seen what. Content moderation part from #3004536: Move the Layout Builder UI into an entity form for better integration with other content authoring modules and core features:
Edit: rereading this issue more carefully, looks like @johndevman and I came to similar conclusions with:
Comment #14
sam152 commentedI've updated the issue proposal in #13 with a demo of layout builder and content moderation working together for anyone who is interested: https://www.youtube.com/watch?v=GT-bf_7o3cY.
Comment #15
amateescu commentedI think this is fixed by #2942675: Layout builder should use the active variant of an entity to avoid orphaned revisions and therefore it can be closed, right?
Comment #16
tim.plunkett#3032287: Add the content moderation state widget to the layout builder entity form. is the actual implementation issue for CM.
I'm not sure what's up with workspaces these days.
Comment #18
tim.plunkettThat implementation issue is in. Calling this done!