Here's the general problem from a low-level architecture stand-point:
- Page Manager is about creating routes and having variants attached
- The variants could be anything including plain HTTP responses - they don't have to know anything about blocks or layout
- So, the variants need to be able to add things to the UI through their API somehow, while also taking UI settings for the things that are common across all variants (like "Menu" for example)
- The Panels variant adds the concept of both layout and assigning blocks to those layouts - so, the Panels variant needs to provide a UI for setting up both those things
- However, we want to split the configuring of "which layout" and "what goes on the layout" to separate forms - so the API for variants to provide their UI for configuration shouldn't be returning a single form (ala
ConfigurablePluginInterface, but returning a set of forms - Also, we want to provide rich and dynamic UIs, however, from
ConfigurablePluginInterfacedoing AJAX is difficult (but possible) and modal dialogs are totally impossible! Returning whole forms allows us to step outside of the plugin and do more
In D8 CTools, there is the Wizard API, which allows you to have a set of forms that edits a single entity, taking advantage of the temp store to hold in progress changes.
This issue is about modifying Page Manager to use the Wizard API to configure variants!
Remaining tasks
Set access correctly for all routes. For the dialogs used within wizards, I've been experimenting with #2623888: Add ParamConverter that pulls entity out of the tempstore. Not sure how to handle access 'block_display' routes in a secure wayFinish or move the page parameters stuff to a follow-up issue - we can start using a wizard while continuing to use parameters like we do in current HEADGet the static contexts working (ideally without changes to how configuration is stored - that could be a follow-up)- (move to follow-up?) When adding a new page, overwrite any existing pages in the tempstore with the same ID. Basically, the problem is that right now those pages existing in the tempstore will interfere with adding a new page with the same ID.
- (move to follow-up?) Refactor out a trait or base class for the forms (mostly dialogs) that access the wizard data in the tempstore but aren't wizard steps - there's lots of code duplication in the current patch
- Deleting a page should delete it from the tempstore as well
"Update and save" should stay on the same pageAfter finishing the add wizard, we should jump right into the edit wizardUpdate the tests to work with the new UISetting on text for the "Update", "Update and save", "Save" buttons.
Original summary:
Work on 8.x-1.x continues forward and this is good in principle, but increasingly, I worry about getting the wizard work merged in the further down this path we go. I'd like to see us move toward collaborating on the wizard branch and getting it merged in sooner rather than later. Of course there is still a lot of work to do there, but I'm filing this issue so that we can evaluate the changes already introduced and begin making plans for an eventual merge.
Eclipse
| Comment | File | Size | Author |
|---|---|---|---|
| #249 | 2550879-247.patch | 281.17 KB | eclipsegc |
Comments
Comment #2
eclipsegc commentedpatch
Comment #3
tim.plunkettThis whole section is missing.
Bad merge
Same, all of the static context stuff is missing?
Little things like this we can merge in early, can you split this change out to another issue?
Comment #4
dsnopekRelated to static contexts, earlier today EclipseGC and I discussed making a change to the way contexts are passed to display variants:#2550941: Allow passing contexts to display variants (to enable Panels Everywhere to use static context and relationships)If we're able to get that into core, then we can implement static contexts using that!EDIT: Er, actually, looking at the code, that is just totally unrelated. :-) Page Manager already has
ContextAwareVariantInterfaceand can do the right thing. The core issue would just move that goodness into core, so that Panels Everywhere can use it.However, in the meantime, the existing static context stuff should be worked back into the wizard patch.
Comment #5
dsnopekHere's a re-rolled patch against the latest page_manager so it doesn't remove the static context stuff. That said, I didn't actually test it or attempt to port the static context stuff into the wizard, so I'm sure this still needs work. I also didn't address any of Tim's comments in #3
Comment #6
dsnopekI did some manual testing on my re-rolled patch on #5 and trying to create a new Page results in a fatal error. :-/ The problem is that
BlockDisplayVariant->buildConfigurationForm( )needs$this->executable, but I'm not sure how construct aPageExecutablebefore thePageactually exists... This would be a lot simpler if we got #2511570: Remove Drupal\page_manager\Plugin\PageAwareVariantInterface done first!I also did a quick read through the patch:
Is this debug code temporarily commenting out _entity_access? Or does the _entity_create_access replace it and the _entity_access line should be removed entirely?
(I'm pretty ignorant of the routing system, sorry!)
Should this (and the route title that follow) use sentance case? For example: "Add condition" instead of "Add Condition"?
I don't know the answer to that -- I'm really asking. :-)
Just marking this code for myself to try and figure out how the current user context is handled if not through this event subscriber...
Missing docblock.
Debug code or should really be a deletion?
This one really seems like it should be a deletion. We can have the PageExecutable pass the context directly to the variant, which may actually be happening here, but I haven't gotten to that part of the patch yet.
Missing docblock!
Missing docblock!
I'm not sure about the PageVariant entity implementing PageVariantInterface from a "seperation of concerns" perspective.
I'd feel better about the PageVariant entity having a function that would construct the the underlying variant plugin which is responsible for the runtime work, and then returning that to call directly.
Loads of missing docblocks. I think I'm going to stop pointing these out now. :-)
This is a lie! This file (PageSelectionForm.php) really has PageSelectionForm.
Also a lie. Should be 'PageVariantConfigureForm'
For human-readable interface strings we should decide what we're going to call it. Personally, I like "variant" best. Another option is "page variant" but I definitely don't think we should do "PageVariant"
Another lie in SelectionConfigure. I'll stop pointing these out - it's just nits.
getParameters() is for context that is from the URL, right?
Could we put "Entity" into the name of this interface somewhere? Otherwise, it'll be difficult to tell the differents between this and PageVariantInterface from core which refers to the variant plugin.
Comment #7
dsnopekAdding to sprint board.
Comment #8
dsnopekWould it make sense to extract the changes which convert page variants to independent config entities into it's own issue? That would certainly help move #2511570: Remove Drupal\page_manager\Plugin\PageAwareVariantInterface foward...
Comment #9
dsnopekI started an issue to extract the parts that convert page variants into their own config entities on this issue: #2551633: Make variants into their own config entity
Postponing on that, so we can get that chunk in first, and hopefully make it easier to review/integrate the wizard changes.
Comment #10
dsnopekI'm copying part of a response that I posted on #2513910-9: Consider using page manager UI similar to Backdrop? because I think it might clarify why I think the wizard changes are necessary:
Comment #11
dsnopekUpdated issue summary
Comment #12
dsnopekThis is unblocked now that #2551633: Make variants into their own config entity has been merged!
First, this'll need a re-roll on to the new code.
Comment #13
dsnopekAssigning to myself! I've started working on the re-roll...
Comment #14
dsnopekHere's a straight re-roll, that sort of works. It allows you to create a new page and add a variant to it, but it appears you're unable to configure the "Block page" variant beyond just the page title. So, the next step is iterating on this until you can add a variant fully with all it's configuration (including block placement).
Comment #15
dsnopekJust wanted to post this patch with only a small number of changes because I'm working on some heavier stuff that might not get posted for a bit!
I attempted to make the page_manager.routing.yml more consistent with what's currently in page_manager HEAD. This was a little difficult because the page entities aren't actually created yet, so we can't rely on entity access. We'll need to do some custom access stuff at some point, checking special for unsaved pages and checking normal entity access when editing an existing page.
Comment #16
dsnopekThis is blocked on fixing #2607552: Pass $cached_values to WizardFormInterface::getOperations() in the Wizard API to allow us to correctly vary the wizard steps depending on whether we're creating a new page or editing an existing page.
Comment #17
dsnopekHere's a long-overdue updated version of this patch! It works for both adding and editing of the page, but it depends on a number of patches to the CTools Wizard API:
#2616492: Allow overriding cached values for specific operations to make it possible to use the same form class for multiple steps
#2616494: On any reusable wizard step forms, pass $cached_values to methods return route info
#2619948: Cached values not in tempstore when first editing entity in wizard
Comment #18
dsnopekHere's a new patch that makes some small bug fixes and changes the buttons on edit to be "Update" and "Update and save". But mostly it removes the menu stuff, which I moved into this patch on #2620036-2: Allow pages to have menu items
Comment #19
dsnopekThis new patch implements full CRUD with variants (adding, deleting, re-ordering) and removes a bunch of old code. The next step is finally to try and implement
PluginWizardInterface!Comment #20
dsnopekHere's a new patch that actually does the dream of moving the configuration of variant plugins into wizard steps via
PluginWizardInterface(which also means this now depends on this CTools patch: #2607382: Add PluginWizardInterface so plugins can be configured with wizard steps). I thoroughly messed up generating an interdiff so I'm not including one with this change - sorry!Comment #21
dsnopekThis patch adds some vaguely page_manager-ish styling to the the edit wizard. I never liked the page_manager UI so it's a little bittersweet recreating it like this. :-/ But here it is.
Comment #22
dsnopekSince this is no longer about a specific branch (it's all in patches now), I've retitled this issue to describe the actual change it's making.
Comment #23
dsnopekNot a meta, so changing category.
Comment #24
dsnopekHere's an attempt to get access correct on the routes using #2623888: Add ParamConverter that pulls entity out of the tempstore but there's a whole bunch of routes that won't work for... I've been trying to see if I can improve it to allow those to work too, but then I hit #2619948-11: Cached values not in tempstore when first editing entity in wizard again and it's blocking forward progress on that.
So, here's this patch is a couple commits backward in my Git repo, but it's the last thing that works as well as the previous patch.
Comment #25
dsnopekI added a "Remaining tasks" section to the issue summary which has everything from my personal TODO that still needs to be done in this patch.
Comment #26
wim leersHere's a cursory review that I did while reading this patch to get a high-level overview. I don't know any Page Manager details. So it's mostly code style/cleanliness things. Hope it helps.
Nit: missing trailing period.
What's preventing us from doing what the @todo states? I guess because the entity is not available as a route parameter?
s/new//
No interface to typehint on?
Missing/incomplete docblock for these and other methods here.
Typehint to the interface?
This looks pretty strange.
array()->[]t()->$this->t()Here and elsewhere in this file.
There's no AJAXy stuff here. If this is necessary, should have an
@seeto make that clear.Outdated docs.
Dead code, or needs a
@todo?Same remarks as for
PageContextsForm.Mismatch.
I've seen this stuff several times now; looks like this could use a base class. Or perhaps a trait.
Mismatch.
Mismatch.
Mismatch.
Mismatch.
s/id/ID/
Comment #27
dsnopekHanded this one off to EclipseGC last week! I'm a little burnt out on the issue. But I'll be happy to come back with reviews (or even take it back) later.
Comment #28
eclipsegc commentedOk, this is a reroll of 24 since PageManagerController changed and it no longer applied. None of the subsequent reviews have been taken into account yet, strictly a reroll.
Eclipse
Comment #29
swentel commentedNice start, feels much more natural adding new pages.
Current patch fatals (on the overview page) though with devel and/or config translation enabled though, fair warning when testing.
Comment #30
eclipsegc commentedOk, this is just to help me and dsnopek discuss some changes I'm making.
Eclipse
PS: Will provide real interdiffs and stuff later, just ignore this.
Comment #31
eclipsegc commentedOk, completed the conversion to perm based routing and updated the page_manager provided block variant plugin routes and forms to work directly against the plugin. Also leveraged the new ctools API for allowing access on variant provided routes to be swapped by the wrapping wizard. This is a pretty awesome improvement and means individual wizards wrapping the variant plugin wizard steps can introduce their own access requirements on the same routes.
Eclipse
Comment #32
dsnopekHere's an interdiff between #24 and #31. I generated it quick and dirty without reviewing it, so no guarantee's it's correct, but it might be useful. :-)
Comment #33
dsnopekI did a quick read through the interdiff, and have two small bits of review:
I don't think this is right. There really isn't an independent route to edit a PageVariant (only a whole page) after this patch, so maybe we want to remove "edit-form" completely? Otherwise, other modules (like devel, config_translation, etc) will try to put their own routes below that route.
The old return value is for adding a new Page, and then new return value is for editing. :-) This should have an if/else like in SelectionConfigure::getParentRouteInfo().
I've also updated the remaining tasks in the issue summary!
Comment #34
dsnopekHere's a patch with the explicit 'parameters' mapping stuff removed!
I've put those changes on this follow-up issue instead: #2631802: Allow explicitly configuring the type of context from parameters
Comment #35
dsnopekAnd here's a patch addressing my own review from #33.
Now, I'm going to refocus my attention away from actual functional changes (leaving those to EclipseGC) and start working on updating the tests. The UI itself is pretty stable, so it should be OK to work on the tests. And I think it'll make a good division of labor where we won't necessarily step on each others toes patch-wise!
Comment #36
swentel commented@dsnopek regarding #33.1 : I think that route actually helps for config translation to create a dedicated page to translated properties of the variant (say title for instance). Haven't tested that patch though, but in my initial testing before (see #29) the overview actually crashed with config translation enabled - and devel too :/
Comment #37
dsnopek@swentel: If those modules won't make up their own route if the config entity doesn't have its own edit route, then we might need to make a special route just for them, which would be unfortunate. :-/ In any case, after this patch, we don't have an obvious existing route for the page variant entity to be edited independently of the page entity, which is why I removed those from the entity type annotation in #35.
Comment #38
eclipsegc commentedOk, so this is a legit response to #26. The interdiff won't contain all the fixes I made because it happened across a few patches, but most of these issues are addressed at this point.
1.) ok
2.) Yes, the entity is in the tempstore, so we need a custom ParamConverter. We've got one of those in ctools, and largely it works for this use case, but we have a need on some pages to also extract the page variant entity and that's a step too far. For the time being we've gone back to permissions and this is fine because it maintains feature parity with D7 page_manager
3.) ok
4.) Nope, there isn't one in core.
5.) We've actually backed this specific code out because it introduces new features and is scope creep. We'll get it back in in another issue #2631802: Allow explicitly configuring the type of context from parameters. The rest of the methods were all double checks for their docs.
6.) Yup, ok
7.) Yeah, it's an aspect of the ctools code that we're extending. I'm happy to discuss ways to make this less weird in the ctools issue queue if you like.
8.) ok
9.) This page is going to get some ajax once we've got it working which should happen in this patch because it's a current feature of page_manager we need to expose.
10.) ok
11.) added a todo
12.) I couldn't find any bad arrays or t()s in this. Maybe we fixed it passively since your review.
13.) ok
14.) Ideally, that'd be great, but too often we have other necessary constructor parameters so I don't feel that it is practical.
15-19.) ok
Eclipse
Comment #39
eclipsegc commentedsorry the patch in 38 is an interdiff. here's the real patch.
Eclipse
Comment #40
dsnopekHere's a patch that gets the PHPUnit tests running, PageManagerTranslationIntegrationTest and a start on PageNodeSelectionTest. It makes a couple small functional changes to fix bugs discovered in working on the tests.
Comment #41
samuel.mortensonJust reviewing functionality (visually), I noticed the following:
1. When adding a page, removing a condition added at /admin/structure/page_manager/add/[machine_name]/access throws the following error:
error: Call to a member function id() on null in /Users/samuel.mortenson/Sites/drupal/modules/page_manager/src/Form/AccessDelete.php on line 19. The same error is thrown when trying to configure a condition after the page is added.2. When adding a page, removing a condition added at /admin/structure/page_manager/add/[machine_name]/selection throws the following error:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Drupal\page_manager\Form\SelectionDelete' does not have a method 'validate' in Drupal\Core\Form\FormValidator->executeValidateHandlers() (line 88 of core/lib/Drupal/Core/Form/FormValidator.php).3. Once a page is added, adding a "Selection Criteria" condition throws the following error:
Fatal error: Call to a member function get() on null in /Users/samuel.mortenson/Sites/drupal/modules/page_manager/src/Form/SelectionConfigure.php on line 584. The text "Configure Condition" is used when adding conditions, but what you're really doing is adding a new condition. Once a condition is added you click "Edit" to configure it, so it seems like there needs to be a standardization of terms used.
5. The deletion confirmation screen in a lot of places should have the "Cancel" button inline with the "Delete" button. You can see this by deleting a Page, Variant, or Condition.
6. "Add variant" and "Reorder variants" look like tabs on the top-right hand corner of the page configuration screen, but they just open modals. Could we add these to the kind-of-vertical-tabs on the left side of the page, nested under "Variants"?
7. To delete a Page, you click on the "Delete" tab, but to delete a Variant you have to go to the nested menu on the left and click on Variants -> Variant Name -> General, which has a "Delete this variant" button. Can we standardize this a bit?
Comment #42
dsnopekMy problems with PageNodeSelectionTest turned out to be a CTools bug: #2639526: Calling BlockDisplayVariant::setConfiguration() won't change results returned from plugin collections
Here's a patch that re-orders the stuff that test does to be slightly easier to read.
Comment #43
dsnopekThis patch gets all the tests, passing except for
StaticContextTestbecause static contexts aren't yet supported (EclipseGC is working on it). That said, there are a number @todo's added, at least one nasty hack to get things working, AND there are some new UIs in this patch which aren't covered. But I'd say this gets us 90% of the way there!Marking as "Needs review" just to make sure testbot gets the same results that I'm getting locally..
Comment #45
dsnopekBah! The tests did worse on testbot than locally on my machine, because this patch depends on changes in CTool 8.x-3.x-dev. Until we have a new CTools release, this patch will never pass. :-/
Comment #46
dsnopekHere's an attempt to clean up the "nasty hack" from yesterday, so that it's clear exactly what it's doing and why, and to make it easier to remove later (when contexts are solely on the variant per #2631800: Store static contexts on the variant rather than the page). Today, I'm going to attempt to flesh out
PageManagerAdminTesta bit more to cover all new UIs in this patch, and try to eliminate some of the other @todo's in there.Comment #47
dsnopekThis patch adds tests for the 'Access conditions' and 'Selection criteria' steps in both the add and edit wizards. This also fixes the bugs that @samuel.mortenson encountered in #41.1, #41.2, and #41.3, and those things are covered by tests now. :-) I'll respond to the rest of Sam's review in my next comment.
Comment #48
dsnopekRegarding the rest of the UI review in #41:
Agreed! This actually comes from
\Drupal\ctools\Form\ManageConditionsso this will be a CTools change.Yeah, I'm not 100% sure on the cause of this but I think it comes from
\Drupal\ctools\Form\ConditionDelete, so again, a CTools change.So, they are at the top looking tab-ish because that's how they look in D7's page_manager, although, the proliferation of tabs everywhere is one of the things I personally hate about D7's page_manager. :-) However, they open in dialogs for purely technical reasons - they aren't actually wizard steps.
All that said, I'd personally be fine with them being moved to the tree thinger on the left. The question really is how closely we want to mimick the UI of D7's page_manager, which probably needs discussion.
In D7's page_manager, it had a second set of horizontal tabs for the variant, which is where the delete button is for the variant. I think I did it this way because it was easier to implement, and all the tabs hurt my soul. :-) But we could definitely switch back to that to match D7, but let's wait until we have a discussion about just how closely we want to mimick that.
Comment #49
dsnopekHere's a CTools issue to fix one of my @todo's: #2640392: ConditionDelete puts a 'validate' method on '#validate' that doesn't exist
Updated the patch to reference it.
Comment #50
samuel.mortensonI'll try to pull CTools patches for #41.4 and #41.5, see if we can get this done in that project. For the bigger UX concerns, we can always open up a new issue after the technical portions of this are done. Given our release deadlines I don't want to slow down progress (too much). :-)
Comment #51
dsnopekThanks, Sam!
Here's a patch that addresses an issue where the label given for a variant would overwrite the label of the page. It turns out to come from a bug in the Wizard API:
#2640410: FormWizardBase/EntityFormWizardBase take the label/id from any form element called label/id on any step
But, for now, implemented a workaround that switches the label for the variant to be 'page_variant_label' rather than just 'label'.
Comment #52
dsnopekHrm. I went to dig into one of my hacks in the tests from yesterday (a strategically placed
drupal_flush_all_caches()), and it appears to no longer be necessary! It must have been fixed by one of the other fixes I did earlier.So, here's a new patch that just removes that!
Comment #53
dsnopekThis patch sets up the access on all the 'block_display' routes per the CTools "access object" stuff that EclipseGC added a couple days ago.
Looking through the patch, I think we're to a point where the tests are as far as they can be until EclipseGC finishes the work he's doing on getting static contexts working, and finishes up the couple trivial "Remaining tasks". So, I'm going to stop sprinting on this until that stuff is done!
Comment #54
samuel.mortensonSubmitted some small UX patches to related projects:
#45.4 - #2640472: \Drupal\ctools\Form\ManageConditions submit text not clear
#45.5 - #2640464: Links styled as buttons not placed inside Dialog's button pane — prevents "cancel" link/button from showing up
Comment #55
berdirTesting this for the first time, some feedback. Feel free to move parts of that to follow-ups or ignore. Didn't read everything that was mentioned already.
Comment #56
dsnopek@Berdir: Thanks for the review! For the most part, I agree with all your points, however, I have couple comments on the last two...
#55.8: Actually, the default machine name for the first variant created does include the page machine name, so it's always unique. For variants added later, it's up to the user to keep the machine name unique just like it works in current page_manager 8.x-1.x.
#55.9: You can definitely edit a variant! Otherwise, we wouldn't have been able to get all the admin UI tests passing. :-) The only piece of functionality that should be missing at this point is the static contexts, which EclipseGC was working on last week, but never posted a patch - I'm not sure where he's at with it.
Comment #57
eclipsegc commentedOk, I've applied all of dsnopek's interdiffs along the way. Not sure if my interdiff will work for others, but this should be an up to date patch at this point. Static contexts can be added, edited and removed! We can start checking the test coverage on this, and make sure nothing is broken along the way, but I believe this replicates the functionality in 8.x-1.x.
Eclipse
Comment #58
dsnopekUpdating "Remaining tasks" because we don't want to do: "On the Structure -> Pages listing page, show pages that are only in the tempstore and haven't been saved to configuration yet"
Comment #59
eclipsegc commentedFixed the static contexts breaking the tempstore storage mechanics and updated the wizards to transition more smoothly from add to edit and allow for a separate "save" button which will quit out of the edit wizard. 'Update and save' now continues to edit the page.
Eclipse
Comment #60
eclipsegc commentedComment #61
dsnopekI started updating the StaticContextTest now that those are working(-ish)! However, I'm still getting the
LogicExceptionthat #59 was meant to fix when adding contexts in the add wizard. :-/Comment #62
eclipsegc commentedFound an issue with putting plugins into the tempstore. Filing an upstream patch. Add/edit transition should work now.
Eclipse
Comment #63
dsnopekBlergh. So, I tried finishing up the tests! However, the contexts weren't getting serialized at all, so in order pass down the contexts I had to add in a hack that is dehybrating and rehydrating the contexts manually from the tempstore. This allows blocks that need context to be added in the UI and configured, but testing with the EntityView block from CTools, it errors out fatally when actually trying to view the page and I'm not sure why. :-/
So, here's a patch that gets slightly further but static contexts are still not working for me...
Comment #64
eclipsegc commentedOk, so I was saving context by entity id instead of UUID, once I fixed that the EntityLazyLoadContext class started working properly.
Eclipse
Comment #65
dsnopekHuzzah! Here's a patch that has all the tests passing locally. It depends on having the latest 8.x-1.x branch of CTools.
From the last patch, I had to make some small changes to the
StaticContextConfigureform to prevent some PHP warnings (which get counted as 'exceptions', ie. failures, in simpletest). And,unset()'ting the plugin collections in__sleep()was causing the magic plugin collection serialization to not happen and broke previously passing tests. But other than that, it's just changes to the tests.I've updated the "Remaining tasks" in the issue summary.
Comment #66
tim.plunkettThis should be a separate issue.
This should be a separate issue.
This should be removed :)
This should be a separate issue.
Why this switch? And this should be a separate issue.
Any insight here as to why we can change this?
This should be a separate issue.
This sorta makes sense, but it's also another problem because what if $this->page === NULL?
This should be a separate issue.
Any reason not to put this into getPage()?
Why? Isn't that service, and therefore handled by the trait?
Comment #67
dsnopekWe postponed this to "Milestone 2" - so, other issues that could have depended on it that we need for "Milestone 1" are going to have to be done another way.
Comment #68
eclipsegc commentedThere continues to be confusion around:
a.) what we're trying to accomplish here
b.) what the final result of this effort provides
To that end, this post will attempt to break down the effort herein and what the primary benefits of it are.
Tempstore
The generally agreed upon benefit of this route is that page_manager's pages would no longer update live during the process of editing. This is important because Pages are complex and have many moving parts. I usually avoid views as an example, but you wouldn't want a view to update live while you were editing it. You want to get it to a proper place and then save the whole thing. All wizard based approaches operate this way, and I think all sides agree that that's a big benefit to page manager specifically.
Reusable wizard steps
Anticipating the usage of conditions, contexts, relationships etc, CTools has UIs that can be used by any module. These were built with page_manager in mind, but not exclusively for it. The wizard leverages these steps and helps to unify PM's approach with ctools and any other module that might choose to use those UIs. The other big benefit in this regard is that PM opens up what a Variant plugin can do within its framework. Currently Panels has exactly one page it can provide for interacting with a panel. This is a less than ideal.
Ideally, panels would provide its own steps in the wizard. It could pull together its own steps in whatever fashion makes sense to it, and then any module that might make use of panels could use those steps as UI. Typically, Panels has provided a step for layout control, a step for block placement and configuration and a step for transitioning blocks from one region to another when the layout is changed. Page Manager in D7 uses all of these steps, and Panelizer uses 2 of the 3 in its entity bundle default administration screens. Since panels variant plugin has been limited in scope to providing a single administrative form, this is no longer possible. Without this work, Panelizer would have to invent all its own UI components and maintain them all independently. If the wizard patch lands for PM, that opens up what panels (and any other variant plugin) can do, and means panelizer can reuse panel's variant administration within its administration screens.
I've provided some D7 screens below to show how this should be working:
Context: https://www.evernote.com/shard/s4/sh/001d680f-4c36-47f9-bb0a-9987558566b...
Layout: https://www.evernote.com/shard/s4/sh/72dfda25-88c3-405a-8fbe-e925d803538...
Content: https://www.evernote.com/shard/s4/sh/29451d05-7c46-419c-b111-7662c4fc9e5...
Each of these screens represents one of the shared screens across multiple UIs that leverage panels. Panelizer and PageManager are just the ones being pushed forward today. Mini Panels and Panels Everywhere would also share these UIs (and others) and need UI components that can be strung together to create the proper workflow.
The continued resistance to this patch needs to go away. This is a good thing, it provides numerous, module-spanning benefits, and allows us to componentize any UI improvements to specific screens that multiple modules will benefit from simultaneously. If we don't solve this here and now, we're hamstringing every panels based module in the environment.
Eclipse
Comment #69
juampynr commentedRe-rolling. This is a tricky one since a few things have changed and have been moved to page_manager_ui.
Comment #70
juampynr commentedThis is an attempt to manually re-roll the patch at #65. I couldn't finish rebasing 8.x-1.x on top of it because there were too many conflicts so I looked at the patch manually to understand the set of changes and compare them against HEAD.
Here are a few questions:
1. Many forms and other classes have been moved to page_manager_ui, but this patch adds a few extra classes that depend on them (for example, PageWizardBase references PageGeneralForm). What should we do?
2. Page and PageVariant don't define handlers in their annotations but instead they now do it through hook_entity_type_build(). How could we add the wizard handlers there?
3. Some of the tests have changed a lot. I managed to update most of them but I am sure that I missed stuff at PageNodeSelectionTest.php.
Aside form this, is there a chance to split this in smaller tasks? This patch is so big that it is very hard to keep it up to date.
Comment #72
tim.plunkettIMO this should be a separate module called page_manager_wizard, and it should be installed *instead* of page_manager_ui, not in addition.
Comment #73
juampynr commented@tim.plunkett, thanks for the feedback. I discussed this with @EclipseGc and we agreed that since the patch relies on some classes that are in page_manager_ui, we will implement the wizard classes within page_manager_ui. I will see if it is possible to do this in small steps instead of submiting another big patch.
Comment #74
juampynr commentedThis looks much better now. Here I have:
* Moved Wizard files from page_manager to page_manager_ui (since they depend on page_manager_ui's forms).
* Removed the changes in the tests, as I first want to see this working locally and then I will update the tests.
I am about to start testing this manually and fix bugs in the patch.
Comment #75
juampynr commentedFixed a few things:
* Fix CSS library attachment
* Dynamic wizard handlers for Page.php
* Fix yaml format in routing
Now I am testing the UI. I am debugging why the node page can't be saved or updated. It looks like the page id is not being loaded from the temporary storage correctly. Will continue tomorrow.
Comment #76
juampynr commentedPhew, this one was tricky, this line at Page::__sleep() was avoiding the Page's id to be saved in the shared storage:
The issue with the above line is that array_search() returned FALSE, which was evaluated as 0, which was the first key in the vars array. Now the Update and Save forms are working back again.
I will continue testing the patch manually and fixing bugs.
Comment #77
juampynr commentedI am now looking at how to adjust the logic so the patch uses
PageVariant::getStaticContexts()instead ofPage::getStaticContexts(). This is something that changed at #2631800: Store static contexts on the variant rather than the page, which got committed after #65.Comment #78
juampynr commentedFixed a few things:
* Fix wrong class path for VariantPluginContentForm (as forms were moved to page_manager_ui).
* Fix the type of PageVariant::contexts so it matches whith Page::contexts. This was causing an error in the UI.
* Fix further buggy statements at __sleep().
Now I am comparing 8.x-1.x against this patch to fix what I mentioned at #77.
Comment #79
juampynr commentedThe issue that I described at #77 was caused by some stalled data that I had at key_value_expire. I realised that in order to start over with this patch, I need to uninstall page_manager_ui and page_manager modules, and then run the following query:
Here I am fixing a bug where deleted variants were being listed at "Reorder variants" I don't really like the approach as the snippet was copied and pasted from another class. Should we move this to a trait?
I am done with manual testing so now I will start fixing the tests.
Comment #80
tim.plunkettThis conflicts with the logic in getContexts(), which checks is_null
unset() doesn't need an isset check first.
Comment #81
juampynr commentedFixed @tim.plunkett's feedback at #80.
Working on the tests now.
Comment #82
juampynr commentedFixed a few strict and critical errors so now tests complete running. I have started working on updating them so we should start seeing the number of failures going down in my subsequent patches.
Comment #84
juampynr commentedFixed half of PageManagerAdminTest.
Comment #86
juampynr commentedFixed errors for PageManagerAdminTest.php. Moving on to the other tests.
Comment #88
yanniboi commentedHad a quick look at PageManagerAdminTest and still getting a couple of fails (could be my dev environment but thought I'd check):
and
are probably caching issues...
And then there are a couple of schema errors:
Comment #89
juampynr commentedIt's weird @yanniboi, the test passed at the testbot. Are you using Drupal core 8.2.x, and the latest HEAD of ctools and page manager?
Comment #90
yanniboi commentedNevermind, I just updated core, and all the errors went away :P
Comment #91
yanniboi commented8.2.x? No I was still on 8.0.x :P
Comment #92
yanniboi commentedI have noticed a regression in adding/editing variants.
Currently as I understand it the only variant plugin that the new UI supports is the Block Page. In the process of adding support for 'Panels' I have come across the following.
Prior to the Page Manager Wizard UI, there was a 2 step process for adding a variant to a page.
The new UI in only has a single form, which is a select list of plugins and a label. However more configuration is needed for different variant plugin types, eg. Panels requires at least the selection of a layout before it can be created, otherwise when you come to edit the plugin it throws errors.
I think the solution is to move towards an add/edit variant wizard where different variant plugin types can specify additional operations, eg. Layout, Selection Rules, etc.
Comment #93
juampynr commentedThis patch updates StaticContextTest.php and PageTest.php.
I discussed with @EclipseGc the StaticContextTest.php errors and found out that the contexts are for variants and not the page entity. I will now work on making the following change in the UI and classes:
Comment #95
juampynr commented@andrewbelcher found a piece of logic in page_manager that skips simple_page and block_page variants. I showed this to @EclipseGc yesterday and he agreed on doing the same in the Wizard API. I am posting this here as a remainder and I will add it to the patch once I am done with #93.
Comment #96
andrewbelcher commentedTo make that a little more readable/copyable:
Comment #97
juampynr commentedJust did a hangout with @yanniboi and @andrewbelcher. We discussed the following:
Andrew needs to be able to define dynamic form steps in the wizard. @dsnopek pointed him to #2687617: Dynamic steps when only the first is certain don't work
@yanniboi needs feedback on the issue that he described at #92 when adding/editing variants.
@andrewbelcher also mentioned that there seems to be something wrong with the finish method. In theory, it should be called just when you click on Save or Update and Save, so it saves both the Page and its Variants. However, it seems that this is not working this way.
Comment #98
juampynr commentedHere is the first step forward for #93. Here I have:
There are a few more things that I need to adjust for this to be fully functional. Here is a screenshot of how it looks like:
Comment #100
juampynr commentedHere I have added @andrewbelcher's suggestion at #96, where core variants are excluded as they are not configurable.
I am figuring out what is wrong with tempstores because when you add a context to a variant it does not get listed.
Comment #102
juampynr commented@andrewbelcher shared with me in a hangout a discussion on managing tempstores that he had with @EclipseGc. Here is the summary:
The forms in this patch define separate tempstores, which leads to inconsistencies. There should be just one tempstore per page. Its contents are what should be passed to Wizard forms so they can update it. I started working on this yesterday so my plan is to complete the work this morning (Spanish time) and submit a new patch).
Comment #103
juampynr commentedFixed the issue with variant contexts not showing up. It wasn't an issue with tempstores but the logic not loading them properly.
@andrewbelcher, I have not made the change of making wizard forms to receive cached values instead of the tempstore id because the logic that I have reviewed so far seems to be working fine. I don't want to make too many changes on the patch until we get tests passing: then we can make improvements on it.
@yanniboi created a snippet to add a cancel button, which I will add in a following patch https://gist.github.com/yanniboi/65ac8a701eb5ca3c6c28.
Comment #105
juampynr commentedAdded the Cancel button suggested by @yanniboi at #103.
I am reviewing the rest of the forms to make sure that they use the correct tempstore.
Comment #106
juampynr commentedFew fixes in this patch:
* Fixed context routes as they now belong to the variant and not the page.
* I removed the edit operation from Page parameters. Is this correct? See the following screenshot:
Now that contexts are working, I will get back to fix the tests.
Comment #108
andrewbelcher commented@juampynr On page parameters you should be able to edit them so that you can select the type for the context (or none), but you shouldn't be able to add or remove them. In variant context you should be able to add/remove/edit (but type can't be none as you would remove).
Comment #109
andrewbelcher commented@juampynr here is a micro patch to merge into yours that fixes the
Page::toUrl('edit-form')(and removes an override on the list builder that worked round the problem).Comment #110
juampynr commentedThanks @andrewbelcher! This patch adds your suggestion.
I am debugging a weird redirection that happens after adding a context and clicking Update (reported by @EclipseGc). Then I will continue fixing tests.
Comment #111
juampynr commentedFixes PageVariantTest.php.
Comment #113
juampynr commentedFixed parameter editing, as described by @andrewbelcher at #108. I made it possible to edit them at Page Parameters. The ParameterEditForm form was not prepared to use the temporary store so I updated it.
I see that some of the form classes could share a few methods to manage the temporary store, but for the moment I want to make the minimum amount of chances until tests pass. Once tests pass, we can start refactoring.
Comment #115
tim.plunkettPlease do not mistake this review as an endorsement of this issue.
Also I ignored all changes to page_manager_ui. This should still be a separate module. I only reviewed page_manager changes.
This is not in scope. If it is necessary, it should be in its own issue (with test coverage) that blocks this.
Same as above
Ahem.
Any explanation for this?
This change makes no sense. Also using Page::load is a step backwards.
This order seems to be backwards. It probably broke a unit test somewhere.
All @todos should have issues, unless they are to be fixed before commit, in which case you can use @fixme
This should not be necessary, the parent trait should handle it.
This seems like it would be better as an annotation.
Use
VariantPluginContentForm::classNow the methods in this trait refer to a property that doesn't exist.
This could have just changed one line, not 3
That not how mocks are supposed to work.
Double semi-colon.
The entity manager is deprecated. Remove all code referencing it.
Use
Page::classWhy would you remove test coverage from an API test in a UI only issue?
Same as above. No functional tests should be altered for UI only changes.
Comment #116
juampynr commentedThanks for the feedback @tim.plunkett. I would like to jump into a hangout with you and @EclipseGc to discuss the scope of this issue. I am all in for reducing it. Here are some responses:
1. Fine for me. Removed it. I am not creating an issue yet as I don't see under which scenario this would be needed since the variant data is stored in temporary store until the user clicks Save or Update and Save.
2. I changed this to empty() because the default value of the contexts array should be [] and not NULL. This is how other classes such as ContextAwarePluginBase or ConditionPluginCollection do it. Am I missing something? Also, having a NULL value by default was causing an error after adding a variant.
3. Removed. Does nothing.
4. Explained at point number 2.
5. Removed change.
6. I changed the order intentionally so when you edit a variant, Page parameters are listed first and then variant contexts second. See the following screenshot:
This makes more sense to me but I may be missing something. Can you confirm? This is why I made adjustments at the related unit test.
7. Removed.
8. I couldn't find any of the parents doing this. I will leave it there for the moment.
9. Noted. I will change it once I get tests passing.
10. Changed.
11. Restored property.
12. Adjusted.
13. The patch was already like this and I am not sure at what the change is attempting to do. I have removed it and now the test fails so I will investigate what is wrong with it.
14. Fixed.
15. Removed. It was needed due to the Page::load() statement removed in point 5.
16. That line was removed in point 15.
17. The method changed now that it pulls data from tempstore and merges contexts from the Page and the Variant. I have restored the test though because I need to understand better Unit tests to adjust it.
18. The patch modifies the method, hence the change in the test.
I am now debugging the following error when you open the Content section of a variant:
Comment #118
yanniboi commented@Juampy
8. HttpStatusCodeDisplayVariant extends VariantBase extends PluginBase which uses the DependencySerializationTrait. DependencySerializationTrait provides the __sleep() method.
Comment #119
andrewbelcher commented1. We can do this manually in our wizard for now with an @todo and a separate issue to do it upstream, pending agreement.
6. the reason for that order is precedence. In
array_merge()the latter override keys in the former. If there were duplicated keys, page should always take precedence. To solve the order, I would suggest switching to$page_contexts + $static_contextsas this will give you the right order and precedence.This could easily be done in a separate issue and we can ignore the impact on UI in the mean time. Could probably do with test coverage for both order and precedence...
I think generally I agree with @tim.plunkett that we shouldn't be making changes to things in page manager (as opposed to UI) and things that do need changing should be in separate issues.
On that note, I've just realised my patch in #109 introduces UI code into p_m. I'll take a look tomorrow and see if I can find a way around that...
Comment #120
juampynr commentedGot it now: TypedData.php is the class that implements the method that sets the serviceIds (stringTranslation being one of them). When serializing, serviceIds are unset(). Thanks @tim.plunkett and @yanniboi! This patch removes a couple instances that use it.
I am still debugging this weird error:
@andrewbelcher, I will look at your feedback at #119 for merging page and variant contexts in a bit.
Comment #122
juampynr commentedRestoring #115-1 as otherwise page variants don't get saved when you click on Update and save or Save.
Comment #124
andrewbelcher commented@juampynr Rather than restoring that, you could do something like this in
\Drupal\page_manager_ui\Wizard\PageWizardBase::finish:I would also be inclined to change
\Drupal\page_manager_ui\Wizard\PageEditWizard::finishto:Even if we move the first bit into
\Drupal\page_manager\Entity\Page::postSave, the second bit deletes the variants before they are saved by eitherparent::finish()orPage::postSave(). Using::removeVariant()is necessary as it removes it from thePage::$variantsproperty, but that is also better as it means other things wont find it (and potentially re-save it) by callingPage::getVariants(). Even better still would be to store only the variant id in$cached_values['deleted_variants']rather than the whole variant object, as that's also a bit unnecessary.Comment #125
juampynr commentedFixed a couple things here:
* Errors when adding and editing contexts for a variant (the variant machine_name was not being passed on).
* Restored the __sleep() method for BlockDisplayVariant as it is not been called as we expected at #120. Without this, a block variant with an entity:node context that points to a node crashes when you click on "Content", as it tries to store stringTranslation into the tempstore.
Comment #127
juampynr commentedHere I have adjusted the finish() methods based on @andrewbelcher's suggestion at #124. I just had to make a small adjustment at page::removeVariant() for this to work. Thanks @andrewbelcher!
Comment #129
andrewbelcher commented@juampynr: Got two patches here.
update_for_2690047-2550879.patch is the fix for fatal errors on the add wizard (due to unsaved page) and is dependent on #2690047: Allow setting the Page on a PageVariant. Should solve lots of issues in the add process - particularly around context as that merges in things from the parent page.
filter_core_variants-2550879.patch applies the fix you've already done elsewhere to exclude the core display variant plugins from the selection - think this instance got missed.
Comment #130
yanniboi commented@jaumpy, did you remove this at some point? We dont want this anymore :)
Comment #131
andrewbelcher commentedSo a few bits that I've noticed (I'm on latest but one patch with my add fixes applied - though from the interdiff I don't think anything touches these):
I think some of these also apply to the edit wizard.
Comment #132
yanniboi commentedOk, so my patch replaces the Add variant form on a Page with the Add variant wizard.
Changes:
"{$page->id()}-{$variant_plugin->id()}-{$delta}"pattern"Comment #133
yanniboi commentedOops! I committed some changes to PageVariant and PageVariantInterface.
I have moved those changes out into a blocker issue here: #2690205: Allow Page Variant Plugin to be set after the entity is created
Comment #134
andrewbelcher commentedSo @EclipseGc and I spent a little while looking at how to solve the link template issue for wizards, which led to introducing
Page::urlRouteParameters(). While this solved the issue, it brought page_manager_ui information intoPagewhich is far from clean or nice.So I've put some work into CTools to allow us to construct the route in a way that is suitable for a link template. That patch can be found in #2690211: Allow link templates for wizards. I've attached a patch that applies to #122 (I can rebase it if/when we're ready for it to go in) which refactors this patch to use that so we can see the changes it makes.
Comment #135
juampynr commentedHere I am re-uploading @yanniboi's patch at #132 to see how it affects the existing tests. Notice that I chose this one instead of #133 because I am hesitant to depend on extra issues to get this patch in for the following reasons:
1. The patch is already big and complex enough to create additional moving parts.
2. If the patch depends on additional issues, then tests will fail abruptly and we won't be able to have a way to measure progress by reducing the number of failed assertions.
I want to reach with all of you to a patch that takes us from point A (a stable UI that does not use the wizard) to point B (a stable UI that uses the wizard). I must be missing something because I don't understand the reasoning behind creating extra issues for the bits of the patch that change the page_manager classes.
While tests run, I will test the patch manually and go over @andrewbelcher's mini-patches and apply them on top.
Comment #137
juampynr commentedThis patch adds @andrewbelcher's suggestions at #129. One of the patches in that comment was already part of the patch, hence it is not visible at the interdiff.
Comment #139
juampynr commentedHere are a few changes based on @andrewbelcher's feedback at #131:
Changed.
Changed.
I need to look this into more depth.
I could not reproduce this issue.
Comment #141
juampynr commentedHere I have adjusted the optional steps when you add a new page: the wizard was always showing the page parameters step even when you did not selected it.
The failing assertions at StaticContext test happen because there is a weird redirection after adding a context. It can be reproduced through the following steps:
1. Click on add Page.
2. Select Block Page for variant type and check "Variant contexts".
3. In the next step, click on Add new context, which pops up a dialog.
4. Fill out the fields and click Save.
Expected: the dialog closes and the context is added to the step.
Actual: the page redirects to the Page general form.
It seems that the Add Context form is not handling the Ajax request well and therefore is setting a redirection. Tomorrow I will debug what is going on.
Comment #143
eclipsegc commentedI have a working context step that I'm almost ready to add into ctools, I was going to get some test coverage for it first, but if you're in need I can clear up the patch in the morning and pass it along.
Eclipse
Comment #144
andrewbelcher commented@juampynr RE #139.4 @yanniboi pointed out to me that you'd already fixed that in the patch before my post :)
For me, on the separate issues thing, it's because this is a UI task. Generally that should be possible without making changes to non-UI code. Changes to things like
PageandPageVariantetc, due to the fact that these power the actual front end rendering of things, need careful testing as they could break existing sites that depend on it. UI changes don't have as significant an impact. A UI issue wont necessarily get as much visibility...Also, having other things separated out into other issues, it makes this patch smaller and easier to review! I suppose an alternative would be to include the non UI changes in a separate patch so it can be tested/reviewed a bit easier?
Comment #145
juampynr commentedNow I understood why PageVariant::contexts has an initial value of NULL: it is so it can be lazy loaded. I have removed the silly changes that I did to PageVariantTest.php and now that unit test passes. I also reverted back to the original order in which page and variant contexts merge (page ones take precedence when there is a conflict), as suggested by @andrewbelcher at #119.
Comment #147
andrewbelcher commentedAs per #145, I have opened #2691391: PageVariant::getContext should order page then variant to deal with that separately. It can just be out of order for now in our UI...
Comment #148
juampynr commentedThis patch fixes the failed assertions at PageAdminTests now that the Parameters step when adding a new page only shows up when you select it at the first step. I fixed this logic at #141.
Comment #150
juampynr commentedThis patch fixes the failing assertion at PageTest.php. The reason why it needs to set the weight is because the patch removes Page::variantSortHelper() and instead leverages ConfigEntity::sort(), which requires the $weight property to be public, as it accesses it directly when sorting.
Comment #152
juampynr commentedThis patch fixes the StaticContextTest.php assertions. There were a few wrong URL paths plus a bug on StaticContextConfigure::getParentRoute() that was causing a weird redirection when adding a new page.
Comment #154
juampynr commentedJust did a hangout with @yanniboi. Here is a summary of what we are working on:
* He will continue working on fixing the config_translation issues, which are causing the remaining 2 test failures.
* I am debugging why the schema of access conditions and selection criteria is not valid (discovered this using the config_inspector module).
* @EclipseGc is working in making ContextConfigure to use ManageContext (from CTools), which will simplify things considerably.
Comment #155
yanniboi commentedAttaching patch to fix config translation.
In short, config_translation builds a lot of routes and menu items under the 'edit-form' link template for a config entity. Since page manager works a little differently to other config entities (ie. using the ctools wizard) I have had to make some alters to make sure that all the required routes exist, work, and the expected parameters are available (ie, machine_name and step, instead of just page).
We probably want to tidy this up later (eg. have variant translation included in the page translation UI rather than seperate) but this is a simple implementation that passes tests and doesn't have any feature regression.
I also moved the existing PageVariantConfigMapper class from page_manager to page_manager_ui, because these are all UI components and leaving part of the functionality in page_manager is confusing. We may also want to move PageManagerConfigTranslationTest to page_manager_ui for the same reason as this test does nothing without the page_manager_ui module enabled, but I have left if where it is for now.
Go Go Passing Tests!! [fingers crossed...]
Comment #157
juampynr commentedRemoved the changes maded to tests/src/Unit/PageVariantTest.php (I removed them already at #145). Now tests should pass.
Comment #158
juampynr commentedTests are passing OMGWTFBBK!!!!!!
Pending tasks:
[ ] Fix weird redirections when you click Update at Contexts or Selection Criteria (working on it now).
[ ] Fix schema errors on Selection Criteria and Access Conditions (add a few to a variant and then check it with config_inspector).
[ ] Full review by @EclipseGc and @andrewbelcher.
Comment #159
andrewbelcher commentedDon't hate me, but I wonder if adding in the description would be better in a separate issue? Don't think it matters too much though, it is very much a UI thing...
I'm guessing this is fixing the invalid config schema? I think this should definitely be a separate issue and the config test should be updated to make sure it doesn't regress...
Do we need to add this as part of this patch? If so, perhaps it should be in p_m_ui?
I thought we decided we'd deal with this at a wizard level for now with an @todo referencing an issue to make it automatic?
Is this change needed? An empty array will be typecast to FALSE anyway I think.
This can surely go?
I think I would prefer to see this in as a separate issue with test coverage.
Likewise for this...
I think this change is out of scope... (And I think we also changed the property visibility to make this work so that could go as well)
Is this change necessary for our UI changes? If not, I think we should put it in a separate issue...
I think this needs documenting with an @todo for when #2690211: Allow link templates for wizards goes in.
I can't see anywhere this is used?
Can we mark this and related methods with an @fixme to remove when #2690047: Allow setting the Page on a PageVariant lands?
Do we need this for our UI changes?
Can this be marked with an @fixme to remove when #2690205: Allow Page Variant Plugin to be set after the entity is created is in?
This doesn't seem worth including with this patch (it's identical functionally).
Is this needed for our UI stuff? I'm guessing this and the other __sleep() bits are due to the fact we store it in the tempstore? Perhaps we could separate out these changes into another issue with test coverage?
Why do we need to get the tempstore from the PageVariant?
Seems a shame to be adding this UI stuff into p_m, but I can't see an obvious way around it. It's fairly dangerous as it is, because VariantPluginContentForm in in p_m_ui and so may not be available even if p_m is. In fact, with the use statement, wont this fatal if p_m_ui is not enabled?
At least we need to find a way for this to live here without fatalling (can we use the full class name in a string and drop the use and wrap in a moduleExists()?).
Better would be an 'upstream' fix, perhaps a trait in CTools which provides a default implementation with a hook that p_m_ui could implement?
Or as tim.plunkett suggested, put it in as an annotation which can then be altered?
Should we be removing this?
Perhaps all of this (and the other UI dependent web tests) would be better in p_m_ui? Can always do that as a follow up issue though!
Why do we need to make this change?
Comment #160
juampynr commentedHere I am fixing the weird redirections that happen when you click Update at Contexts or Selection criteria that I described at #158. I will now go through @andrewbelcher's feedback at #159 before moving on to debug the schema validation errors for Access and Selection conditions.
Comment #162
juampynr commentedHere are my answers for @andrewbelcher's feedback at #159 plus a patch with the changes:
1. Can’t remove it. If we do, tests fail with the following error:
Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for page_manager.page.node_view with the following errors: page_manager.page.node_view:description missing schema inDrupal\Core\Config\Testing\ConfigSchemaChecker->onConfigSave() (line 98 of/var/www/drupal8/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php).2. If we remove that from the schema, then this issue’s test won’t pass as the test won’t be able to test these variants. I would like to hear from @EclipseGC on whether we take this out of the patch or we create a new issue.
3. Makes sense. Moved.
4. Not sure if we need this. We should remove it and run tests to see if they fail.
5. Removed.
6. Removed.
7. I will try removing it in a following post to see if tests pass. If they do, I will remove it.
8. We need this one for tests to pass. @EclipseGC, shall we get this in or create anther issue?
9. Same as 7.
10. I will try removing it and see if tests pass.
11. Added @fixme.
12. Me neither. Removed.
13. Added reference at the property.
14. Not sure, I will test it.
15. Added @fixme.
16. Agree. Removed.
17. Yes, this is needed or otherwise you get errors after adding a context that points to an entity and clicking at a block variant’s Contents section.
18. No idea, we certainly can refactor this but it needs further testing. Leaving it for a second pass of changes.
19. The annotation approach seems the best. Let’s wait for @EclipseGc to see what he thinks we should do at this point.
20. It is used by tests. Not a huge win, but I guess that this trait was the start of further methods to be moved there.
21. Agree. Moved.
22. Explained at https://www.drupal.org/node/2550879#comment-10991695
Comment #163
tim.plunkettThe patch is too big and has a massive scope. Everything that @andrewbelcher called out (and more) should be split to a new issue.
Comment #164
eclipsegc commented1.) Can we produce this same failure without this patch? If so it looks like an easy fix as a separate issue and reduces the weight of this one.
2.) If the tests that cause a failure around that are included in this issues, I'd have to be convinced of how easily they can be extracted before I'd support a separate issue for them.
8.) Is there a demonstrable failure in the current code around this? are we missing some test coverage as it concerns this issue. Sometimes when we re-architect something significantly we find other issues that are more obvious a second time around. I personally dislike breaking those out into separate issues since that tends to slow the progress of the primary issue which uncovered them in the first place. So long as we have sufficient test coverage for the problem, I'm fine with leaving it in this issue. Again, my comments in 2.) are the litmus test. If it's easy to file as a separate issue, there's no reason not to do so, if it's integral to what we're doing here, leave it here.
10.) I thought we already removed page executable from the code base. Will recheck and edumicate myself.
19.) The 'use' won't fatal but if it's actually invoked in the class anywhere that'll fatal. This is part of the complication that comes with extracting aspects of this into a separate UI module. The variant should exist with whatever classes are used to configure it, perhaps that means we put the variant into a submodule and include the steps there. The flip side to this is that if this particular variant doesn't require multi-step configuration, then we should package a step with pm_ui that calls to the plugin's normal config form method. Let's do a hangout tomorrow on this topic and make a decision.
The other bullet points seem to indicate that juampy is either on board or about to test one way or the other, so I didn't venture an opinion. In short, this patch is huge, but then so is the problem it's solving, so there's going to be some wide-spread "scope creep" associate with it. As I mentioned in my comments on 8, if the problem is demonstrably related to introducing the wizard and we have test coverage for it, I'm fine with it in this patch. That being said, if a thing is especially easy to extract from this patch, then that's a win all around. I'm doing my own review of this patch now and will post again when that's finished.
Eclipse
Comment #165
yanniboi commented@andrewbelcher and I went through the patch last night and created a bunch of subissues:
1. #2692325: Add description to Page
2. #2692327: Add schema for block_page and simple_page plugin types
7. #2692397: Adding/removing variants leaves Page::$variants out of date
8. #2692347: removeVariant() should remove variant from page and not just delete the variant.
9. #2692353: Swap variantSortHelper() for ConfigEntity::sort()
21. #2692313: Move UI dependent tests into page_manager_ui
I am going to flesh them out now and post patches. They all have the pm-ui-blocker tag (https://www.drupal.org/project/issues/search/page_manager?project_issue_...) and could do with priority reviewing and committing :)
Comment #166
yanniboi commented2. Berdir posts in #2692327-2: Add schema for block_page and simple_page plugin types that we don't really support block_page and simple_page. I think we should have a closer look at why the test is failing (which test btw @juampy?) rather than adding schema for something that we don't need.
Comment #167
juampynr commentedHere is the second round at @andrewbelcher's feedback at #159. The elements with a strike through have been answered at #162.
1. Can’t remove it. If we do, tests fail with the following error:Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for page_manager.page.node_view with the following errors: page_manager.page.node_view:description missing schema inDrupal\Core\Config\Testing\ConfigSchemaChecker->onConfigSave() (line 98 of/var/www/drupal8/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php).
2. Removed. These were needed while we were accidentally exposing these variants.
3. Makes sense. Moved.4. Removed. Tests pass.
5. Removed.6. Removed.
7, 8 and 9: Tests fail: variants dissapear or appear unordered randomly. This code fixes it.
10. Needed for tests to pass. Otherwise we get errors such as “UnexpectedValueException: The page variant has no associated page”
11. Added @fixme.12. Me neither. Removed.
13. Added reference at the property.
14. Pending to test it.
15. Added @fixme.16. Agree. Removed.
17. Yes, this is needed or otherwise you get errors after adding a context that points to an entity and clicking at a block variant’s Contents section.18. Pending to test what can we do here.
19. Pending to test it.
20. It is used by tests. Not a huge win, but I guess that this trait was the start of further methods to be moved there.
21. Agree. Moved.22. Explained at https://www.drupal.org/node/2550879#comment-10991695Comment #168
andrewbelcher commented@juampynr Excellent work, really nice to see the patch getting smaller and easier to understand!
1: Yes, this needs to stay in for now, but could have an
@fixme: Remove when https://www.drupal.org/node/2692325 is fixed.as [#2692325 ] addresses it separately.7, 8 & 9: These are all deal with in #2692397: Adding/removing variants leaves Page::$variants out of date, so could have
@fixme: Remove when https://www.drupal.org/node/2692397 is fixed..10: I think this should probably have a separate issue with test coverage. The problem is about serializing them for the tempstore I think. I'll spin up a separate issue for it.
14, 18: Cool - I'll leave it to you to have a look and see what they're about.
19: So I expect this could probably be done as part of this issue. We can either have it in the annotation or move this into p_m_ui using
hook_display_variant_plugin_alter()to add the information. Other modules can then declare it directly in their annotation to support p_m_ui. I don't think it will be easy to update the annotation definition though, as it is a core annotation.I do wonder whether it's worth making the name more abstract than
wizardOperationsthough as an alternative UI/use for plugins will probably still need to provide configuration forms for their variant plugins. Perhaps we can do something likeconfiguration_forms?Comment #169
juampynr commentedThis patch fixes a bug on the Ajax request that loads the form to add a new condition for Selection Criteria. Tests are not catching this one because they are not adding conditions using the Ajax interactions. I am adding here a fix plus a test that currently fails because the Ajax response is not showing up. Am I doing something wrong here?
Comment #171
juampynr commentedThis patch fixes the failing test by inspecting the result of the AJAX request.
Comment #172
andrewbelcher commentedClosing #2692313: Move UI dependent tests into page_manager_ui in favour of #2659638: Split StaticContextTest into one depending on page_manager_ui and one testing the API. Also, I think related is more accurate anyway as we can go ahead without it.
Comment #173
juampynr commentedThird and last round at @andrewbelcher's feedback at #159. The elements with a strike through have been answered at #162.
1. Added @fixme.
2. Removed. These were needed while we were accidentally exposing these variants.
3. Makes sense. Moved.4. Removed. Tests pass.
5. Removed.6. Removed.
7, 8 and 9: Added @fixme.
10. Needed for tests to pass. Otherwise we get errors such as “UnexpectedValueException: The page variant has no associated page”
11. Added @fixme.12. Me neither. Removed.
13. Added reference at the property.
14. Pending to test it.
15. Added @fixme.16. Agree. Removed.
17. Yes, this is needed or otherwise you get errors after adding a context that points to an entity and clicking at a block variant’s Contents section.18. Removed. Not used.
19. I am hesitant to change this as it may take me a while to figure out how to do it. If it is a blocker, then I will work on it.
20. It is used by tests. Not a huge win, but I guess that this trait was the start of further methods to be moved there.
21. Agree. Moved.22. Explained at https://www.drupal.org/node/2550879#comment-10991695Comment #174
juampynr commentedRe-rolling after #2692397: Adding/removing variants leaves Page::$variants out of date got committed.
Comment #175
juampynr commented@EclipseGc, I looked at removing Page parameters from the "Optional steps" field when creating a variant and realized that it will require further work because:
* Simply removing it from the list of optional steps make it mandatory, so it breaks tests because they don't expect this step. Should this be a follow up?
* It is not evaluating the path value and extracting its parameters. Should this be a follow up?
Comment #176
andrewbelcher commentedI think we should have it non optional but only show if there are parameters to configure. I think doing that and adding test coverage is in scope.
Comment #177
eclipsegc commentedThis seems like a regression, don't we need to get the contexts from the variant since that's where they're stored?
This route is meant to be reusable so odds are the tempstore id should be passed in as well.
I assume that we don't have the page_variant here to ask for contexts?
This looks like a prime candidate for a ctools patch, but fair enough for this patch for now, we can file a follow up.
As mentioned previously, page parameter configuration is only available when there are slugs in the path.
LOL, ok sure.
Do we have test coverage for changing our mind about the type of variant we're creating mid-wizard?
Yup, here it is again. Considering that the tempstore is already updated before this is hit, I think this is an oversight in the ctools code.
No newline!
if you do these as use statements in the header of the file you can just do PageVariantContextsForm::class which is a lot nicer to read.
I don't think the "Configure variant" step AND the steps of the plugin provided wizard steps should co-exist, so if the plugin is an instanceof the ContextAwareVariantInterface, then we should remove the "Configure variant" step.
Another of those situations where we can do ClassName::class
Pretty sure this doesn't exist anymore and we can stop doing this.
Do we still need this with the way #2692397: Adding/removing variants leaves Page::$variants out of date is working?
Of this list, the most important issues are 1 and 11. The rest are all pretty negotiable or simply questions. Overall, this patch is looking really really good, I think we're in the home stretch.
Eclipse
Comment #178
eclipsegc commentedSo I spent a bit of time getting this working with the ctools context steps. I'm just providing an interdiff for record-keeping and if anyone wants to play with it. Most of the patch is red (because the code is mostly in ctools). The context description doesn't work yet. I'll be working on that a bit when I get out of bed. Schema needs to change. If CTools's providing the forms then I think it makes sense to move the schema there. I'll post when I have more.
Eclipse
Comment #179
andrewbelcher commentedIn answer to some of @EclipseGc's comments:
2: This was one of the things on my list to look at - it needs to have things passed in. My understanding of re-usable is that we're talking about block variant plugin across different entities (e.g. Page, Mini Panel, Panelizer)?
3: If my understanding about re-usability above is right, the this should be working with the variant plugin rather than the page variant?
Also, on both 2 and 3: I think there is some work getting it to make use of #2604178: Modify core block UI to seperate blocks into categories with tabs (I think that's the right issue?)...
4 & 8: Is this not the responsibility of
PageEditWizardwhich adds those submit buttons rather than CTools?7: I think in edit mode it's not a big deal as we don't really go back/forward, but we probably need to think and test (with actual tests) going back as well as forward in add mode...
11: Is the configure variant step not about setting name etc that are about the page variant rather than the variant plugin. If we drop this step, anything stored directly on the variant will be un-editable. I think the change that needs to happen is making it so that if the variant provides wizard operations,
PageVariantConfigureFormdoesn't include the variant settings.13: I'm looking at serialization issues with the hope of removing/spinning off into another issue...
14: You are correct, that can go now.
Comment #180
juampynr commentedThanks for the feedback. I will go through it throughout the day. I am traveling today but I can find time to work on some of it.
Comment #181
juampynr commentedI just saw how parameters work in 8.x.1.x. I will focus in fixing the path so:
[ ] When adding a page, parameters is not listed as an optional step.
[ ] The parameters step shows up when there are parameters in the path.
[ ] The parameter step lists parameters and allows to assign contexts to them.
[ ] When editing a page, parameters can be edited at "Page parameters".
[ ] Page parameters are read only at a variant's Contexts section.
[ ] Add tests to cover the above.
Comment #182
juampynr commentedI need some guidance for managing parameters: I have fixed the following points from my above list:
[X] When adding a page, parameters is not listed as an optional step.
[X] The parameters step shows up when there are parameters in the path.
[X] The parameter step lists parameters and allows to assign contexts to them.
[X] When editing a page, parameters can be edited at "Page parameters".
[X] Page parameters are read only at a variant's Contexts section.
[ ] Add tests to cover the above.
The tests fail because when you are adding a variant with a block display, the Node block does not show up even though you assigned the Node context to the {node} parameter. Is this assumption correct? If you look at PageParametersTest.php you will see what I am trying to do.
Comment #184
eclipsegc commentedI'll look at this first thing in the morning.
Eclipse
Comment #185
juampynr commentedI did some debugging and now I know what is happening at #182: we cannot access to the Node context in the Add Page wizard because we have to save the page so a route is created. This is why PageManagerRoutes:: Since the variant has not been saved yet so the event subscriber RouteParamContext can't load the route (and therefore, create a Context object).
I have adjusted the test PageParametersTest.php, where you can see this behavior. I think that there is nothing that we can do here. Now tests pass back again.
Tomorrow I will go through @EclipseGc's feedback at #177.
Comment #186
juampynr commentedHere I have removed StaticContextAddForm.php, StaticContextEditForm.php and StaticContextFormBase.php because they have been replaced by StaticContextConfigure.php and StaticContextDelete.php.
Comment #187
andrewbelcher commentedI think we need to find a solution. Can we not return empty context when there is none available or something like that? That way the variant has info about what it could expect?
Comment #188
juampynr commented@andrewbelcher, I did some manual testing with the attached snippet and things seem to work as expected. What I am doing is simply inspecting the page parameters without validating them against a route if the page is new. I need to adjust tests, which will do later in the day.
Comment #189
juampynr commentedI think that I have fixed this. Tests pass and we now can access page contexts during the Add Page Wizard.
Now I will go through @EclipseGc's feedback at #177 and @andrewbelcher's response to it at #179.
Comment #190
eclipsegc commentedThat will always return boolean or NULL.
We can't only determine params as context on new. Params could be changed.
I've been working on this section too, I'll try to apply all your interdiffs since I started working and get something up today.
Eclipse
Comment #191
juampynr commentedFirst round at @EclipseGc's feedback at #177. Here I:
* Use ::class statements.
* Remove Page::__sleep().
* Revert PageVariant->weight accessor to protected.
Here are some answers to each point:
Pending. I have not looked at this yet.
Pending. I have not looked at this yet.
Pending. I have not looked at this yet.
Ok, ignoring it until then.
Pending. I have not looked at this yet.
Pending. I have not looked at this yet.
Pending. I have not looked at this yet.
Pending. I have not looked at this yet.
Removed whole test as it was not testing anything.
Changed these and other instances.
Pending. I have not looked at this yet.
Fixed this and many other instances in the patch.
Removed.
Removed.
Comment #192
eclipsegc commentedThis is a cross-post to 191, so it does not include the interdiff from there.
Changes:
Locally this all passes tests, I'm posting this patch first and then spending some time updating ctools to match, so I expect these tests to fail for the time being. Also, I'm not sure what voodoo tim is using to map values into parameters, but it appears to "just work" for the moment and I'm happy about that. :-D Need to probably figure out the nuances though.
I'll try to get this merged with 191 soon and clean up the outstanding issues I know I still have.
Eclipse
Comment #194
eclipsegc commentedOk, the passing tests are because of my new ctools release today (which still has a bug in tests that I'll fix tomorrow). I'll probably begin working on merging juampy's latest work with my own tomorrow morning.
Eclipse
Comment #195
juampynr commentedI have some time today so I will give you a hand on that now. I will post a patch later. It feels that we are getting close to the end!
Comment #196
juampynr commentedHere it is. I will now go through a second round on the feedback at #177 plus @andrewbelcher's on #179.
Comment #197
juampynr commentedSecond round at @EclipseGc's feedback. Here I:
* Adjust docblocks.
* Remove unused title callback.
* Add missing tempstore_id to page callback.
Below is the full report with my responses. The only one pending is number 3:
This callback is not used. Removed.
Adjusted callback.
Pending. I have not looked at this yet.
Ok, ignoring it until then.
This is gone already.
This is gone.
Pending. I have not looked at this yet.
OK. Ignoring it then.
Removed whole test as it was not testing anything.
Changed these and other instances.
I looked at this and I don't understand why: the block variant's configure step lets you set the page title. Don't we want that?
Fixed this and many other instances in the patch.
Removed.
Removed.
Comment #198
eclipsegc commentedIgnore 3, Andrew pointed out the flaw in my logic.
I'm giving the whole patch a huge manual workout, and if everything looks good, I'm going to be focussing in on 11 to make sure that I'm right/wrong about it and then take action appropriately.
Eclipse
Comment #199
tim.plunkettIf you change getParameters, why do you need to change filterParemeters as well?
reverse x3? Are we sure that's needed? Is there test coverage for it?
Out of scope
Pick one way to do it and stick to it
Missing {@inheritdoc}. Also for the 100th time, why do we need this? Where is the explicit test coverage for it's addition? Why isn't it a separate issue?
Any way for this to be added on somehow by the UI?
Comment #200
andrewbelcher commented@tim.plunkett the last 2 points I'm working on (__sleep stuff and moving wizard stuff into annotations/page_manager_ui). @juampynr, could you note that with
// @fixme: andrewbelcher working on this.for both?I've spun off an issue with test coverage #2691391: PageVariant::getContext should order page then variant. A review there would be great. @juampynr: can we remove that change from the patch? Although it confuses the UI it certainly doesn't block this and can be dealt with even after this gets committed...
Comment #201
eclipsegc commented199.1:
The filter is only done on save, this means that if you were to remove configured params from the url and then add them back in without update & save/finish, then you wouldn't lose the configuration. The config is only thrown away at "save" so that we have a little protection for anyone who does something silly like that, but we don't tote around all the params ever configured.
199.2:
Yeah, I'm SUPER open to other options here, and I know it's ugly, however this is actually a little bit of test coverage for this as there is a mocked set of context expectations that expect a specific order, so yes there's test coverage.
199.3:
Yeah, I added that stuff to ctools and didn't remove it here yet, but sure that could absolutely be a follow up.
199.4:
Going forward, let's settle on how PageVariant does this. As I recall that has an added layer of protection.
199.5:
Yeah, these inherit dependency serialization trait, however, as I recall, this was blowing up when the plugin ended up in the tempstore (as it will necessarily do once in a while), so we had to hack around this limitation. Perhaps that's a core bug? Perhaps we just did something wrong. We should remove this and test it. I'll include the inheritdoc regardless in my next patch.
199.6:
I'm not entirely clear on what you're asking here. The variant is just stating that there's another step in its configuration beyond the step that calls its own config form method. What are you asking?
Eclipse
Comment #202
eclipsegc commentedOk, I worked on this patch all day hunting through anything that would functionally block it. Unfortunately I found a bit, however I also fixed most of it.
I was really hoping to push this up today, but given the size of the interdiff and the few outstanding issues here it deserves a little more time. If anyone has insights into these issues let me know, but for the time being I think we should establish the last bit of test coverage we need for the Add Variant Wizard.
Eclipse
Comment #203
yanniboi commented@EclipseGc I've had a look at the differences in PageBlockDisplayVariant::__sleep()
For reference, the 2 versions are as follows:
basically the second one (which doesn't cause tests to fail) is ever so slightly different. If array_search does not find stringTranslation it returns false.
unset($vars[false])equates tounset($vars[0])which unsets the first element in the array.When StaticContextTest is failing, it is failing while settings the tempstore as part of VariantPluginContentForm::buildForm() during the 'variant content' step of the add page wizard with the error:
Settings can not be serialized. This probably means you are serializing an object that has an indirect reference to the Settings object. Adjust your code so that is not necessary.This error does not occur when
unset($vars[false])removes 'context' as the first element in the $vars array. I have no idea if this is desired behaviour, but the test is passing when this happens so it needs another looking at.Comment #204
andrewbelcher commentedAs mentioned in #200 - I've been working on the
__sleepissue - got tests :) Some of I think is actually best solved in CTools, but let me get my stuff together and can start an issue for it and go from there. It's certainly not a UI issue, so let's work round it for now with @fixme's to remove it when it's resolved.Comment #205
yanniboi commentedTiny typo fix 'acess' => 'access'
Comment #206
yanniboi commentedAlso I spotted something weird with the context selection dropdown.
It seems for a lot of the field type contexts (boolean, email, entity reference, etc.) there are 2 options in the drop down (ie. 'boolean' and 'field_item:boolean'). Then when saving the page (and by extension variant) with any of the 'field_item:*' contexts, it throws an exception:
Drupal\Core\Config\UnsupportedDataTypeConfigException: Invalid data type for config element page_manager.page_variant.foo-block_display-0:static_context.b3.value in Drupal\Core\Config\StorableConfigBase->castValue() (line 212 of core/lib/Drupal/Core/Config/StorableConfigBase.php).The non-'field_item' contexts work fine.
This is probably a follow up issue, but I thought I would flag it.
Comment #207
eclipsegc commentedYanni,
Can you file 206 against ctools?
Eclipse
Comment #208
juampynr commentedThere are a few regressions with the latest changes so 14 assertions failed when I ran tests locally. I fixed them down to 5 by adding an statement at Page::removeVariant().
There is a weird behavior when you add a new variant to a page that had one already: the old variant disappears. I am debugging this at the moment.
Comment #210
juampynr commentedAnd this is the reason why existing page variants are lost when a new one is added see how $cached_values is not available at the following build method from
PageVariantAddWizardForm.php:Comment #211
eclipsegc commentedJuampy,
Are you working on an older version of the code? I don't get the error you're talking about and my local version of Page has the one line you've added here already.
Eclipse
Comment #212
eclipsegc commentedOk, this should fix the sleep related issues. I believe andrew is expounding on those in another issue, but we have an answer as it relates to this issue for now and will get better coverage in that issue.
Eclipse
Comment #213
eclipsegc commentedoops
Comment #226
andrewbelcher commentedOk, I've filed #2696283: Unable to serialize objects to fix the
__sleep()/serialization issues. I suggest we update our__sleep()changes to match that patch and mark those changes with an@fixme: Remove when https://www.drupal.org/node/2696283 is fixed.?Comment #227
samuel.mortensonDoing a quick manual review:
Comment #228
eclipsegc commentedTest coverage for the context and selection criteria steps in the Add Variant wizard.
Hopped on a hangout with mortenson re:227:
Comment #229
eclipsegc commentedFix for 227.1
Comment #230
eclipsegc commented227.2 is reproduce-able in HEAD without the wizard patch, so I'm calling that out of scope.
Comment #231
eclipsegc commentedI could not reproduce 227.3 Maybe we can do a hangout tomorrow and nail this down?
Eclipse
Comment #232
andrewbelcher commentedAs per conversation with @EclipseGc, I've opened #2696683: Update wizard to support link templates as a follow up and removed the
pm-ui-blockertag from #2690211: Allow link templates for wizards.Comment #233
andrewbelcher commentedI've updated the patch to include the relevant parts of the patches from the blocking child issues and @fixme's at ever:
I have also included a patch which is filtered down to everything non UI and not covered by the above issues. This will help us see what is being changed at the API level to make reviewing that easier...
Comment #235
andrewbelcher commentedHmm... interdiff didn't upload, here's to trying again!
Comment #236
andrewbelcher commentedA quick skim over the API changes:
These don't seem to be UI related? Have we just got better test coverage that is highlighting an existing issue? If so, we need to make sure we have API level tests, not just UI and that may warrant a separate issue...
@tim.plunkett mentioned this was very deliberately left in page_manager rather than page_manager_ui. I don't know any more detail than that, but that may be something we need to look at again. Was there an issue where that decision was made?
This looks like a good change to make as we don't want parameters left over from path changes. However, this will only change it for calls to
Page::getParameters(), so it will still be saved/exported with the incorrect data. I wonder if due to the various other connected bits, this would be better dealt with separately and with good reliable test coverage?Have we got any test coverage for this? Again, not really related to the UI changes. Does not having this cause test fails? If not it could be a non blocking separate issue?
Ok, so we do the same on
::preSave, perhaps we'd be better calling this before returning the params rather than duplicating the logic? We also need this on export (::toArray()I think) and test coverage...This (as the comments suggest) don't feel very nice. Is this all so we have context available before the route is created? Eugh... I'll try and have a ponder about this...
Can I suggest this either becomes an @fixme that we sort before this gets committed or an @todo with an issue link so it doesn't get lost/forgotten?
This is necessary because wizards don't currently support link templates. I've created a follow up for this #2696683: Update wizard to support link templates. I missed updating the @fixme to an @todo referencing that issue - could the next person to update the patch update that?
Is this necessary for the UI changes?
I think we should switch this to annotations... I've not got onto that yet. I will try and do it, but it could probably be done as a follow up. I suggest we include an @fixme and change that to @todo with a follow up issue if we don't get it done in time.
Is this change necessary for our UI changes?
Comment #237
juampynr commented@andrewbelcher, thanks for your changes on #233. They seem fine to me.
While looking at your feedback, I found a CTools bug that can be reproduced with the following steps:
1. Create a new page.
2. Add a block variant.
3. Click on Contexts and then Add new context.
4. Fill out the fields, then click submit:
Expected: the action context is added.
Actual: the form does not submit an the following error is logged:
"The 'entity:action' context is required and not present." at /var/www/drupal8/core/lib/Drupal/Core/Plugin/Context/Context.php line 76This is a CTools error. I have fixed it locally and will create an issue at the module's issue queue.
Comment #238
juampynr commentedJust created #2696819: Cannot add contexts whose entity ids are not numeric for the above bug that I found in CTools.
Comment #239
juampynr commentedI will let @EclipseGc answer to @andrewbelcher's feedback at #236 as some of his questions refer to work that was done before me joining so I don't have enough background to answer them.
Comment #240
juampynr commented@EclipseGc, @samuel.mortenson, I could not reproduce #227.3 either.
Comment #241
eclipsegc commentedThis does not include changes from 233, I will look at that next.
Mortenson and I spent an hour together today trying to figure out how to reproduce his issue from 227.3. Reproduce-able steps:
This _SEEMS_ to have something to do with block weights as it's just interaction with the block regions/weights that causes this issue. The only classes which touch the 'deleted_variants' key in the cached_values array are the Edit wizard, the reorder variants form and the delete variant form. Of those, only delete sets values on the deleted_variants key. I've done a pretty extensive amount of debugging on that class, and the values always look proper, so it is at some point AFTER the delete form is submitted that this is altered.
Typically, what we see is that it gets changes to 'current_key_value' => -1. I attempted to type check the values and only process those, however whatever is messing with the values seems to be doing it in an N-1 equations, so if I have:
Then only the value of key 1 will be affected. This means that old variants you've previously "deleted" during this tempstore session can show back up since they're no longer in your deleted variants key. This is all on very simplistic testing situations. Mortenson has screenshots of other data appearing in the cached values too, so we should solve this in the long term, however...
During all my testing, I never saw keys affected at all, and we only need (in all situations) the page variant's id, so I simply started storing them keyed by their entity id. This simplifies things a bit and means I don't care if the value is a page variant, -1 or foo, long as I have the id, that's all that matters.
All of this amounts to something somewhere, that is probably doing some sort of array_function() in a sloppy manner against $cached_values, and rather than doing what it's supposed to be doing, it's managing to target the deleted_variants key NOT by name. We should figure this out, but it doesn't seem like a blocker since you have to jump through quite a few hoops to make it happen, and this patch has a fix that will prevent it.
Eclipse
Comment #242
eclipsegc commentedRebased for other commits.
Eclipse
Comment #243
juampynr commentedJust created #2697587: Wizard API integration and posted there the commit by @yanniboi and @EclipseGc. I will help on testing and continuing the work on this patch so then I can use the variant to set Panelizer defaults.
Comment #244
andrewbelcher commentedThis patch addresses:
#236.7 by switching to an
@todoto remove as part of #2696683: Update wizard to support link templates.#236.10 by adding an
@fixmeto remove when the already existing issue #2684281: PageTestHelperTrait defines existing $container property get's fixed.It also fixes a whitespace issue the patch was introducing in
page_manager_ui/templates/page-manager-wizard-form.html.twig.I've also uploaded an updated diff that excludes the changes in
page_manager_uifor easy review.Comment #245
andrewbelcher commentedI've merged in the bits from #233which are still relevant after the other issues got committed. I've also un-postponed #2696283: Unable to serialize objects which has passed tests :) That leaves
@fixmes for just #2684281: PageTestHelperTrait defines existing $container property and #2696283: Unable to serialize objects.Comment #246
andrewbelcher commented@EclipseGc regarding #236.9 it looks to me like we have five options:
1. As is but without silent dependency
Which would mean wrapping
::getWizardOperationsin a check whetherpage_manager_uiis installed. This will mean that we still have all the UI definitions in the API code, but that it wont fatal if something else attempts to use that info.2. Have the API provide a hook for the UI to implement
This means we've still got some UI related code, but not including any actual definitions.
3. Switch entirely to annotations
This keeps the API stuff very clean as we don't need to even implement
PluginWizardInterface. However, it means we need to do a little more work in the wizard operations logic as we need to inspect the annotations etc. It also means we aren't re-using the nice generic nature ofPluginWizardInterface.4. Pull the information from annotations
::getWizardOperationscould inspect the annotation to see whether there are any wizard operations to make use of.page_manager_uican then use an alter to provide that information. This is similar to 2, but probably a more D8/OO approach.5. Have CTools provide a trait to pull from annotations
Exactly the same as 4, except it can live in CTools in a completely generic manner. Implementers can then decide whether they want to use annotations (use the trait) or provide via
::getWizardOperations((implement the interface). Then the only noise in the API is using the trait, which is basically a signifier that other modules can provide a wizard UI for this plugin.Comment #247
eclipsegc commentedResponding to 236:
We have UI coverage for the moment and that has to use the API. I agree we should have explicit coverage of the API, but let's do that in a follow up.
So, after a bit of discussion with various parties. 1.) As I understand it Tim's trying to prep pm for future changes he hopes to see in Core. 2.) I can appreciate this, but as it stands if there's no UI for editing your entity, there's no config translation and separation between pm and pm_ui complicates this to some degree as the PageVariant entity can't just assume it'll be displayed in a wizard since in fact it has no exclusive route specific to editing just it. 3.) Page Manager almost doesn't even work this way. You're unlikely to translate an existing variant and way way more likely to build a new variant for a specific language. I think we should file some follow ups on this specific to making that as easy as possible.
It won't be saved improperly because of ::filterParameters which cleans up during ::preSave().
I'm pretty sure removal of this causes test failures. I don't recall the specifics, but it's important to note that each variant caches contexts for itself so if the parameters are changed, the contexts need to be updated appropriate.
If someone calls toArray() on an unsaved entity, I don't have any sympathy for the values they get and preSave() cleans all this up so that it's saved correctly. For various other reasons, we actually want to hold onto data for params so that if they're accidentally removed, when they're re-added (during the same tempstore session) the user doesn't have to re-configure them. And yes, there is test coverage for the expected state of parameters after a save call that tests all of this code path.
This is the intersection of a couple issues. First, yes we have to generate contexts for parameters on a page we just defined. I can't very well expect users to actually save the page before I provide them contexts from their parameters for things like block placement or access/selection. Second, the ugliness involved here is that we can't differentiate between global contexts (current_user) and parameters defined by the page because the actual contexts are delivered to us by the event we're dispatching here. We need a more holistic solution for this, but I'm not delaying this patch on what is currently a special case of 1 (current user) and likely will only expand in the foreseeable future to 3 or 4 (including languages).
Looks like you handled that already.
It is necessary yes.
I agree, let's look at an Annotation based approach for this, but let's do it in a follow up. I realize this could cause issues if someone attempts to use these variant plugins in a wizard without enabling PM_UI, but realistically, the only variant that should be happening for is Panels, and it should contain all of its own steps. I don't think it very likely that we'll want to embed block_page in blocks or similar.
No, it's not necessary, but it makes reviewing the working-ness of this thing from a tests perspective SOOO much nicer, and I think the issue that's trying to solve this should probably move towards a getter based methodology, but I'd prefer not to hold this issue up further on it.
Eclipse
Comment #249
eclipsegc commentedAfter 7 months of effort from a crew of great contributors I'm calling this done. I've attached the committed patch.
Eclipse
Comment #250
tim.plunkettThis shouldn't have been committed, there were remaining @fixme and @todos, for example #2696283: Unable to serialize objects should have blocked this.
Missed the commit message, but giving myself credit for this as well because I did a ton of reviewing.
Comment #251
eclipsegc commentedIndeed you did, sorry I just copied what d.o generated. My bad.
Eclipse
Comment #253
damienmckenna