Problem/Motivation
Layout builder allows individual fieldable entities to be laid out on a per-entity basis, but we need a way to create entity layouts per view_mode.
Proposed resolution
Reuse the new layout builder UI on the "manage display" tab in field ui allowing for custom layouts and block placement to be supported as a default for entity rendering.
Remaining tasks
N/A
User interface changes
Radical changes to field ui's "manage display" section. We'd swap in the new layout builder once it's committed.
API changes
We expect this to be encapsulated in the 3rd party settings of the entity displays. To that end we don't yet foresee any API changes.
Data model changes
Additions in the form of 3rd party settings.
Comment | File | Size | Author |
---|---|---|---|
#105 | 2922033-defaults-105.patch | 138.58 KB | tim.plunkett |
#105 | 2922033-defaults-105-interdiff.txt | 854 bytes | tim.plunkett |
#99 | 2922033-defaults-99-interdiff.txt | 2.24 KB | tim.plunkett |
#99 | 2922033-defaults-99-PASS.patch | 138.59 KB | tim.plunkett |
#99 | 2922033-defaults-99-FAIL.patch | 138.51 KB | tim.plunkett |
Comments
Comment #2
tim.plunkettThis does not yet update the UI.
And this is already a big patch. Parts of it need to be split out into other blocking issues.
Work is being done here:
https://github.com/timplunkett/d8-layouts/commits/2922033-layout_defaults
f437e373b6 Move the core block plugin schema out of block module.
1ea595139f Use setComponent() within EntityDisplayBase::init() to allow subclasses to intercept all calls.
ff7ba837ee Rewrite Section's data model.
8fb7a0087b Refactor to use Section instead of arrays or LayoutSectionItem.
db0cfd9be5 Add LayoutBuilderEntityViewDisplay
0ea0d114fa Introduce LayoutEntity.
ef0e05d8b0 Use LayoutEntity
Comment #3
tim.plunkettMissed a spot, oops. Never make last minute changes *after* running tests.
Also attached is a patch made via format-patch, for easier reviewing.
Comment #5
tim.plunkettFiled #2925657: EntityDisplayBase::init() should use ::setComponent() for fields and #2925651: Config schema for \Drupal\Core\Block is wrongly in block.module as the two core blockers
Comment #6
larowlanWhile I can appreciate that this is a convenience, we're polluting our value object with the container. Given that these seem to be the only calling code for the ::getLayout method, and both ::getLayoutId and ::getLayoutSettings are public *and* this calling code already has/had the layout manager injected, should we leave the ::createInstance call to the calling code *or* should we add a parameter to ::getLayout for the layout plugin manager and make it the calling code's responsibility to either create the instance or pass along the manager. That would keep our value object pure.
we need a test for this
If there are no field layout settings should we
continue;
to the next versionshould these be @internal?
oh and another call here..
So in terms of breaking this up, I see two chunks
Progressing well, nice work
Comment #7
xjmWhat if someone has their own improved Field UI module?
Comment #8
EclipseGc CreditAttribution: EclipseGc at Acquia commentedSwapping out classes is a thing that can't be done by multiple modules really. In ctools, when we've done this, we've checked that the class we're swapping out is the class we expect it to be before we swap it. I'm not sure Core needs to do that, it seems like contrib should be aware of core's needs, not the other way around, but that's just my opinion.
Eclipse
Comment #9
tim.plunkett#6
1) You're right, of course. It's just so damn convenient. I'll work on this
2) I think we could stand for a more explicit test, but LayoutBuilderFieldLayoutCompatibilityTest does test this.
3) We still need the second half of this loop to run.
4) Not sure but probably
I agree with the chunks. I have them split like that in the branch.
#7
This is temporary. Before this issue is finished we need our own Form class, this was just to stop the Field Layout UI from fataling.
Comment #10
tim.plunkett#6.1
Section is not a value object, it's a domain object.
Domain objects contain business logic and are mutable. Amusingly enough, they are sometimes called "entities" in other systems.
I'm still amenable to some method of injecting the plugin manager, but I still didn't do that.
Additionally, we need the plugin manager for another part of the code that this class is absolutely responsible for, so we're going to have it anyway.
What I did do was cut down the usages of getLayoutId/getLayoutSettings to only 2 calls, the times when it is being stored. I also marked the methods @internal and explained when they should be used.
I've also removed setLayoutId/setLayoutSettings entirely. Finally, I moved the logic for switching a layout that was only in the defaults code before.
#6.2
I wrote \Drupal\Tests\layout_builder\Kernel\LayoutBuilderInstallTest
#6.3
While writing the above test and reexamining this code, I realized that we DON'T want to start with a default section. I've removed that from LayoutBuilderEntityViewDisplay and fixed this install code
#6.4
Made all of the classes @internal
#7
Added an explicit @todo.
I still have to split up this issue, working on that next
Comment #11
tim.plunkettSplit the first portion out:
#2926914: Rewrite \Drupal\layout_builder\Section to represent the entire section, not just the block info
Comment #12
tim.plunkettHere's a slimmed down version of what is next after that blocker issue.
Comment #13
tim.plunkettThis is now further postponed on #2927349: Decouple the Layout Builder UI from entities
Comment #14
tim.plunkettI have this split up as 3 commits locally:
The complete patch is all 3 of those.
The combined patch is all 3 of those plus #2927349: Decouple the Layout Builder UI from entities and #2671964: ContextHandler cannot validate constraints
Comment #15
tim.plunkettComment #16
tim.plunkettComment #17
larowlanone blocker left
Comment #18
larowlancould use a trait for this, there was similar code elsewhere?
nice
ick - anything we can do to avoid this?
internal for now?
We should be able to add kernel/unit tests for these?
Comment #19
tim.plunkett#18
1)
Because of slight differences between the two, I'd rather avoid trying to overgeneralize. Instead, I've linked to #66183: Add helper methods to inject items into a particular position in associative arrays, which should make this first part a one-liner eventually.
3)
I forgot I left this ugliness in. I've gone ahead and rewritten this.
4)
Yep!
5)
Sure!
The test for LayoutBuilderRoutes asserts the entire structure of each route.
It feels really prescriptive and possibly brittle, but it also revealed a problem in the logic already, so I guess it's worth it.
Wrote the tests for the others too.
Some of these additions need to be moved to #2927349: Decouple the Layout Builder UI from entities, working on that now
32348a8a54 Fix storage to not use reflection
f02d060c53 Point to NestedArray::insert() issue to eventually remove the array_slice/array_merge complexity.
f4aeaafd29 Mark OverridesSectionStorageInterface as @internal
3ed5589b17 Add test for LayoutBuilderRoutes
39e57a8092 Add test for LayoutTempstoreParamConverter.
590249fe4c Add test for SectionStorageDefaultsParamConverter.
a90e9889b5 Add test for SectionStorageOverridesParamConverter.
This is a patch with all 3 parts combined, the individual commits are on github for now
Comment #20
tim.plunkettRealized that this will fail tests until #2921626: Add proper context-awareness to Layout Builder happens.
Still technically postponed, but I want to see some test results.
Comment #22
tim.plunkett4d9b0e5d37 Add dependency on Field UI
bc8129417e Fix label of entity view display
e5ea4dd23a Redirect to Manage Display when done editing defaults.
229caff328 Handle fields that cannot be rendered when in preview.
05320e15fc Avoid collision on tempstore collection name
fc6e6b73fc Store the sample entity in the tempstore.
25223cb60a Move "Manage Layout" to the front end
702a68e166 Fix hook_install check
Still includes #2921626: Add proper context-awareness to Layout Builder, but that's now RTBC!
Comment #24
tim.plunkettFixing a couple things, and making defaults work for every view mode.
Comment #25
tim.plunkettBlocker is in!
Added in the revert functionality.
Comment #26
samuel.mortenson@tim.plunkett Doing some manual testing - if I enable the standard profile, layout builder, then visit
/admin/structure/types/manage/article/display-layout/default
and try to configure + save an existing block (like Image, for instance), I get a 500 error. Removing existing field blocks, adding new ones, and configuring them seems to work OK.Comment #27
tim.plunkettThere was some weirdness in the add/update flow, specifically around relying on the correct UUID persisting.
Which is precisely the exception you hit in #26.
This fixes that by generating/retrieving and then tracking the UUID throughout the form flow, instead of trying to find it at the end during submit.
Comment #28
samuel.mortensonPart 1 of review:
This kind of logic is good for migrating settings from existing displays, but new displays don't have their default fields (i.e. "Body") added into sections. I also noticed that when I add a new Content Type and go to configure its Entity Display layout, the "Content" category is missing until I rebuild cache! That should be addressed.
Are there cases where an Entity Type would want to "opt-out" of Layout Builder? I'm wondering if we should restrict the scope to known Entity Types, to prevent contrib headaches.
So
$delta
in the other insert/append/setSection methods is always numeric (and sequential), right? Just double checking becausearray_values
will discard any existing non-numeric keys.Maybe we should have a
hasSection
method, given the number of other related methods that are being added here?The key
layout_builder__layout
is hard-coded in a lot of places in layout_builder, should this be a constant or returned by a method?Why provide a default for the bundle key here? If there is not bundle entity type, we shouldn't add the bundle as a parameter.
We should do this logic for individual entities as well, since we're currently using serialization.
Comment #29
samuel.mortensonLast bit of review:
It seems like there's a lot of code in this patch that fills in values when an entity type is not bundle-able, is there any harm in omitting the bundle completely in that case?
Is there an issue for this?
Also, It looks like there's test coverage for the routing changes introduced by this issue, but not much for actually creating an Entity View Display default using Layout Builder and verifying that entities are displayed properly using that default.
Comment #30
tim.plunkett#28
1) Ughhhhh we're going to have to intercept calls to `setComponent()` and translate that into... something.
2) Can you open a follow-up to discuss this?
3) As of now, we expect them to be numeric, and sequential. This could be documented/codified/enforced better.
4) Where else would we use this? I'd rather avoid needlessly expanding the interface... Though it could also be on a trait.
5) It's in 3 places: This class, which owns the field. That class's corresponding ParamConverter. And a hook_form_alter.
We could constant-ify this, I did that in previous iterations. Just didn't seem important, since it's not something anyone else should be using.
If you feel like it'd be an improvement, please open a follow-up
6) We need this for the ParamConverter.
7) Is serializing an array any better or worse than serializing the object? I really don't know. Can you open a follow-up for this?
#29
1) Yep, and that's 100% due to the Field UI and EntityViewDisplays, specifically around the
field_ui_base_route
property on all entity types. We're inheriting that mess, and can't really touch it.2) We might consider removing this hack, and rewriting the accompanying test that proves that migrating from Field Layout to Layout Builder results in *identical markup*.
Needing code changes:
#28.1
#28.3
#29.2
Needing follow-ups:
#28.2
#28.4
#28.5
#28.7
Comment #31
samuel.mortensonFollow ups:
#28.2 - #2936358: Layout Builder should be opt-in per display (entity type/bundle/view mode)
#28.4 - After reviewing possible uses for a new method, a follow up is probably overkill.
#28.5 - #2936360: Remove duplicate references to the "layout_builder__layout" field from Layout Builder
#28.7 - This is covered by #2914503: Determine if serializing blobs is safe for use in Layout Builder
Comment #32
tim.plunkettAddressed #28.1, both parts.
Turns out I took care of the brittle test already, so #29.2 can be resolved. Thanks, past me!
For #28.3, I moved the array_values() call to the setter itself, and documented the behavior on the interface.
LayoutSectionItemList (overrides) already enforced this behavior.
To the best of my knowledge, all feedback is addressed in the patch or by follow-ups.
Comment #33
EclipseGc CreditAttribution: EclipseGc at Acquia commentedSo I want to revisit this post-beta and improve on it. Issue here: #2936501: Reverting an override redirects the user to an edit form for a new override and therefore still sets the new override as "unsaved changes", which is confusing I think I was "outvoted" on what we should do on revert, and I'm honestly "OK" with that, but it happened in chat, so surfacing it here.
As it stands, it totally functions and is ok, but going forward, we basically we have to ask ourselves what we think is a more common task, reverting a custom layout and promptly building a new custom layout based on the default, or simply reverting the custom layout. In the case of the latter, we should be going to the canonical url. In the case of the former, we should go to the layout builder url. I think the "revert and done" action will be the far more common action to perform.
Likewise, in the case of reverting and being done, the user has to click revert and THEN cancel. I know this because I understand what those buttons do. I suspect most end users will click "revert" and then click "save" which is actually the opposite of what we want them to do. NOT visiting /layout ui paths as a redirect from reverting would prevent this behavior entirely.
This looks really unnecessary at this point.
Hard-coding this seems wrong. I think we should probably have a $view_mode = 'default' in the method parameters.
"A sequentially"
Eclipse
Comment #34
tim.plunkettThanks for the review!
1) I think our decision here is appropriate for the first iteration, and yeah we now have that issue to discuss more.
2) This branch has existed locally for me for a loooong time, and this code was needed before the Section/SectionComponent rewrite. It is indeed no longer needed!
3) We currently only support overrides for the
default
, so this is okay for now.Opened #2936507: Determine how an override can identify its corresponding default, which is only relevant pending resolution of #2907413: Consider supporting Layout Builder Overrides for other view modes
4) Hah, nice catch.
Comment #35
EclipseGc CreditAttribution: EclipseGc at Acquia commentedRTBC pending passing tests.
Eclipse
Comment #38
EclipseGc CreditAttribution: EclipseGc at Acquia commentedTest bot being weird again, still rtbc.
Eclipse
Comment #39
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedI wonder if the Blocks-Layouts initiative has any plans to work on #1875974: Abstract 'component type' specific code out of EntityDisplay so it can integrate properly with the existing system :)
Comment #40
tim.plunkettI've been tracking that issue for about 5 years. I really hope to be able to help push it forward as a part of getting this module to become a full part of core.
Comment #41
larowlanDo we need an uninstall here or does the third-party settings api automatically remove these for us?
If we moved this to a protected method on the new LayoutBuilderEntityViewDisplay we could just call ->setComponent in the install hook, and we'd make sure no-one can ever call this code. Yes its prefixed with _, but enforced private API is better than naming conventions. Thoughts?
Forgive me if I missed it, but I don't see any functional tests for this form?
Is there a missing API here -
StorageType::supportsReverting
duck typing etc
Assigning to @xjm who indicated in #2927349-18: Decouple the Layout Builder UI from entities that she wanted the opportunity to sign-off here.
Comment #42
tim.plunkett1) Third party settings API handles it for us
2) I can look into that
3) #2924201: Resolve random failure in LayoutBuilderTest so that it can be added to HEAD has it :(
4) I think LayoutBuilderRoutes needs to become more extensible, it's not sustainable for every type of Layout Builder UI to expect to be included in this single class. Looking into this as well.
Comment #43
larowlanWhen I click 'manage layout' from manage display I'm sent to the layout page, which is fine.
But when I save the layout, I'm put back on the 'manage display' page with no indication that something happened.
Do I need to click save again there?
Did my changes save?
Screenshot:
On the edit layout page, the 'generate sample values' could use some love. The title generated is very long and breaks the layout. I realize that isn't related to the code here, but its definitely something that is a bit off. We really need a general usabililty review here (tagged as such).
Screenshot of that:
Also I think the 'save layout' button needs some visual affordance to make it clear that its the primary action here. At present its a bit lost.
Comment #44
tim.plunkettAdded messages to the Layout Builder UI for each action.
@EclipseGc opened #2936655: Layout Builder should use the toolbar modes system once it exists. to explicitly codify that our usage of local tasks is not desired nor permanent.
See the comps for the non-beta plan for the UI, which has had product manager and UX review: https://projects.invisionapp.com/boards/KH3EPJMFNWR4Z
I addressed #41.2 and #41.4 as well.
Comment #45
larowlannice!
Comment #46
EclipseGc CreditAttribution: EclipseGc at Acquia commentedSeems like a definitive move in the right direction. Cleans up a number of things and makes protects methods we don't want others using. RTBC pending tests.
Eclipse
Comment #48
tim.plunkettI introduced two bugs in the last patch.
First, the move to a static method on SectionStorageInterface ran into this Prophecy bug: https://github.com/phpspec/prophecy/issues/119
Second, the inlining of _layout_builder_create_section_component_from_options() failed to update $options after calling parent::setComponent().
Comment #49
EclipseGc CreditAttribution: EclipseGc at Acquia commentedLooks good to me.
Eclipse
Comment #50
pameeela CreditAttribution: pameeela as a volunteer commentedSome notes from manual testing:
#1.
After enabling the module, going to Comment Types > Manage Display > Manage layout results in
Fatal error: Call to a member function access() on a non-object in /home/du749/www/core/modules/comment/src/CommentAccessControlHandler.php on line 34
This only occurs if there is no content. Once you create a node, Manage layout works for the default comment type.
#2.
When you enable this module, it modifies the layout of the Article content type, putting the comment field at the top (above the body and image). Screenshots attached of before and after, they aren't great because my screen is very small atm! (Steps to test: Create an article on a fresh install, view the page, then enable "Layout Builder" and view it again.) Not a showstopper since it's an easy fix, but it's definitely unexpected.
Article page before enabling:
Article page after enabling:
Comment #51
larowlanPossible an issue with CommentStorageHandler::createSampleEntity?
Thanks @pameeela
Comment #52
tim.plunkettMy array_column/array_multisort wasn't working as expected, but thankfully Drupal provides a method for this already:
Drupal\Component\Utility\SortArray::sortByWeightElement()
Using that fixes #50.2.
The bug in #50.1 is because of
\Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::generateSampleValue()
(one step down the chain from CommentStorageHandler::createSampleEntity as suggested by @larowlan)
It tries to load an existing entity (in this case, a node) and can't find any.
But if you were to create and save a node first, this page would work fine (as @pameeela pointed out)
#2936793: EntityReferenceItem::generateSampleValue() should create a sample entity if a referenceable entity is not found is an issue to fix that, leaving it out of the patch
Comment #53
tim.plunkettComment #54
EclipseGc CreditAttribution: EclipseGc at Acquia commentedLast patch fixed the actual bug introduced in the previous re-work. The issue with comment is a specific shortcoming of the entity reference field's sample generation and is separate from this issue.
RTBC.
Eclipse
Comment #55
tim.plunkettNeeded a reroll due to #2935779: Come up with an affordance for what parts of the page are/are not affected by Layout Builder.
Additionally, fixed some PHPCS warnings.
Leaving RTBC as there are no functional changes.
Comment #56
tim.plunkettGot
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 13 database or disk is full in /var/www/html/core/lib/Drupal/Core/Database/Connection.php:1207
from the testbot, requeueing
Comment #57
EclipseGc CreditAttribution: EclipseGc at Acquia commentedStill looks awesome.
Eclipse
Comment #59
xjmThe sample content with the dead fish in #50 amused me.
Just scanning the patch to start; a few nitpicky things and questions I noticed while scanning:
I think this should probably be more specific ("Layout component"), since AFAIK it's used for translation?
(Here and maybe elsewhere.) Because experimental or because actually internal? Guessing the latter because of the interface but we should document why always.
I do like this better than the approach from last month.
Is this in scope?
Ah interesting.
Do we know necessarily that the "full" view mode is the default? I think I've had sites before where that was not the case.
Probably OK to fix after beta though.
Yep that's what I'm looking for. :)
Interesting.
In what way? What does this mean for calling code?
Comment #60
xjmWhat happens if the site builder tries to override a layout of not-the-default-display, or configure one for not-the-default-display?
Comment #61
EclipseGc CreditAttribution: EclipseGc at Acquia commentedLet me start by apologizing for the forthcoming sentences and their use of the word "default".
Users cannot currently override at the individual entity level any layout except the default "view_mode"'s layout. There's no UI to do it, there's no storage to do it. It doesn't exist.
If they want to configure a another view_mode's layout (say teaser, or search results) then that is 100% kosher and will completely work. So a layout configured for the teaser view_mode of articles would show up in a view of article teasers for all the articles displayed by that view.
Did that answer your questions? or did I answer other things you did not ask?
Eclipse
Comment #62
tim.plunkett#59
1)
Firstly, these strings are not used anywhere that I know of, but it is a best practice to provide labels anyway.
Secondly, I'm not sold on pigeon-holing these as "Layout components" only. In my mind, this is the first step toward addressing #1875974: Abstract 'component type' specific code out of EntityDisplay (as mentioned by @amateescu in #39)
2) Fixed
3) Thanks
4) That change is needed to address #41.4
5) We no longer have
full
anywhere in our code. D8 ships with the full view mode turned off, so this is the best we can check.It will be really interesting to see if we can resolve that disconnect from this side of things. But definitely post-beta material.
8) Tried to reword this. But basically, if you have 4 sections they are stored as 0,1,2,3 and calling
->removeSection(2)
will result in deltas of 0,1,2 not 0,1,3.#60
Configuring the layout for a not-the-default-display works as you'd expect. For example, with nodes you can go and see that the teaser will be configured to use a smaller image style and a trimmed body. This is migrated over upon install. Changing the layout for the teaser will affect their display on the homepage view.
There is no UI, no secret route parameter, nothing you can do to get to a place to override the layout of another display than the default. It is currently impossible, by design. #2907413: Consider supporting Layout Builder Overrides for other view modes would be for discussing allowing this.
Comment #63
EclipseGc CreditAttribution: EclipseGc at Acquia commentedTotally +1 to this.
Eclipse
Comment #64
mtodor CreditAttribution: mtodor at Thunder commentedI have tested patch from #62 and I experienced few problems. I didn't have time to dig deeper what happened there, just want to list them here since the issue is marked as RTBC and maybe problems are relevant. Also, someone can give additional feedback.
I have used Standard profile for testing and after enabling Layout Builder.
Comment #65
tim.plunkettWell spotted @mtodor!
1)
I had tested this, but with Body field.
If the field is present on any other bundles, then it will not print any output.
But if it is the last instance of the field, it will cause an exception.
This pointed to an issue with config dependencies. All the correct dependencies are in place, but we did not respond to it correctly.
2)
This is due to all code expecting the load-or-create flow of
entity_get_display()
, which is unfortunate. EntityConverter does not handle this, but now we do.3)
This was an issue with routing, somehow media_type was being loaded before section_storage (but after when node usually runs?)
Ensured that this won't happen again by using NestedArray::mergeDeep().
Comment #66
EclipseGc CreditAttribution: EclipseGc at Acquia commentedI ran through all these scenarios and we seem to be good now.
Eclipse
Comment #67
mtodor CreditAttribution: mtodor at Thunder commentedI have tested additionally, all problems listed in #64 are fixed. Nice work @tim.plunkett!
I have found one additional problem. You can reproduce it in following way:
1. go to manage display of article (any view mode)
2. add block for Body field
3. change "Formatter" => that will trigger Ajax Request
=> that ajax request adds a new block to the collection of blocks for a section and when you do "Add Block" exception will happen. Additionally, you can just close right tray dialog and Save Layout -> then the new layout state is kinda broken.
I have attached proposal for a solution, it's not nice, but works for what I have tested. Other option could be to react on trigger element in the request. I'm not sure, what way is better, maybe there is some other cleaner solution.
Comment #68
tim.plunkettAnother nice find!
Unlike the other bugs above, this one is currently untestable.
I will make a note on #2924201: Resolve random failure in LayoutBuilderTest so that it can be added to HEAD to test this scenario.
I've rewritten the fix slightly to use temporary form_state values, interdiff is against #65
I also checked for any other cases of generating new UUIDs, but they are all safe.
Comment #69
mtodor CreditAttribution: mtodor at Thunder commentedI have found two additional problems.
There is problem here when I try to delete full content type, then additionally in list of dependencies is also entity type (fe. NodeType) and node type doesn't have method
getName()
.Also in confirmation dialog, wrong information is provided. It's written that configuration for display views will be changed and then if you have 4 display views it will be displayed 4 times same name, for example: "Article content items". I think it should actually display Display View names.
When new field is created, then
$options['region']
doesn't exist. So PHP is giving Notice. I guess we could usegetDefaultRegion()
as fallback.Comment #70
tim.plunkettThis addresses both points.
First, this was an oversight when I was copying the logic from the parent:: implementation
Fixed it and added test coverage
Second, I cleaned up this code as @mtodor suggested in #layouts slack.
Additionally, I removed places in our tests where we passed 'region' to sidestep this bug. Whoops!
Comment #72
tim.plunkettThe getDefaultRegion method on entity displays is a relic of the old Field UI that we're replacing, we shouldn't try to use it here.
Fixed!
Comment #73
EclipseGc CreditAttribution: EclipseGc at Acquia commentedOk, I tested all the above mentioned bugs and found no issues. This is feeling pretty stable from what I can tell.
Eclipse
Comment #74
tim.plunkettAdding a confirmation form for the revert link.
Comment #75
xjmFor #74, I pinged @tim.plunkett about this problem. I mistakenly thought it was part of #2914484: Prevent the layout field from being removed if overrides exist This is the issue:
Clicking "Revert to defaults" accidentally when editing a layout override nukes your layout override with no override, even if you click "Cancel" afterward.
Testing the confirm form now.
Comment #76
EclipseGc CreditAttribution: EclipseGc at Acquia commentedNew confirmation form looks good and prevents #75.
Eclipse
Comment #77
xjmPer discussion with @tim.plunkett, @dyannenova, and @EclipseGc, we should add some basic browser tests for this functionality. Experimental modules don't need to have perfect test coverage, but we do need some for the basics.
Meanwhile, trying to reconstruct things that I posted last night (d.o ate my comment). Will post shortly.
Comment #78
xjmForgot to mention above: the reason those tests weren't included yet was #2924201: Resolve random failure in LayoutBuilderTest so that it can be added to HEAD. However, @tim.plunkett is going to write browser tests instead to work around that issue, and the things that actually need JS tests (like drag-and-drop) can still have tests added later (mostly not related to this issue).
Comment #79
xjmAlright so:
However, when I spoke to the layouts team two weeks ago, they raised the point that while administrators would likely control and deploy layouts for content types, individual entity layouts would often be created by content authors, and (as such) would need to go through moderation workflows. It would actually create data integrity problems if the layouts were not moderated along with the content, because content authors would be placing blocks and editing content together and submit it for review together.
So, at a high-level, it totally makes sense for this issue to use a separate storage implementation from the individual entity overrides (rather than replacing their storage implementation entirely).
I also spoke to @larowlan about this. He indepedently went through almost exactly the same thought process, with the same initial expectations and then the same reasoning for why that would not actually work.
Unassigning from myself to clarify that this issue does not need to wait on my further signoff. (@larowlan and I already discussed that last week; it just didn't end up back on the issue. Sorry for the delay!) That said, I am still reviewing and testing this.
Comment #80
tim.plunkettTest added!
Also fixed our workaround for #2936464: Remove setComponent() workaround in LayoutBuilderEntityViewDisplay to the actual correct fix, which is a huge relief for me.
Additionally, we should not be checking entity access during preview (aka, a sample entity).
Comment #81
EclipseGc CreditAttribution: EclipseGc at Acquia commentedThe changes make sense in the executable pathway. The test also looks good. My only criticism there would be that it'd be nice to test another view mode in addition to the default, but we can probably get that in a follow up. This test coverage is good enough for an experimental beta module.
Eclipse
Comment #82
xjmWhoops, yet another comment lost, blah.
But anywho:
It looks a little goofy with the help block, but that's not meant to be permanent anyway, so it does not matter here.
I also confirmed that prior user input (between save and is not lost when the user clicks "Cancel" on the confirm form. Thanks, TempStore!
I went through my miscellaneous screenshots of things I noticed in testing this and confirmed that none of them are introduced here.
Comment #83
xjmFixing broken image.
Comment #84
tim.plunkettReviewed with @webchick and @effulgentsia, most of these points will get follow-ups, but one of them (I think it will be #4?) needs to be resolved in this issue.
@todo Rename to third_party_settings?
@todo explain this!
@todo Move this upstream
@todo #2579743: Config entities implementing EntityWithPluginCollectionInterface should ask the plugins to react when their dependencies are removed
@see #1875974: Abstract 'component type' specific code out of EntityDisplay
@todo Open an issue to consider moving the data model improvements upstream
@todo Open an issue about final destination for this code (Drupal\Core\Layout and Field UI)
@todo Is this okay? :D
@todo Revert should only be presented when overrides exist
Comment #85
tim.plunkettOkay translating those notes into issues and changes:
#84
1) Opened #2939928: Discuss renaming SectionComponent's additional to third_party_settings for consistency
2) Added a comment
3) Opened #2939931: Add an implementation of EntityDisplayBase::label() and linked in the code
4) This... needed a big change.
First, removed the old code that hardcoded a fix for FieldBlock
Then added dependency calculation to FieldBlock itself
Also we need to work around #2579743: Config entities implementing EntityWithPluginCollectionInterface should ask the plugins to react when their dependencies are removed.
Additionally we need a temporary version of #2939925: Add a getPluginDependencies() method to \Drupal\Core\Plugin\PluginDependencyTrait
This change has a whole new test method.
5) Opened #2939932: Integrating Layout Builder directly into Standard profile
6) This is not ideal. And as needed for #2937799: Allow greater flexibility within SectionComponent::toRenderArray(), we might as well pass around the $in_preview value now
7) Added an @todo pointing to #2917777: Improvements to the styling, grouping, etc. of the Layout Builder UI actions form and updated that issue to note the needed change.
Comment #87
EclipseGc CreditAttribution: EclipseGc at Acquia commentedThere is so much so good about the dependency calculation in this interdiff, but this really hits it home I think and shines a light on things that were maybe a little too obfuscated up to this point to make good sense of. +100000000
Overall, this settles a number of my concerns about dependency management that I was struggling to put words to. I think it really increases the overall polish of the patch and the module and makes me even more convinced of the approach.
All that said, I still had issues with configuring certain blocks under certain conditions (for example the comments block). In my case I removed it, re-added it and then tried to configure it, and was greeted with an error. :-( I, unfortunately, have to agree with testbot right now. :-(
Eclipse
Comment #88
tim.plunkettHmmm the error, and what is described in #87, is because we can't rely on the contexts during dependency calculation.
The only reason it was needed was for the current bundle.
But due to #2671964: ContextHandler cannot validate constraints being committed, we can properly have a derivative per-bundle without exploding the list of blocks in the UI.
The interdiff is made to ignore whitespace changes, to make it slightly easier to understand.
Comment #89
tim.plunkettStupid mistakes. Forgot to run phantomjs locally when testing, so the failing test was skipped...
Comment #90
EclipseGc CreditAttribution: EclipseGc at Acquia commentedI'll try to make sense of these changes in the morning. I get where this is going, but I don't understand the specifics of the "why", and I need more brain power to do it, so tomorrow. :-D
Eclipse
Comment #91
tim.plunkettSwitched from dynamic dependencies to declared dependencies, since we can.
Also adding an explicit test for this to FieldBlockTest, in addition to the other implicit tests in Layout Builder.
Attaching an interdiff for this change, as well as a larger one for all changes since the last RTBC patch in #80.
Comment #93
tim.plunkettI rushed that last one and didn't have all my changes staged. This half is important too! :)
Comment #95
larowlanThere doesn't look to be a contextRepository field on this class (existing issue, can be follow up)
same for classResolver
Comment #96
tim.plunkett1 I believe is used by a subclass, that indeed could be moved.
2 is used by a trait
Comment #97
xjm#2940212: [meta] Miscellaneous UI issues for the Layout Builder module lists out various UI issues that are not in scope here (as a pile of screenshots). Hopefully this is also helpful to other reviewers. :)
Comment #98
EclipseGc CreditAttribution: EclipseGc at Acquia commentedRunning through manual testing, found that the taxonomy and comment displays were displayed in seven (instead of the front end) and that contextual links were missing and certain css issues were present. Pointed this out to Tim on a call, he's working on it.
Eclipse
Comment #99
tim.plunkettThankfully a one-line fix, and it fixes the theme issue, the contextual links issue, and the settings tray styling issue :)
Added a test for it too.
Comment #100
EclipseGc CreditAttribution: EclipseGc at Acquia commentedI've looked at all the code, and while aspects of the interdiff, as it pertains to the field block, are not what I wanted to do, it still ships the features I wanted, and actually simplifies the code a great deal, so as compromises go, this is a really good one.
I've tested the patch extensively manually for the sake of proving to myself this does everything we wanted.
This tested nodes, terms, comments and content block entities all with the results I expected. I think this is a huge step forward in what we're trying to deliver here and I have no qualms with the patch as it stands. RTBC pending tests passing. I put this thing through every exercise of which I could conceive.
Eclipse
Comment #102
EclipseGc CreditAttribution: EclipseGc at Acquia commentedYup, just reaffirming the rtbc here.
Eclipse
Comment #103
larowlanPer #44 and #97
Comment #104
larowlanAdding review credits
Comment #105
tim.plunkettFixing stale method name in a comment from before a refactor. Leaving at RTBC.
Comment #106
tim.plunkettPosted a CR https://www.drupal.org/node/2940777
Comment #108
larowlanGave this another code review and the only issues I have with it are addressed by #2937483: Defining a new type of section storage relies on magic strings and hidden assumptions
@webchick and @effulgentsia have gone over the code with @tim.plunkett
@EclipseGc has given it another extensive review and manual test in #100
I gave another manual test this morning, screenshot attached. Worked well - found a UX issue that I added to the existing meta
Committed 02f9325 and pushed to 8.6.x
Published the change record
:tada:
Comment #110
larowlanCommitted #105 as fbf13ed and pushed to 8.6.x
Comment #112
tim.plunkett