Here's the general problem from a low-level architecture stand-point:

  1. Page Manager is about creating routes and having variants attached
  2. The variants could be anything including plain HTTP responses - they don't have to know anything about blocks or layout
  3. 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)
  4. 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
  5. 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
  6. Also, we want to provide rich and dynamic UIs, however, from ConfigurablePluginInterface doing 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 way
  • Finish 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 HEAD
  • Get 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 page
  • After finishing the add wizard, we should jump right into the edit wizard
  • Update the tests to work with the new UI
  • Setting 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

CommentFileSizeAuthor
#249 2550879-247.patch281.17 KBeclipsegc
#245 2550879-245-excluding_ui.txt21.15 KBandrewbelcher
#245 2550879-245-interdiff.txt2.98 KBandrewbelcher
#245 2550879-245.patch281.17 KBandrewbelcher
#244 2550879-243-excluding_ui.diff20.41 KBandrewbelcher
#244 2550879-243-interdiff.txt1.47 KBandrewbelcher
#244 2550879-243.patch280.43 KBandrewbelcher
#242 2550879-242.patch280.41 KBeclipsegc
#241 2550879-interdiff.txt2.44 KBeclipsegc
#241 2550879-241.patch285.37 KBeclipsegc
#235 2550879-233-interdiff.txt8.22 KBandrewbelcher
#233 2550879-233-non_ui_changes.patch18.75 KBandrewbelcher
#233 2550879-233.patch287.28 KBandrewbelcher
#229 2550879-interdiff.txt745 byteseclipsegc
#229 2550879-229.patch284.83 KBeclipsegc
#228 2550879-interdiff.txt8.13 KBeclipsegc
#228 2550879-228.patch284.65 KBeclipsegc
#212 2550879-interdiff.txt1.48 KBeclipsegc
#212 2550879-212.patch277.35 KBeclipsegc
#208 use_ctools_wizard_api-2550879-208.patch282.66 KBjuampynr
#208 interdiff.txt390 bytesjuampynr
#206 context-duplicates.png56.97 KByanniboi
#205 interdiff.txt882 bytesyanniboi
#205 2550879-204.patch282.91 KByanniboi
#202 2550879-interdiff.txt31.01 KBeclipsegc
#202 2550879-202.patch278.2 KBeclipsegc
#197 use_ctools_wizard_api-2550879-197.patch256.4 KBjuampynr
#197 interdiff.txt2.36 KBjuampynr
#196 use_ctools_wizard_api-2550879-196.patch255.83 KBjuampynr
#196 196-interdiff.txt11.75 KBjuampynr
#192 2550879-interdiff.txt38.21 KBeclipsegc
#192 2550879-192.patch255.61 KBeclipsegc
#191 use_ctools_wizard_api-2550879-191.patch258.68 KBjuampynr
#191 interdiff.txt14.89 KBjuampynr
#189 use_ctools_wizard_api-2550879-189.patch260.16 KBjuampynr
#189 interdiff.txt3.5 KBjuampynr
#188 interdiff.txt3.17 KBjuampynr
#186 interdiff.txt10.41 KBjuampynr
#186 use_ctools_wizard_api-2550879-186.patch259.41 KBjuampynr
#185 use_ctools_wizard_api-2550879-185.patch249.14 KBjuampynr
#185 interdiff.txt2.37 KBjuampynr
#182 use_ctools_wizard_api-2550879-182.patch248.39 KBjuampynr
#182 interdiff.txt9.42 KBjuampynr
#178 2550879-context.interdiff.txt36.54 KBeclipsegc
#174 use_ctools_wizard_api-2550879-174.patch244.98 KBjuampynr
#173 use_ctools_wizard_api-2550879-173.patch247.48 KBjuampynr
#173 interdiff.txt1.38 KBjuampynr
#171 use_ctools_wizard_api-2550879-171.patch247.46 KBjuampynr
#171 interdiff.txt1.8 KBjuampynr
#169 use_ctools_wizard_api-2550879-169.patch247.55 KBjuampynr
#169 interdiff.txt3.26 KBjuampynr
#167 use_ctools_wizard_api-2550879-167.patch245.7 KBjuampynr
#167 interdiff.txt1.18 KBjuampynr
#162 use_ctools_wizard_api-2550879-162.patch246.55 KBjuampynr
#162 interdiff.txt19.34 KBjuampynr
#160 use_ctools_wizard_api-2550879-160.patch240.77 KBjuampynr
#160 test-only-2550879-160.patch2.7 KBjuampynr
#160 interdiff.txt0 bytesjuampynr
#157 use_ctools_wizard_api-2550879-157.patch237.97 KBjuampynr
#155 use_ctools_wizard_api-2550879-155.patch240.19 KByanniboi
#155 interdiff.txt7.98 KByanniboi
#152 use_ctools_wizard_api-2550879-152.patch226.17 KBjuampynr
#152 interdiff.txt2.4 KBjuampynr
#150 use_ctools_wizard_api-2550879-150.patch225.99 KBjuampynr
#150 interdiff.txt1.13 KBjuampynr
#148 use_ctools_wizard_api-2550879-148.patch225.72 KBjuampynr
#148 interdiff.txt1.69 KBjuampynr
#145 use_ctools_wizard_api-2550879-145.patch226.22 KBjuampynr
#145 interdiff.txt3.55 KBjuampynr
#141 use_ctools_wizard_api-2550879-141.patch228.06 KBjuampynr
#141 interdiff.txt2.26 KBjuampynr
#139 interdiff.txt5.98 KBjuampynr
#139 use_ctools_wizard_api-2550879-139.patch227.82 KBjuampynr
#137 use_ctools_wizard_api-2550879-137.patch227.82 KBjuampynr
#137 interdiff.txt937 bytesjuampynr
#135 use_ctools_wizard_api-2550879-132.patch227.47 KBjuampynr
#134 use_link_templates_2690211-2550879.patch10.67 KBandrewbelcher
#133 interdiff.txt1.46 KByanniboi
#133 use_ctools_wizard_api-2550879-133.patch225.22 KByanniboi
#132 interdiff.txt21.49 KByanniboi
#132 use_ctools_wizard_api-2550879-132.patch227.47 KByanniboi
#129 filter_core_variants-2550879.patch937 bytesandrewbelcher
#129 update_for_2690047-2550879.patch1.77 KBandrewbelcher
#127 use_ctools_wizard_api-2550879-127.patch217.94 KBjuampynr
#127 interdiff.txt3.03 KBjuampynr
#125 use_ctools_wizard_api-2550879-125.patch218.35 KBjuampynr
#125 interdiff.txt10.05 KBjuampynr
#122 use_ctools_wizard_api-2550879-122.patch217.19 KBjuampynr
#122 interdiff.txt612 bytesjuampynr
#120 use_ctools_wizard_api-2550879-120.patch216.72 KBjuampynr
#120 interdiff.txt1.16 KBjuampynr
#116 use_ctools_wizard_api-2550879-116.patch217.6 KBjuampynr
#116 interdiff.txt7.65 KBjuampynr
#116 Selection_001.png67.34 KBjuampynr
#113 use_ctools_wizard_api-2550879-113.patch221.32 KBjuampynr
#113 interdiff.txt7.66 KBjuampynr
#111 use_ctools_wizard_api-2550879-111.patch215.48 KBjuampynr
#111 interdiff.txt2.21 KBjuampynr
#110 use_ctools_wizard_api-2550879-110.patch214.52 KBjuampynr
#110 interdiff.txt1.47 KBjuampynr
#109 2550879-fix_edit_form_params.patch1.34 KBandrewbelcher
#106 Selection_001.png33.85 KBjuampynr
#106 use_ctools_wizard_api-2550879-106.patch213.66 KBjuampynr
#106 interdiff.txt14.7 KBjuampynr
#105 use_ctools_wizard_api-2550879-105.patch211.98 KBjuampynr
#105 interdiff.txt1.03 KBjuampynr
#103 use_ctools_wizard_api-2550879-103.patch211.53 KBjuampynr
#103 interdiff.txt2.57 KBjuampynr
#100 use_ctools_wizard_api-2550879-100.patch211.33 KBjuampynr
#100 interdiff.txt903 bytesjuampynr
#98 use_ctools_wizard_api-2550879-98.patch210.99 KBjuampynr
#98 interdiff.txt20.02 KBjuampynr
#98 Selection_003.png54.74 KBjuampynr
#93 use_ctools_wizard_api-2550879-93.patch206.52 KBjuampynr
#93 interdiff.txt6.94 KBjuampynr
#93 Selection_001.png42.47 KBjuampynr
#86 use_ctools_wizard_api-2550879-86.patch199.58 KBjuampynr
#86 interdiff.txt7.49 KBjuampynr
#84 use_ctools_wizard_api-2550879-84.patch192.66 KBjuampynr
#84 interdiff.txt14.39 KBjuampynr
#82 interdiff.txt3.41 KBjuampynr
#82 use_ctools_wizard_api-2550879-82.patch178.52 KBjuampynr
#81 use_ctools_wizard_api-2550879-81.patch176.18 KBjuampynr
#81 interdiff.txt1.94 KBjuampynr
#79 use_ctools_wizard_api-2550879-79.patch175.96 KBjuampynr
#79 interdiff.txt945 bytesjuampynr
#78 interdiff.txt2.77 KBjuampynr
#78 use_ctools_wizard_api-2550879-78.patch175.68 KBjuampynr
#76 use_ctools_wizard_api-2550879-76.patch174.67 KBjuampynr
#76 interdiff.txt521 bytesjuampynr
#75 use_ctools_wizard_api-2550879-75.patch174.63 KBjuampynr
#75 interdiff.txt3.03 KBjuampynr
#74 use_ctools_wizard_api-2550879-74.patch174.37 KBjuampynr
#74 interdiff.txt0 bytesjuampynr
#70 use_ctools_wizard_api-2550879-70.patch201.58 KBjuampynr
#65 interdiff.txt6.03 KBdsnopek
#65 page_manager-wizard-2550879-65.patch203.22 KBdsnopek
#64 2550879-64.interdiff.txt1.5 KBeclipsegc
#64 2550879-64.patch203.34 KBeclipsegc
#63 interdiff.txt6.09 KBdsnopek
#63 page_manager-wizard-2550879-64.patch203.06 KBdsnopek
#62 2550879-62.interdiff.txt2.78 KBeclipsegc
#62 2550879-62.patch201.15 KBeclipsegc
#61 interdiff.txt7.52 KBdsnopek
#61 page_manager-wizard-2550879-61.patch200.17 KBdsnopek
#59 2550879-59.interdiff.txt4.48 KBeclipsegc
#59 2550879-59.patch194.03 KBeclipsegc
#57 2550879-57.interdiff.txt22.31 KBeclipsegc
#57 2550879-57.patch192.96 KBeclipsegc
#53 interdiff.txt1.49 KBdsnopek
#53 page_manager-wizard-2550879-53.patch179.12 KBdsnopek
#52 interdiff.txt511 bytesdsnopek
#52 page_manager-wizard-2550879-52.patch179.17 KBdsnopek
#51 interdiff.txt3.14 KBdsnopek
#51 page_manager-wizard-2550879-51.patch179.28 KBdsnopek
#49 interdiff.txt995 bytesdsnopek
#49 page_manager-wizard-2550879-49.patch179.2 KBdsnopek
#47 interdiff.txt14.29 KBdsnopek
#47 page_manager-wizard-2550879-47.patch179.19 KBdsnopek
#46 interdiff.txt3.09 KBdsnopek
#46 page_manager-wizard-2550879-46.patch172.84 KBdsnopek
#43 interdiff.txt19.6 KBdsnopek
#43 page_manager-wizard-2550879-43.patch172.67 KBdsnopek
#42 interdiff.txt2.45 KBdsnopek
#42 page_manager-wizard-2550879-42.patch154.27 KBdsnopek
#40 interdiff.txt8.37 KBdsnopek
#40 page_manager-wizard-2550879-40.patch154.45 KBdsnopek
#39 2550879-39.patch147.63 KBeclipsegc
#38 2550879-38.patch7.02 KBeclipsegc
#35 interdiff.txt2.49 KBdsnopek
#35 page_manager-wizard-2550879-35.patch147.66 KBdsnopek
#34 interdiff.txt18.4 KBdsnopek
#34 page_manager-wizard-2550879-34.patch147.27 KBdsnopek
#32 interdiff-24-31.txt36.53 KBdsnopek
#31 2550879-31.patch160.22 KBeclipsegc
#30 2550879-30.patch155.55 KBeclipsegc
#28 2550879-28.patch153.28 KBeclipsegc
#24 interdiff.txt8.37 KBdsnopek
#24 page_manager-wizard-2550879-24.patch153.23 KBdsnopek
#21 interdiff.txt5.34 KBdsnopek
#21 page_manager-wizard-2550879-21.patch152.62 KBdsnopek
#20 page_manager-wizard-2550879-20.patch148.88 KBdsnopek
#19 interdiff.txt74.04 KBdsnopek
#19 page_manager-wizard-2550879-19.patch134.67 KBdsnopek
#18 interdiff.txt28.5 KBdsnopek
#18 page_manager-wizard-2550879-18.patch82.24 KBdsnopek
#17 page_manager-wizard-2550879-17.patch105.88 KBdsnopek
#15 interdiff.txt10.05 KBdsnopek
#15 page_manager-wizard-2550879-15.patch93.35 KBdsnopek
#14 page_manager-wizard-2550879-14.patch89.5 KBdsnopek
#5 page_manager-wizard-2550879-5.patch108.49 KBdsnopek
#2 2550879-2.patch198.98 KBeclipsegc

Comments

EclipseGc created an issue. See original summary.

eclipsegc’s picture

Status: Active » Needs work
StatusFileSize
new198.98 KB

patch

tim.plunkett’s picture

  1. +++ b/page_manager.routing.yml
    @@ -82,32 +157,6 @@ page_manager.access_condition_delete:
    -#### Static Contexts
    

    This whole section is missing.

  2. +++ b/page_manager.routing.yml
    @@ -153,7 +202,7 @@ page_manager.display_variant_select_block:
    -    _form: '\Drupal\page_manager\Form\DisplayVariantAddBlockForm'
    +    _form: 'Drupal\page_manager\Form\DisplayVariantAddBlockForm'
    
    @@ -161,7 +210,7 @@ page_manager.display_variant_add_block:
    -    _form: '\Drupal\page_manager\Form\DisplayVariantEditBlockForm'
    +    _form: 'Drupal\page_manager\Form\DisplayVariantEditBlockForm'
    
    @@ -169,7 +218,7 @@ page_manager.display_variant_edit_block:
    -    _form: '\Drupal\page_manager\Form\DisplayVariantDeleteBlockForm'
    +    _form: 'Drupal\page_manager\Form\DisplayVariantDeleteBlockForm'
    

    Bad merge

  3. +++ b/page_manager.services.yml
    @@ -9,11 +12,6 @@ services:
    -  page_manager.static_context:
    -    class: Drupal\page_manager\EventSubscriber\StaticContext
    -    arguments: ['@entity.manager']
    -    tags:
    -      - { name: 'event_subscriber' }
    

    Same, all of the static context stuff is missing?

  4. +++ b/src/Controller/PageManagerController.php
    @@ -184,7 +168,7 @@ class PageManagerController extends ControllerBase {
    -    return $this->redirect('page_manager.page_list');
    +    return $this->redirect('entity.page.collection');
    

    Little things like this we can merge in early, can you split this change out to another issue?

dsnopek’s picture

Related 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 ContextAwareVariantInterface and 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.

dsnopek’s picture

StatusFileSize
new108.49 KB

Here'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

dsnopek’s picture

I 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 a PageExecutable before the Page actually 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:

  1. +++ b/page_manager.routing.yml
    @@ -11,18 +9,30 @@ page_manager.page_list:
    -    _entity_access: page.update
    +    #_entity_access: page.update
    +    _entity_create_access: page
    

    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!)

  2. +++ b/page_manager.routing.yml
    @@ -48,6 +58,71 @@ entity.page.disable:
    +    _title: 'Add Condition'
    

    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. :-)

  3. +++ b/page_manager.services.yml
    @@ -1,4 +1,7 @@
       page_manager.current_user_context:
         class: Drupal\page_manager\EventSubscriber\CurrentUserContext
         arguments: ['@current_user', '@entity.manager']
    

    Just marking this code for myself to try and figure out how the current user context is handled if not through this event subscriber...

  4. +++ b/src/Entity/Page.php
    @@ -106,12 +131,9 @@ class Page extends ConfigEntityBase implements PageInterface {
    +  protected $menu_type = 'route';
    +
    +  protected $menu_settings = [];
     
    

    Missing docblock.

  5. +++ b/src/Entity/Page.php
    @@ -248,7 +315,7 @@ class Page extends ConfigEntityBase implements PageInterface {
    -      'display_variants' => $this->getVariants(),
    +      //'display_variants' => $this->getVariants(),
    

    Debug code or should really be a deletion?

  6. +++ b/src/Entity/Page.php
    @@ -331,7 +398,8 @@ class Page extends ConfigEntityBase implements PageInterface {
    -    return $this->getExecutable()->getContexts();
    +    //return $this->getExecutable()->getContexts();
    +    return $this->getParameters();
    

    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.

  7. +++ b/src/Entity/Page.php
    @@ -342,6 +410,79 @@ class Page extends ConfigEntityBase implements PageInterface {
    +  public function getMenuType() {
    +    return $this->menu_type;
    +  }
    +
    +  public static function preDelete(EntityStorageInterface $storage, array $entities) {
    +    parent::preDelete($storage, $entities); // TODO: Change the autogenerated stub
    +  }
    +
    +  public function getMenuSettings() {
    +    return $this->menu_settings;
    +  }
    

    Missing docblock!

  8. +++ b/src/Entity/Page.php
    @@ -342,6 +410,79 @@ class Page extends ConfigEntityBase implements PageInterface {
    +  public function addVariantEntity(PageVariantInterface $variant) {
    +    $this->display_variants[$variant->id()] = $variant;
    +    return $variant->id();
    +  }
    

    Missing docblock!

  9. +++ b/src/Entity/PageVariant.php
    @@ -0,0 +1,159 @@
    +class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    

    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.

  10. +++ b/src/Entity/PageVariant.php
    @@ -0,0 +1,159 @@
    +  protected $weight;
    +
    +  protected $uuid;
    +
    +  protected $variant;
    +
    +  protected $variant_settings = [];
    

    Loads of missing docblocks. I think I'm going to stop pointing these out now. :-)

  11. +++ b/src/Form/PageSelectionForm.php
    @@ -0,0 +1,67 @@
    +/**
    + * @file
    + * Contains \Drupal\page_manager\Form\PageAccessForm.
    + */
    

    This is a lie! This file (PageSelectionForm.php) really has PageSelectionForm.

  12. +++ b/src/Form/PageVariantConfigureForm.php
    @@ -0,0 +1,66 @@
    +/**
    + * @file
    + * Contains \Drupal\page_manager\Form\PageVariant\ConfigureForm.
    + */
    

    Also a lie. Should be 'PageVariantConfigureForm'

  13. +++ b/src/Form/PageVariantForm.php
    @@ -0,0 +1,70 @@
    +      '#description' => $this->t("Label for the PageVariant."),
    

    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"

  14. +++ b/src/Form/SelectionConfigure.php
    @@ -0,0 +1,54 @@
    +/**
    + * @file
    + * Contains \Drupal\page_manager\Form\AccessConfigure;
    + */
    

    Another lie in SelectionConfigure. I'll stop pointing these out - it's just nits.

  15. +++ b/src/PageInterface.php
    @@ -48,6 +56,11 @@ interface PageInterface extends ConfigEntityInterface, EntityWithPluginCollectio
       /**
    +   * @return \Drupal\Core\Plugin\Context\ContextInterface[]
    +   */
    +  public function getParameters();
    

    getParameters() is for context that is from the URL, right?

  16. +++ b/src/PageVariantInterface.php
    @@ -0,0 +1,37 @@
    +interface PageVariantInterface extends ConfigEntityInterface {
    

    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.

dsnopek’s picture

Issue tags: +D8panels

Adding to sprint board.

dsnopek’s picture

Would 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...

dsnopek’s picture

Status: Needs work » Postponed

I 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.

dsnopek’s picture

I'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:

Here's the general problem from a low-level architecture stand-point:

  1. Page Manager is about creating routes and having variants attached
  2. The variants could be anything including plain HTTP responses - they don't have to know anything about blocks or layout
  3. 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)
  4. 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
  5. However, both Panels in D7 and Backdrop split the configuring of "which layout" and "what goes on the layout" to separate forms (which I think makes a lot of sense!) - 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
  6. We've chosen to call "a set of forms which edits a single entity" the Wizard API in CTools

So, I guess I would say, just pretend we didn't call it the Wizard API. :-) It's really about the fact that we'll need multiple forms to edit a single variant, and what those forms are should be entirely invisible to Page Manager, because they are provided by the variant.

dsnopek’s picture

Issue summary: View changes

Updated issue summary

dsnopek’s picture

Status: Postponed » Active
Issue tags: +Needs reroll

This 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.

dsnopek’s picture

Assigned: Unassigned » dsnopek

Assigning to myself! I've started working on the re-roll...

dsnopek’s picture

Status: Active » Needs work
StatusFileSize
new89.5 KB

Here'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).

dsnopek’s picture

StatusFileSize
new93.35 KB
new10.05 KB

Just 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.

dsnopek’s picture

This 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.

dsnopek’s picture

StatusFileSize
new105.88 KB
dsnopek’s picture

Issue tags: -Needs reroll +Needs tests
StatusFileSize
new82.24 KB
new28.5 KB

Here'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

dsnopek’s picture

StatusFileSize
new134.67 KB
new74.04 KB

This 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!

dsnopek’s picture

StatusFileSize
new148.88 KB

Here'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!

dsnopek’s picture

StatusFileSize
new152.62 KB
new5.34 KB

This 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.

dsnopek’s picture

Title: Merge Wizard branch to 8.x-1.x » Use CTools Wizard API to add/edit Pages (and move plugin UI using PluginWizardInterface)

Since 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.

dsnopek’s picture

Category: Plan » Task

Not a meta, so changing category.

dsnopek’s picture

StatusFileSize
new153.23 KB
new8.37 KB

Here'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.

dsnopek’s picture

Issue summary: View changes

I 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.

wim leers’s picture

Here'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.

  1. +++ b/page_manager.module
    @@ -0,0 +1,65 @@
    + * Preprocess function for page-manager-wizard-tree.html.twig
    

    Nit: missing trailing period.

  2. +++ b/page_manager.routing.yml
    @@ -11,18 +11,30 @@ entity.page.collection:
    +    # @todo: this is really _entity_access: page.update
    +    _entity_create_access: page
    
    @@ -48,37 +60,63 @@ entity.page.disable:
    +    # @todo: this is really _entity_access: page.update
    +    _permission: 'administer pages'
    ...
    +    # @todo: should really check permission to edit entity somehow...
    +    #_entity_access: page.update
    +    _permission: 'administer pages'
    

    What's preventing us from doing what the @todo states? I guess because the entity is not available as a route parameter?

  3. +++ b/page_manager.routing.yml
    @@ -48,37 +60,63 @@ entity.page.disable:
         _title: 'Add new access condition'
    

    s/new//

  4. +++ b/src/Controller/PageManagerController.php
    @@ -64,12 +72,15 @@ class PageManagerController extends ControllerBase {
    +   * @param \Drupal\user\SharedTempStoreFactory $tempstore
    

    No interface to typehint on?

  5. +++ b/src/Entity/Page.php
    @@ -138,6 +159,10 @@ class Page extends ConfigEntityBase implements PageInterface {
    +  public function getDescription() {
    
    @@ -163,6 +188,40 @@ class Page extends ConfigEntityBase implements PageInterface {
    +  public function getParameters() {
    ...
    +  public function getParameter($parameter) {
    

    Missing/incomplete docblock for these and other methods here.

  6. +++ b/src/Form/AccessConfigure.php
    @@ -0,0 +1,67 @@
    +    /** @var $page \Drupal\page_manager\Entity\Page */
    ...
    +    /** @var $page \Drupal\page_manager\Entity\Page */
    ...
    +    /** @var $page \Drupal\page_manager\Entity\Page */
    ...
    +    /** @var $page \Drupal\page_manager\Entity\Page */
    
    +++ b/src/Form/AccessDelete.php
    @@ -0,0 +1,57 @@
    +    /** @var $page \Drupal\page_manager\Entity\Page */
    ...
    +    /** @var $page \Drupal\page_manager\Entity\Page */
    ...
    +    /** @var $page \Drupal\page_manager\Entity\Page */
    

    Typehint to the interface?

  7. +++ b/src/Form/PageAccessForm.php
    @@ -0,0 +1,68 @@
    +  protected function getConditionClass() {
    +    return 'Drupal\page_manager\Form\AccessConfigure';
    +  }
    

    This looks pretty strange.

  8. +++ b/src/Form/PageContextsForm.php
    @@ -0,0 +1,89 @@
    +      '#header' => array($this->t('Context'), $this->t('Type'), $this->t('Operations')),
    +      '#rows' => $this->renderRows($cached_values),
    +      '#empty' => t('No Contexts configured for this variant.')
    

    array() -> []

    t() -> $this->t()

    Here and elsewhere in this file.

  9. +++ b/src/Form/PageContextsForm.php
    @@ -0,0 +1,89 @@
    +    $form['#attached']['library'][] = 'core/drupal.dialog.ajax';
    

    There's no AJAXy stuff here. If this is necessary, should have an @see to make that clear.

  10. +++ b/src/Form/PageGeneralForm.php
    @@ -0,0 +1,183 @@
    +   * Constructs a new DisplayVariantAddForm.
    

    Outdated docs.

  11. +++ b/src/Form/PageGeneralForm.php
    @@ -0,0 +1,183 @@
    +          //'contexts' => $this->t('Contexts'),
    

    Dead code, or needs a @todo?

  12. +++ b/src/Form/PageParameterForm.php
    @@ -0,0 +1,152 @@
    +      '#header' => array($this->t('Argument'), $this->t('Position in path'), $this->t('Context assigned'), $this->t('Operations')),
    +      '#rows' => $this->renderRows($cached_values),
    +      '#empty' => t('No required conditions have been configured.')
    

    Same remarks as for PageContextsForm.

  13. +++ b/src/Form/PageVariantConfigureForm.php
    @@ -0,0 +1,94 @@
    + * Contains \Drupal\page_manager\Form\PageVariant\ConfigureForm.
    

    Mismatch.

  14. +++ b/src/Form/PageVariantDeleteForm.php
    @@ -7,35 +7,74 @@
    +  protected $tempstore;
    +
    +  /**
    +   * Constructs a PageVariantDeleteForm.
    +   *
    +   * @param \Drupal\user\SharedTempStoreFactory $tempstore
    +   *   The tempstore factory.
    +   */
    +  public function __construct(SharedTempStoreFactory $tempstore) {
    +    $this->tempstore = $tempstore;
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public static function create(ContainerInterface $container) {
    +    return new static(
    +      $container->get('user.shared_tempstore')
    +    );
    +  }
    

    I've seen this stuff several times now; looks like this could use a base class. Or perhaps a trait.

  15. +++ b/src/Form/SelectionConfigure.php
    @@ -0,0 +1,81 @@
    + * Contains \Drupal\page_manager\Form\AccessConfigure;
    

    Mismatch.

  16. +++ b/src/Form/SelectionDelete.php
    @@ -0,0 +1,48 @@
    + * Contains \Drupal\page_manager\Form\AccessDelete.
    

    Mismatch.

  17. +++ b/src/Form/VariantPluginConfigureBlockFormBase.php
    @@ -36,6 +45,43 @@ abstract class VariantPluginConfigureBlockFormBase extends FormBase {
    +   * Constructs a new DisplayVariantAddForm.
    

    Mismatch.

  18. +++ b/src/Form/VariantPluginContentForm.php
    @@ -0,0 +1,251 @@
    +   * Constructs a new DisplayVariantAddForm.
    

    Mismatch.

  19. +++ b/src/Form/VariantPluginContentForm.php
    @@ -0,0 +1,251 @@
    +   * Get the tempstore id.
    

    s/id/ID/

dsnopek’s picture

Assigned: dsnopek » eclipsegc

Handed 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.

eclipsegc’s picture

StatusFileSize
new153.28 KB

Ok, 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

swentel’s picture

Nice 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.

eclipsegc’s picture

StatusFileSize
new155.55 KB

Ok, 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.

eclipsegc’s picture

StatusFileSize
new160.22 KB

Ok, 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

dsnopek’s picture

StatusFileSize
new36.53 KB

Here'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. :-)

dsnopek’s picture

Issue summary: View changes

I did a quick read through the interdiff, and have two small bits of review:

  1. +++ b/src/Entity/PageVariant.php
    @@ -44,7 +44,7 @@ use Drupal\page_manager\PageVariantInterface;
    - *     "edit-form" = "/admin/structure/page_manager/manage/{page}/variant/{page_variant}",
    + *     "edit-form" = "/admin/structure/page_manager/manage/{machine_name}/{step}",
    

    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.

  2. +++ b/src/Form/SelectionDelete.php
    @@ -14,7 +14,7 @@ class SelectionDelete extends ConditionDelete {
    -    return ['entity.page.edit_form', ['machine_name' => $this->machine_name, 'step' => 'selection']];
    +    return ['entity.page.edit_form', ['machine_name' => $this->machine_name, 'step' => 'page_variant__' . $cached_values['page_variant']->id() . '__selection']];
    

    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!

dsnopek’s picture

Issue summary: View changes
StatusFileSize
new147.27 KB
new18.4 KB

Here'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

dsnopek’s picture

StatusFileSize
new147.66 KB
new2.49 KB

And 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!

swentel’s picture

@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 :/

dsnopek’s picture

@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.

eclipsegc’s picture

StatusFileSize
new7.02 KB

Ok, 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

eclipsegc’s picture

StatusFileSize
new147.63 KB

sorry the patch in 38 is an interdiff. here's the real patch.

Eclipse

dsnopek’s picture

StatusFileSize
new154.45 KB
new8.37 KB

Here'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.

samuel.mortenson’s picture

Just 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 58

4. 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?

dsnopek’s picture

Related issues: +#2639526: Calling BlockDisplayVariant::setConfiguration() won't change results returned from plugin collections
StatusFileSize
new154.27 KB
new2.45 KB

My 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.

dsnopek’s picture

Status: Needs work » Needs review
StatusFileSize
new172.67 KB
new19.6 KB

This patch gets all the tests, passing except for StaticContextTest because 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..

Status: Needs review » Needs work

The last submitted patch, 43: page_manager-wizard-2550879-43.patch, failed testing.

dsnopek’s picture

Bah! 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. :-/

dsnopek’s picture

StatusFileSize
new172.84 KB
new3.09 KB

Here'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 PageManagerAdminTest a bit more to cover all new UIs in this patch, and try to eliminate some of the other @todo's in there.

dsnopek’s picture

StatusFileSize
new179.19 KB
new14.29 KB

This 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.

dsnopek’s picture

Regarding the rest of the UI review in #41:

4. 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.

Agreed! This actually comes from \Drupal\ctools\Form\ManageConditions so this will be a CTools change.

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.

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.

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"?

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.

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?

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.

dsnopek’s picture

StatusFileSize
new179.2 KB
new995 bytes

Here'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.

samuel.mortenson’s picture

I'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). :-)

dsnopek’s picture

StatusFileSize
new179.28 KB
new3.14 KB

Thanks, 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'.

dsnopek’s picture

StatusFileSize
new179.17 KB
new511 bytes

Hrm. 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!

dsnopek’s picture

StatusFileSize
new179.12 KB
new1.49 KB

This 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!

berdir’s picture

Testing 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.

  1. The fieldset on the label/id seems confusing to me. I've seen that @EclipseGc's UI for pathauto patterns had the same, not sure where this is coming from. I don't see a reason for that fieldset label, doesn't provide any additional information and complicates the UI.
  2. Given that path is required, I'd move that above description.
  3. The Variant type is a bit confusing, it's about which variant you want to create as the first one, right? Needs a better label + a description IMHO.
  4. Also confused about the selection rules/access controls optional feature checkboxes. Selection rules apply to variants and are only relevant when you have more than one, why not let me decide if I want that while configuring the variant? Will there be more options later? If just access rules remains, then maybe we can find a better, less confusing UI for that? (e.g. do it later on, or handle it through multiple buttons)
  5. Path could really use a description/example (placeholder) to explain things like arguments, if you need a leading / or not, etc. (The current UI doesn't have that, but the it also doesn't have a whole other bunch that we are adding ;) But follow-up is fine, e.g. as part of making arguments work properly).
  6. Additionally to the button label mentioned in #45.4, I'd say that the button should be next to the select and not in the same area as the wizard buttons
  7. I checked both optional checkboxes and I get a Selection Criteria step before actually configuring the variant. The UI doesn't give me any explanation about the difference between selection criterias and access rules. We need some intro text above each step, maybe through hook_help() ?
  8. The machine name for variants is global, but the default suggestion will often result in duplicates. I think it would be useful if the default machine name would be prefixed with the page machine name?
  9. A fair amount of functionality still seems to be missing? I can't actually configure a variant, static contexts UI isn't there, etc. What's the plan for completing this, how much will be part of the first patch? The patch is already huge and way too big for a code review I think but leaving out functionality also doesn't seem like an option for existing installations?
dsnopek’s picture

@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.

eclipsegc’s picture

StatusFileSize
new192.96 KB
new22.31 KB

Ok, 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

dsnopek’s picture

Issue summary: View changes

Updating "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"

eclipsegc’s picture

StatusFileSize
new194.03 KB
new4.48 KB

Fixed 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

eclipsegc’s picture

Issue summary: View changes
dsnopek’s picture

StatusFileSize
new200.17 KB
new7.52 KB

I started updating the StaticContextTest now that those are working(-ish)! However, I'm still getting the LogicException that #59 was meant to fix when adding contexts in the add wizard. :-/

eclipsegc’s picture

StatusFileSize
new201.15 KB
new2.78 KB

Found an issue with putting plugins into the tempstore. Filing an upstream patch. Add/edit transition should work now.

Eclipse

dsnopek’s picture

StatusFileSize
new203.06 KB
new6.09 KB

Blergh. 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...

eclipsegc’s picture

StatusFileSize
new203.34 KB
new1.5 KB

Ok, so I was saving context by entity id instead of UUID, once I fixed that the EntityLazyLoadContext class started working properly.

Eclipse

dsnopek’s picture

Issue summary: View changes
StatusFileSize
new203.22 KB
new6.03 KB

Huzzah! 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 StaticContextConfigure form 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.

tim.plunkett’s picture

  1. +++ b/src/Entity/Page.php
    @@ -37,6 +39,7 @@ use Drupal\page_manager\PageVariantInterface;
    + *     "description",
    
    @@ -70,6 +73,13 @@ class Page extends ConfigEntityBase implements PageInterface {
    +   * The description of the page entity.
    +   *
    +   * @var string
    +   */
    +  protected $description;
    +
    +  /**
    
    @@ -141,6 +151,13 @@ class Page extends ConfigEntityBase implements PageInterface {
    +  public function getDescription() {
    +    return $this->description;
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    

    This should be a separate issue.

  2. +++ b/src/Entity/Page.php
    @@ -174,6 +191,13 @@ class Page extends ConfigEntityBase implements PageInterface {
    +    // Save the page variants just in case they were modified (or added) and
    +    // not saved independently.
    +    foreach ($this->getVariants() as $page_variant) {
    +      $page_variant->save();
    +    }
    

    This should be a separate issue.

  3. +++ b/src/Entity/Page.php
    @@ -297,8 +321,21 @@ class Page extends ConfigEntityBase implements PageInterface {
    +  public static function preDelete(EntityStorageInterface $storage, array $entities) {
    +    parent::preDelete($storage, $entities); // TODO: Change the autogenerated stub
    +  }
    

    This should be removed :)

  4. +++ b/src/Entity/Page.php
    @@ -297,8 +321,21 @@ class Page extends ConfigEntityBase implements PageInterface {
    +    // If variants hasn't been initialized, we initialize it before adding the
    +    // new variant.
    +    if ($this->variants === NULL) {
    +      $this->getVariants();
    +    }
         $this->variants[$variant->id()] = $variant;
    +    $this->sortVariants();
    

    This should be a separate issue.

  5. +++ b/src/Entity/Page.php
    @@ -331,23 +368,19 @@ class Page extends ConfigEntityBase implements PageInterface {
    -      @uasort($this->variants, [$this, 'variantSortHelper']);
    ...
    +      @uasort($this->variants, '\Drupal\page_manager\Entity\PageVariant::sort');
    

    Why this switch? And this should be a separate issue.

  6. +++ b/src/Entity/Page.php
    @@ -356,21 +389,8 @@ class Page extends ConfigEntityBase implements PageInterface {
    -    // Avoid serializing plugin collections and the page executable as they
    -    // might contain references to a lot of objects including the container.
    -    $unset_vars = [
    -      'variants' => NULL,
    -      'accessConditionCollection' => 'access_variants',
    -      'executable' => NULL,
    -    ];
    -    foreach ($unset_vars as $unset_var => $configuration_key) {
    -      if (!empty($this->$unset_var)) {
    -        if ($configuration_key) {
    -          $this->set($configuration_key, $this->$unset_var->getConfiguration());
    -        }
    -        unset($vars[array_search($unset_var, $vars)]);
    -      }
    -    }
    +    // Avoid serializing the page executable as it represents runtime state.
    +    unset($vars[array_search('executable', $vars)]);
    

    Any insight here as to why we can change this?

  7. +++ b/src/Entity/PageVariant.php
    @@ -207,6 +206,9 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    +      if (empty($this->variant_settings['uuid'])) {
    +        $this->variant_settings['uuid'] = $this->uuidGenerator()->generate();
    +      }
    

    This should be a separate issue.

  8. +++ b/src/Entity/PageVariant.php
    @@ -232,17 +234,29 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    -    if (!$this->page) {
    +    $page = Page::load($this->page);
    +    if (!$page) {
           throw new \UnexpectedValueException('The page variant has no associated page');
         }
    -    return Page::load($this->page);
    +    return $page;
    

    This sorta makes sense, but it's also another problem because what if $this->page === NULL?

    This should be a separate issue.

  9. +++ b/src/Entity/PageVariant.php
    @@ -232,17 +234,29 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    +    try {
    +      $page = $this->getPage();
    +    }
    +    catch (\UnexpectedValueException $e) {
    +      // This can happen adding a new page - it may only exist in the tempstore.
    +      // @todo Remove once contexts are stored only on the variant!
    +      $cached_values = $this->getTempstoreFactory()->get('page_manager.page')->get($this->page);
    +      if (!empty($cached_values) && !empty($cached_values['page'])) {
    +        $page = $cached_values['page'];
    +      }
    +    }
    

    Any reason not to put this into getPage()?

  10. +++ b/src/Plugin/DisplayVariant/HttpStatusCodeDisplayVariant.php
    @@ -84,4 +84,11 @@ class HttpStatusCodeDisplayVariant extends VariantBase {
    +  public function __sleep() {
    +    $vars = parent::__sleep();
    +    unset($vars[array_search('stringTranslation', $vars)]);
    +    return $vars;
    +  }
    
    +++ b/src/Plugin/DisplayVariant/PageBlockDisplayVariant.php
    @@ -234,4 +247,10 @@ class PageBlockDisplayVariant extends BlockDisplayVariant {
    +  public function __sleep() {
    +    $vars = parent::__sleep();
    +    unset($vars[array_search('stringTranslation', $vars)]);
    +    return $vars;
    

    Why? Isn't that service, and therefore handled by the trait?

dsnopek’s picture

Status: Needs work » Postponed
Issue tags: -Needs tests

We 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.

eclipsegc’s picture

There 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

juampynr’s picture

Re-rolling. This is a tricky one since a few things have changed and have been moved to page_manager_ui.

juampynr’s picture

Status: Postponed » Needs review
StatusFileSize
new201.58 KB

This 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.

Status: Needs review » Needs work

The last submitted patch, 70: use_ctools_wizard_api-2550879-70.patch, failed testing.

tim.plunkett’s picture

IMO this should be a separate module called page_manager_wizard, and it should be installed *instead* of page_manager_ui, not in addition.

juampynr’s picture

@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.

juampynr’s picture

Assigned: eclipsegc » Unassigned
StatusFileSize
new0 bytes
new174.37 KB

This 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.

juampynr’s picture

StatusFileSize
new3.03 KB
new174.63 KB

Fixed 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.

juampynr’s picture

StatusFileSize
new521 bytes
new174.67 KB

Phew, this one was tricky, this line at Page::__sleep() was avoiding the Page's id to be saved in the shared storage:

unset($vars[array_search('executable', $vars)]);

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.

juampynr’s picture

I am now looking at how to adjust the logic so the patch uses PageVariant::getStaticContexts() instead of Page::getStaticContexts(). This is something that changed at #2631800: Store static contexts on the variant rather than the page, which got committed after #65.

juampynr’s picture

StatusFileSize
new175.68 KB
new2.77 KB

Fixed 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.

juampynr’s picture

StatusFileSize
new945 bytes
new175.96 KB

The 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:

delete from key_value_expire where collection like '%page_manager%'

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.

tim.plunkett’s picture

+++ b/src/Entity/PageVariant.php
@@ -117,9 +117,9 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
-  protected $contexts = NULL;
+  protected $contexts = [];

@@ -277,7 +277,7 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
-    $this->contexts = NULL;
+    $this->contexts = [];

This conflicts with the logic in getContexts(), which checks is_null

+++ b/page_manager_ui/src/Form/PageReorderVariantsForm.php
@@ -84,8 +84,17 @@ class PageReorderVariantsForm extends FormBase {
+        if (isset($variants[$page_variant->id()])) {
+          unset($variants[$page_variant->id()]);
+        }

unset() doesn't need an isset check first.

juampynr’s picture

StatusFileSize
new1.94 KB
new176.18 KB

Fixed @tim.plunkett's feedback at #80.

Working on the tests now.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new178.52 KB
new3.41 KB

Fixed 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.

Status: Needs review » Needs work

The last submitted patch, 82: use_ctools_wizard_api-2550879-82.patch, failed testing.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new14.39 KB
new192.66 KB

Fixed half of PageManagerAdminTest.

Status: Needs review » Needs work

The last submitted patch, 84: use_ctools_wizard_api-2550879-84.patch, failed testing.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new7.49 KB
new199.58 KB

Fixed errors for PageManagerAdminTest.php. Moving on to the other tests.

Status: Needs review » Needs work

The last submitted patch, 86: use_ctools_wizard_api-2550879-86.patch, failed testing.

yanniboi’s picture

Had a quick look at PageManagerAdminTest and still getting a couple of fails (could be my dev environment but thought I'd check):

HTTP response expected 403, actual 200 | PageManagerAdminTest.php | 419 | Drupal\page_manager_ui\Tests\PageManagerAdminTest->doTestReorderVariants()

and

Page is rendered in bartik Value 0 is equal to value 1. | PageManagerAdminTest.php | 452 | Drupal\page_manager_ui\Tests\PageManagerAdminTest->doTestAdminPath()

are probably caching issues...

And then there are a couple of schema errors:

Uncaught PHP Exception Drupal\Core\Config\Schema\SchemaIncompleteException: "Schema errors for page_manager.page_variant.block_page with the following errors: page_manager.page_variant.block_page:variant_settings.blocks.058ec778-96c8-4ce6-9500-e4c7a4501b9d.level missing schema, page_manager.page_variant.block_page:variant_settings.blocks.058ec778-96c8-4ce6-9500-e4c7a4501b9d.depth missing schema" at /var/www/html/b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php line 98

juampynr’s picture

It'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?

yanniboi’s picture

Nevermind, I just updated core, and all the errors went away :P

yanniboi’s picture

8.2.x? No I was still on 8.0.x :P

yanniboi’s picture

I 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.

  1. Click on 'Add variant'. We are presented with a list of variant plugins to choose from (eg. Block Page/Panels/etc)
  2. Configuring variant. We now have an entity add form where we can add a new variant and fill in information required by it, eg. Layout.

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.

juampynr’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new42.47 KB
new6.94 KB
new206.52 KB

This 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:

Move contexts to variants

Status: Needs review » Needs work

The last submitted patch, 93: use_ctools_wizard_api-2550879-93.patch, failed testing.

juampynr’s picture

@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.

<andrewbelcher> juampynr: noticed one thing missed switching to the wizard: \Drupal\page_manager_ui\Controller\PageManagerController::selectVariant() filtered out simple_page and block_page from the available variant plugin ids - the new \Drupal\page_manager_ui\Form\PageGeneralForm::buildForm() doesn't do the same
<andrewbelcher> <?php
<andrewbelcher>       foreach ($this->variantManager->getDefinitions() as $plugin_id => $definition) {
<andrewbelcher>         // The following two variants are provided by Drupal Core. They are not
<andrewbelcher>         // configurable and therefore not compatible with Page Manager but have
<andrewbelcher>         // similar and confusing labels. Skip them so that they are not shown in
<andrewbelcher>         // the UI.
<andrewbelcher>         if (in_array($plugin_id, ['simple_page', 'block_page'])) {
<andrewbelcher>           continue;
<andrewbelcher>         }
<andrewbelcher>         $variant_plugin_options[$plugin_id] = $definition['admin_label'];
<andrewbelcher>       }
andrewbelcher’s picture

To make that a little more readable/copyable:

      foreach ($this->variantManager->getDefinitions() as $plugin_id => $definition) {
        // The following two variants are provided by Drupal Core. They are not
        // configurable and therefore not compatible with Page Manager but have
        // similar and confusing labels. Skip them so that they are not shown in
        // the UI.
        if (in_array($plugin_id, ['simple_page', 'block_page'])) {
          continue;
        }

        $variant_plugin_options[$plugin_id] = $definition['admin_label'];
      }
juampynr’s picture

Just 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.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new54.74 KB
new20.02 KB
new210.99 KB

Here is the first step forward for #93. Here I have:

  • Changed Page Contexts to Page Parameters.
  • Moved Contexts to each variant.

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:

Rearranged menu options

Status: Needs review » Needs work

The last submitted patch, 98: use_ctools_wizard_api-2550879-98.patch, failed testing.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new903 bytes
new211.33 KB

Here 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.

Status: Needs review » Needs work

The last submitted patch, 100: use_ctools_wizard_api-2550879-100.patch, failed testing.

juampynr’s picture

@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).

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new2.57 KB
new211.53 KB

Fixed 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.

Status: Needs review » Needs work

The last submitted patch, 103: use_ctools_wizard_api-2550879-103.patch, failed testing.

juampynr’s picture

StatusFileSize
new1.03 KB
new211.98 KB

Added 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.

juampynr’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new14.7 KB
new213.66 KB
new33.85 KB

Few 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:

Parameters not editable

Now that contexts are working, I will get back to fix the tests.

Status: Needs review » Needs work

The last submitted patch, 106: use_ctools_wizard_api-2550879-106.patch, failed testing.

andrewbelcher’s picture

@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).

andrewbelcher’s picture

StatusFileSize
new1.34 KB

@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).

juampynr’s picture

StatusFileSize
new1.47 KB
new214.52 KB

Thanks @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.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new2.21 KB
new215.48 KB

Fixes PageVariantTest.php.

Status: Needs review » Needs work

The last submitted patch, 111: use_ctools_wizard_api-2550879-111.patch, failed testing.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new7.66 KB
new221.32 KB

Fixed 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.

Status: Needs review » Needs work

The last submitted patch, 113: use_ctools_wizard_api-2550879-113.patch, failed testing.

tim.plunkett’s picture

Please 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.

  1. +++ b/src/Entity/Page.php
    @@ -139,6 +154,13 @@ class Page extends ConfigEntityBase implements PageInterface {
    +    // Save the page variants just in case they were modified (or added) and
    +    // not saved independently.
    +    foreach ($this->getVariants() as $page_variant) {
    +      $page_variant->save();
    +    }
    

    This is not in scope. If it is necessary, it should be in its own issue (with test coverage) that blocks this.

  2. +++ b/src/Entity/Page.php
    @@ -300,7 +322,7 @@ class Page extends ConfigEntityBase implements PageInterface {
    -    if (!$this->contexts) {
    +    if (empty($this->contexts)) {
    

    Same as above

  3. +++ b/src/Entity/Page.php
    @@ -309,8 +331,21 @@ class Page extends ConfigEntityBase implements PageInterface {
    +  public static function preDelete(EntityStorageInterface $storage, array $entities) {
    +    parent::preDelete($storage, $entities); // TODO: Change the autogenerated stub
    +  }
    

    Ahem.

  4. +++ b/src/Entity/PageVariant.php
    @@ -116,9 +117,9 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    -   * @var \Drupal\Component\Plugin\Context\ContextInterface[]|null
    +   * @var \Drupal\Component\Plugin\Context\ContextInterface[]
    ...
    -  protected $contexts = NULL;
    +  protected $contexts = [];
    
    @@ -259,7 +292,7 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    -    $this->contexts = NULL;
    +    $this->contexts = [];
    

    Any explanation for this?

  5. +++ b/src/Entity/PageVariant.php
    @@ -235,21 +246,43 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    -    if (!$this->page) {
    +    $page = Page::load($this->page);
    +    if (!$page) {
    ...
    -    return $this->getPageStorage()->load($this->page);
    

    This change makes no sense. Also using Page::load is a step backwards.

  6. +++ b/src/Entity/PageVariant.php
    @@ -235,21 +246,43 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    -      $this->contexts = array_merge($static_contexts, $page_contexts);
    ...
    +    return array_merge($page->getContexts(), $this->loadContexts());
    

    This order seems to be backwards. It probably broke a unit test somewhere.

  7. +++ b/src/Entity/PageVariant.php
    @@ -235,21 +246,43 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    +      // @todo Remove once contexts are stored only on the variant!
    

    All @todos should have issues, unless they are to be fixed before commit, in which case you can use @fixme

  8. +++ b/src/Plugin/DisplayVariant/HttpStatusCodeDisplayVariant.php
    @@ -84,4 +84,13 @@ class HttpStatusCodeDisplayVariant extends VariantBase {
    +  public function __sleep() {
    +    $vars = parent::__sleep();
    +    $key = array_search('stringTranslation', $vars);
    +    if ($key !== FALSE) {
    +      unset($vars[$key]);
    +    }
    +    return $vars;
    +  }
    
    +++ b/src/Plugin/DisplayVariant/PageBlockDisplayVariant.php
    @@ -300,4 +313,13 @@ class PageBlockDisplayVariant extends BlockDisplayVariant {
    +  public function __sleep() {
    

    This should not be necessary, the parent trait should handle it.

  9. +++ b/src/Plugin/DisplayVariant/PageBlockDisplayVariant.php
    @@ -248,6 +249,18 @@ class PageBlockDisplayVariant extends BlockDisplayVariant {
    +  public function getWizardOperations($cached_values) {
    

    This seems like it would be better as an annotation.

  10. +++ b/src/Plugin/DisplayVariant/PageBlockDisplayVariant.php
    @@ -248,6 +249,18 @@ class PageBlockDisplayVariant extends BlockDisplayVariant {
    +        'form' => '\Drupal\page_manager_ui\Form\VariantPluginContentForm',
    

    Use VariantPluginContentForm::class

  11. +++ b/src/Tests/PageTestHelperTrait.php
    @@ -13,13 +13,6 @@ namespace Drupal\page_manager\Tests;
    -   * @see \Drupal\simpletest\TestBase::$container
    -   *
    -   * @var \Symfony\Component\DependencyInjection\ContainerInterface
    -   */
    -  protected $container;
    

    Now the methods in this trait refer to a property that doesn't exist.

  12. +++ b/src/Tests/StaticContextTest.php
    @@ -49,22 +49,15 @@ class StaticContextTest extends WebTestBase {
    +    $this->drupalGet('admin/structure/page_manager/add');
    ...
    -    $this->drupalPostForm('admin/structure/page_manager/add', $edit_page, 'Save');
    ...
    +    $this->drupalPostForm(NULL, $edit_page, 'Next');
    

    This could have just changed one line, not 3

  13. +++ b/tests/src/Unit/PageTest.php
    @@ -49,10 +49,12 @@ class PageTest extends UnitTestCase {
    -    $variant1->getWeight()->willReturn(0);
    ...
    +    $variant1->weight = 0;
    ...
    -    $variant2->getWeight()->willReturn(-10);
    ...
    +    $variant2->weight = -10;
    

    That not how mocks are supposed to work.

  14. +++ b/tests/src/Unit/PageTest.php
    @@ -49,10 +49,12 @@ class PageTest extends UnitTestCase {
    +    $variant1->label()->willReturn('Variant 1');;
    ...
    +    $variant2->label()->willReturn('Variant 2');;
    

    Double semi-colon.

  15. +++ b/tests/src/Unit/PageVariantTest.php
    @@ -49,12 +50,17 @@ class PageVariantTest extends UnitTestCase {
    +    $entity_manager = $this->prophesize(EntityManagerInterface::class);
    ...
    +    $container->set('entity.manager', $entity_manager->reveal());
    

    The entity manager is deprecated. Remove all code referencing it.

  16. +++ b/tests/src/Unit/PageVariantTest.php
    @@ -49,12 +50,17 @@ class PageVariantTest extends UnitTestCase {
    +    $entity_manager->getEntityTypeFromClass('Drupal\page_manager\Entity\Page')->willReturn('page');
    

    Use Page::class

  17. +++ b/tests/src/Unit/PageVariantTest.php
    @@ -70,8 +76,6 @@ class PageVariantTest extends UnitTestCase {
    -    $contexts = $this->pageVariant->getContexts();
    -    $this->assertSame($expected, $contexts);
    

    Why would you remove test coverage from an API test in a UI only issue?

  18. +++ b/tests/src/Unit/PageVariantTest.php
    @@ -84,12 +88,12 @@ class PageVariantTest extends UnitTestCase {
    -      ['static' => 'static', 'page' => 'page'],
    +      ['page' => 'page', 'static' => 'static'],
    ...
    -      ['foo' => 'page'],
    +      ['foo' => 'static'],
    

    Same as above. No functional tests should be altered for UI only changes.

juampynr’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new67.34 KB
new7.65 KB
new217.6 KB

Thanks 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:

Variant contexts ordering

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:

LogicException: 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. in Drupal\Core\Site\Settings->__sleep() (line 67 of core/lib/Drupal/Core/Site/Settings.php).

Status: Needs review » Needs work

The last submitted patch, 116: use_ctools_wizard_api-2550879-116.patch, failed testing.

yanniboi’s picture

@Juampy

8. HttpStatusCodeDisplayVariant extends VariantBase extends PluginBase which uses the DependencySerializationTrait. DependencySerializationTrait provides the __sleep() method.

andrewbelcher’s picture

1. 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_contexts as 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...

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new1.16 KB
new216.72 KB

Got 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:

LogicException: 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. in Drupal\Core\Site\Settings->__sleep() (line 67 of core/lib/Drupal/Core/Site/Settings.php).

@andrewbelcher, I will look at your feedback at #119 for merging page and variant contexts in a bit.

Status: Needs review » Needs work

The last submitted patch, 120: use_ctools_wizard_api-2550879-120.patch, failed testing.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new612 bytes
new217.19 KB

Restoring #115-1 as otherwise page variants don't get saved when you click on Update and save or Save.

Status: Needs review » Needs work

The last submitted patch, 122: use_ctools_wizard_api-2550879-122.patch, failed testing.

andrewbelcher’s picture

@juampynr Rather than restoring that, you could do something like this in \Drupal\page_manager_ui\Wizard\PageWizardBase::finish:

  public function finish(array &$form, FormStateInterface $form_state) {
    parent::finish($form, $form_state);

    $cached_values = $form_state->getTemporaryValue('wizard');
    /** @var \Drupal\page_manager\Entity\Page $page */
    $page = $cached_values['page'];
    foreach($page->getVariants() as $variant) {
      $variant->save();
    }
  }

I would also be inclined to change \Drupal\page_manager_ui\Wizard\PageEditWizard::finish to:

  public function finish(array &$form, FormStateInterface $form_state) {
    // Delete any of the variants marked for deletion.
    $cached_values = $form_state->getTemporaryValue('wizard');
    /** @var \Drupal\page_manager\Entity\Page $page */
    $page = $cached_values['page'];
    if (!empty($cached_values['deleted_variants'])) {
      foreach ($cached_values['deleted_variants'] as $page_variant) {
        $page->removeVariant($page_variant->id());
      }
    }

    parent::finish($form, $form_state);
  }

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 either parent::finish() or Page::postSave(). Using ::removeVariant() is necessary as it removes it from the Page::$variants property, but that is also better as it means other things wont find it (and potentially re-save it) by calling Page::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.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new10.05 KB
new218.35 KB

Fixed 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.

Status: Needs review » Needs work

The last submitted patch, 125: use_ctools_wizard_api-2550879-125.patch, failed testing.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new3.03 KB
new217.94 KB

Here 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!

Status: Needs review » Needs work

The last submitted patch, 127: use_ctools_wizard_api-2550879-127.patch, failed testing.

andrewbelcher’s picture

@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.

yanniboi’s picture

@jaumpy, did you remove this at some point? We dont want this anymore :)

+++ b/page_manager_ui/src/Form/PageParametersForm.php
@@ -0,0 +1,129 @@
+    /** @var \Drupal\Core\StringTranslation\TranslatableMarkup $add */
+    $add = $form_state->getValue('add');
+    if ($add->getUntranslatedString() == 'Add new context') {
+      list(, $route_parameters) = $this->getOperationsRouteInfo($cached_values, $this->machine_name, $form_state->getValue('types'));
+      $form_state->setRedirect($this->getAddRoute($cached_values), $route_parameters);
+    }
andrewbelcher’s picture

So 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):

  1. I think we normally only capitalise the first work (e.g. Page access rather than Page Access).
  2. Page access should come after Page parameters, as you may want to make use of those configured parameters.
  3. Page parameters only shows current user, which isn't in the path. This page should only show items from the path (which it doesn't show).
  4. Submitting Page parameters gave me:
    PHP Fatal error:  Call to a member function getUntranslatedSt
    ring() on null in modules/page_manager/page_manager_ui/src/Form/PageParametersForm.php on line 94

I think some of these also apply to the edit wizard.

yanniboi’s picture

StatusFileSize
new227.47 KB
new21.49 KB

Ok, so my patch replaces the Add variant form on a Page with the Add variant wizard.

Changes:

  1. Add variant and add variant step routes.
  2. Selection Criteria and Context steps of the variant wizard are optional
  3. Page Variant ids are always programatically generated using a "{$page->id()}-{$variant_plugin->id()}-{$delta}" pattern"
  4. Both the page add wizard and the variant add wizard share the same PageVariantConfigureForm step form.
  5. Updated PageManagerAdminTest to be aware of the currently required 'parameters' step.
  6. Updated PageManagerAdminTest to be aware of the variant wizard steps and variant ids.
yanniboi’s picture

Oops! 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

andrewbelcher’s picture

StatusFileSize
new10.67 KB

So @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 into Page which 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.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new227.47 KB

Here 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.

Status: Needs review » Needs work

The last submitted patch, 135: use_ctools_wizard_api-2550879-132.patch, failed testing.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new937 bytes
new227.82 KB

This 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.

Status: Needs review » Needs work

The last submitted patch, 137: use_ctools_wizard_api-2550879-137.patch, failed testing.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new227.82 KB
new5.98 KB

Here are a few changes based on @andrewbelcher's feedback at #131:

1. I think we normally only capitalise the first work (e.g. Page access rather than Page Access).

Changed.

2. Page access should come after Page parameters, as you may want to make use of those configured parameters.

Changed.

3. Page parameters only shows current user, which isn't in the path. This page should only show items from the path (which it doesn't show).

I need to look this into more depth.

4. Submitting Page parameters gave me:
PHP Fatal error: Call to a member function getUntranslatedSt
ring() on null in modules/page_manager/page_manager_ui/src/Form/PageParametersForm.php on line 94
I think some of these also apply to the edit wizard.

I could not reproduce this issue.

Status: Needs review » Needs work

The last submitted patch, 139: use_ctools_wizard_api-2550879-139.patch, failed testing.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new2.26 KB
new228.06 KB

Here 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.

Status: Needs review » Needs work

The last submitted patch, 141: use_ctools_wizard_api-2550879-141.patch, failed testing.

eclipsegc’s picture

I 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

andrewbelcher’s picture

@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 Page and PageVariant etc, 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?

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new3.55 KB
new226.22 KB

Now 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.

Status: Needs review » Needs work

The last submitted patch, 145: use_ctools_wizard_api-2550879-145.patch, failed testing.

andrewbelcher’s picture

As 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...

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new1.69 KB
new225.72 KB

This 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.

Status: Needs review » Needs work

The last submitted patch, 148: use_ctools_wizard_api-2550879-148.patch, failed testing.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new1.13 KB
new225.99 KB

This 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.

Status: Needs review » Needs work

The last submitted patch, 150: use_ctools_wizard_api-2550879-150.patch, failed testing.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new2.4 KB
new226.17 KB

This 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.

Status: Needs review » Needs work

The last submitted patch, 152: use_ctools_wizard_api-2550879-152.patch, failed testing.

juampynr’s picture

Just 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.

yanniboi’s picture

Status: Needs work » Needs review
StatusFileSize
new7.98 KB
new240.19 KB

Attaching 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...]

Status: Needs review » Needs work

The last submitted patch, 155: use_ctools_wizard_api-2550879-155.patch, failed testing.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new237.97 KB

Removed the changes maded to tests/src/Unit/PageVariantTest.php (I removed them already at #145). Now tests should pass.

juampynr’s picture

Tests 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.

andrewbelcher’s picture

  1. +++ b/config/schema/page_manager.schema.yml
    @@ -8,6 +8,9 @@ page_manager.page.*:
    +    description:
    +      type: text
    +      label: 'Description'
    

    Don'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...

  2. +++ b/config/schema/page_manager.schema.yml
    @@ -108,6 +112,14 @@ page_manager.block_plugin.*:
    +display_variant.plugin.block_page:
    +  type: display_variant.plugin
    +  label: 'Page with blocks'
    +
    +display_variant.plugin.simple_page:
    +  type: display_variant.plugin
    +  label: 'Simple page'
    +
    

    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...

  3. +++ b/src/Access/PageManagerPluginAccess.php
    @@ -0,0 +1,19 @@
    +<?php
    +/**
    + * @file
    + * Contains \Drupal\page_manager\Access\PageManagerPluginAccess.
    + */
    +
    +namespace Drupal\page_manager\Access;
    +
    +use Drupal\Core\Access\AccessResult;
    +use Drupal\Core\Session\AccountInterface;
    +use Drupal\ctools\Access\AccessInterface;
    +
    +class PageManagerPluginAccess implements AccessInterface {
    +
    +  public function access(AccountInterface $account) {
    +    return $account->hasPermission('administer pages') ? AccessResult::allowed() : AccessResult::forbidden();
    +  }
    +
    +}
    

    Do we need to add this as part of this patch? If so, perhaps it should be in p_m_ui?

  4. +++ b/src/Entity/Page.php
    @@ -139,6 +154,13 @@ class Page extends ConfigEntityBase implements PageInterface {
    +
    +    // Save the page variants just in case they were modified (or added) and
    +    // not saved independently.
    +    foreach ($this->getVariants() as $page_variant) {
    +      $page_variant->save();
    +    }
    +
    

    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?

  5. +++ b/src/Entity/Page.php
    @@ -139,6 +154,13 @@ class Page extends ConfigEntityBase implements PageInterface {
    @@ -300,7 +322,7 @@ class Page extends ConfigEntityBase implements PageInterface {
    
    @@ -300,7 +322,7 @@ class Page extends ConfigEntityBase implements PageInterface {
        * {@inheritdoc}
        */
       public function getContexts() {
    -    if (!$this->contexts) {
    +    if (empty($this->contexts)) {
    

    Is this change needed? An empty array will be typecast to FALSE anyway I think.

  6. +++ b/src/Entity/Page.php
    @@ -300,7 +322,7 @@ class Page extends ConfigEntityBase implements PageInterface {
    @@ -309,8 +331,21 @@ class Page extends ConfigEntityBase implements PageInterface {
    
    @@ -309,8 +331,21 @@ class Page extends ConfigEntityBase implements PageInterface {
       /**
        * {@inheritdoc}
        */
    +  public static function preDelete(EntityStorageInterface $storage, array $entities) {
    +    parent::preDelete($storage, $entities); // TODO: Change the autogenerated stub
    +  }
    

    This can surely go?

  7. +++ b/src/Entity/Page.php
    @@ -309,8 +331,21 @@ class Page extends ConfigEntityBase implements PageInterface {
       public function addVariant(PageVariantInterface $variant) {
    +    // If variants hasn't been initialized, we initialize it before adding the
    +    // new variant.
    +    if ($this->variants === NULL) {
    +      $this->getVariants();
    +    }
         $this->variants[$variant->id()] = $variant;
    +    $this->sortVariants();
         return $this;
       }
    

    I think I would prefer to see this in as a separate issue with test coverage.

  8. +++ b/src/Entity/Page.php
    @@ -309,8 +331,21 @@ class Page extends ConfigEntityBase implements PageInterface {
    @@ -330,6 +365,7 @@ class Page extends ConfigEntityBase implements PageInterface {
    
    @@ -330,6 +365,7 @@ class Page extends ConfigEntityBase implements PageInterface {
        */
       public function removeVariant($variant_id) {
         $this->getVariant($variant_id)->delete();
    +    unset($this->variants[$variant_id]);
         return $this;
       }
    

    Likewise for this...

  9. +++ b/src/Entity/Page.php
    @@ -330,6 +365,7 @@ class Page extends ConfigEntityBase implements PageInterface {
    @@ -343,23 +379,19 @@ class Page extends ConfigEntityBase implements PageInterface {
    
    @@ -343,23 +379,19 @@ class Page extends ConfigEntityBase implements PageInterface {
           foreach ($this->variantStorage()->loadByProperties(['page' => $this->id()]) as $variant) {
             $this->variants[$variant->id()] = $variant;
           }
    -      // Suppress errors because of https://bugs.php.net/bug.php?id=50688.
    -      @uasort($this->variants, [$this, 'variantSortHelper']);
    +      $this->sortVariants();
         }
         return $this->variants;
       }
     
       /**
    -   * {@inheritdoc}
    +   * Sort variants.
        */
    -  public function variantSortHelper($a, $b) {
    -    $a_weight = $a->getWeight();
    -    $b_weight = $b->getWeight();
    -    if ($a_weight == $b_weight) {
    -      return 0;
    +  protected function sortVariants() {
    +    if (isset($this->variants)) {
    +      // Suppress errors because of https://bugs.php.net/bug.php?id=50688.
    +      @uasort($this->variants, '\Drupal\page_manager\Entity\PageVariant::sort');
         }
    -
    -    return ($a_weight < $b_weight) ? -1 : 1;
       }
    

    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)

  10. +++ b/src/Entity/Page.php
    @@ -343,23 +379,19 @@ class Page extends ConfigEntityBase implements PageInterface {
    @@ -378,25 +410,26 @@ class Page extends ConfigEntityBase implements PageInterface {
    
    @@ -378,25 +410,26 @@ class Page extends ConfigEntityBase implements PageInterface {
       public function __sleep() {
         $vars = parent::__sleep();
     
    -    // Ensure any plugin collections are stored correctly before serializing.
    -    // @todo Let https://www.drupal.org/node/2650588 handle this instead.
    -    foreach ($this->getPluginCollections() as $plugin_config_key => $plugin_collection) {
    -      $this->set($plugin_config_key, $plugin_collection->getConfiguration());
    -    }
    -
    -    // Avoid serializing plugin collections and entities as they might contain
    -    // references to a lot of objects including the container.
    -    $unset_vars = [
    -      'variants',
    -      'accessConditionCollection',
    -    ];
    -    foreach ($unset_vars as $unset_var) {
    -      if (!empty($this->{$unset_var})) {
    -        unset($vars[array_search($unset_var, $vars)]);
    -      }
    +    // Avoid serializing the page executable as it represents runtime state.
    +    $key = array_search('executable', $vars);
    +    if ($key !== FALSE) {
    +      unset($vars[$key]);
         }
     
         return $vars;
       }
    

    Is this change necessary for our UI changes? If not, I think we should put it in a separate issue...

  11. +++ b/src/Entity/Page.php
    @@ -378,25 +410,26 @@ class Page extends ConfigEntityBase implements PageInterface {
    +  /**
    +   * {@inheritdoc}
    +   */
    +  protected function urlRouteParameters($rel) {
    +    if ($rel == 'edit-form') {
    +      $uri_route_parameters = [];
    +      $uri_route_parameters['step'] = 'general';
    +      return $uri_route_parameters;
    +    }
    +
    +    return parent::urlRouteParameters($rel);
    +  }
    

    I think this needs documenting with an @todo for when #2690211: Allow link templates for wizards goes in.

  12. +++ b/src/Entity/PageVariant.php
    @@ -86,6 +87,13 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    @@ -130,6 +138,13 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    
    @@ -130,6 +138,13 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
       protected $static_context = [];
     
       /**
    +   * The page object for the parent page.
    +   *
    +   * @var \Drupal\page_manager\PageInterface
    +   */
    +  protected $parentPage;
    

    I can't see anywhere this is used?

  13. +++ b/src/Entity/PageVariant.php
    @@ -69,7 +70,7 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    @@ -86,6 +87,13 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    
    @@ -86,6 +87,13 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
       protected $variant;
     
       /**
    +   * The loaded page entity this page variant entity belongs to.
    +   *
    +   * @var \Drupal\page_manager\PageInterface
    +   */
    +  protected $pageEntity;
    

    Can we mark this and related methods with an @fixme to remove when #2690047: Allow setting the Page on a PageVariant lands?

  14. +++ b/src/Entity/PageVariant.php
    @@ -212,6 +227,9 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    +      if (empty($this->variant_settings['uuid'])) {
    +        $this->variant_settings['uuid'] = $this->uuidGenerator()->generate();
    +      }
    

    Do we need this for our UI changes?

  15. +++ b/src/Entity/PageVariant.php
    @@ -212,6 +227,9 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    @@ -234,11 +252,34 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    
    @@ -234,11 +252,34 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
       /**
        * {@inheritdoc}
        */
    +  public function setVariantPluginId($variant) {
    +    $this->variant = $variant;
    +    return $this;
    +  }
    

    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?

  16. +++ b/src/Entity/PageVariant.php
    @@ -234,11 +252,34 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    @@ -246,9 +287,9 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    
    @@ -246,9 +287,9 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
        */
       public function getContexts() {
         if (is_null($this->contexts)) {
    -      $static_contexts = $this->getContextMapper()->getContextValues($this->getStaticContexts());
           $page_contexts = $this->getPage()->getContexts();
    -      $this->contexts = array_merge($static_contexts, $page_contexts);
    +      $variant_contexts = $this->getContextMapper()->getContextValues($this->getStaticContexts());
    +      $this->contexts = array_merge($variant_contexts, $page_contexts);
         }
         return $this->contexts;
       }
    

    This doesn't seem worth including with this patch (it's identical functionally).

  17. +++ b/src/Entity/PageVariant.php
    @@ -246,9 +287,9 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    @@ -429,8 +470,20 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    
    @@ -429,8 +470,20 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
       public function __sleep() {
         $vars = parent::__sleep();
         // Gathered contexts objects should not be serialized.
    -    unset($vars[array_search('contexts', $vars)]);
    +    $key = array_search('contexts', $vars);
    +    if ($key !== FALSE) {
    +      unset($vars[$key]);
    +    }
         return $vars;
       }
    

    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?

  18. +++ b/src/Entity/PageVariant.php
    @@ -429,8 +470,20 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    +  /**
    +   * Wraps the shared tempstore factory.
    +   *
    +   * @return \Drupal\user\SharedTempStoreFactory
    +   */
    +  protected function getTempstoreFactory() {
    +    return \Drupal::service('user.shared_tempstore');
    +  }
    +
    

    Why do we need to get the tempstore from the PageVariant?

  19. +++ b/src/Plugin/DisplayVariant/PageBlockDisplayVariant.php
    @@ -21,6 +21,8 @@ use Drupal\Core\Render\Element;
    @@ -31,7 +33,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
    
    @@ -31,7 +33,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
      *   admin_label = @Translation("Block page")
      * )
      */
    -class PageBlockDisplayVariant extends BlockDisplayVariant {
    +class PageBlockDisplayVariant extends BlockDisplayVariant implements PluginWizardInterface {
     
       /**
        * The module handler.
    @@ -248,6 +250,18 @@ class PageBlockDisplayVariant extends BlockDisplayVariant {
    
    @@ -248,6 +250,18 @@ class PageBlockDisplayVariant extends BlockDisplayVariant {
       /**
        * {@inheritdoc}
        */
    +  public function getWizardOperations($cached_values) {
    +    return [
    +      'content' => [
    +        'title' => $this->t('Content'),
    +        'form' => VariantPluginContentForm::class,
    +      ],
    +    ];
    +  }
    

    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?

  20. +++ b/src/Tests/PageTestHelperTrait.php
    @@ -13,13 +13,6 @@ namespace Drupal\page_manager\Tests;
    -   * @see \Drupal\simpletest\TestBase::$container
    -   *
    -   * @var \Symfony\Component\DependencyInjection\ContainerInterface
    -   */
    -  protected $container;
    -
    -  /**
    

    Should we be removing this?

  21. +++ b/src/Tests/PageTestHelperTrait.php
    @@ -13,13 +13,6 @@ namespace Drupal\page_manager\Tests;
    diff --git a/src/Tests/StaticContextTest.php b/src/Tests/StaticContextTest.php
    
    diff --git a/src/Tests/StaticContextTest.php b/src/Tests/StaticContextTest.php
    index 2b382e7..ad21a0b 100644
    
    index 2b382e7..ad21a0b 100644
    --- a/src/Tests/StaticContextTest.php
    
    --- a/src/Tests/StaticContextTest.php
    +++ b/src/Tests/StaticContextTest.php
    
    +++ b/src/Tests/StaticContextTest.php
    +++ b/src/Tests/StaticContextTest.php
    @@ -53,18 +53,10 @@ class StaticContextTest extends WebTestBase {
    

    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!

  22. +++ b/tests/src/Unit/PageTest.php
    +++ b/tests/src/Unit/PageTest.php
    @@ -49,10 +49,11 @@ class PageTest extends UnitTestCase {
    
    @@ -49,10 +49,11 @@ class PageTest extends UnitTestCase {
       public function testGetVariants() {
         $variant1 = $this->prophesize(PageVariantInterface::class);
         $variant1->id()->willReturn('variant1');
    -    $variant1->getWeight()->willReturn(0);
    +    $variant1->label()->willReturn('Variant 1');
         $variant2 = $this->prophesize(PageVariantInterface::class);
         $variant2->id()->willReturn('variant2');
    -    $variant2->getWeight()->willReturn(-10);
    +    $variant2->label()->willReturn('Variant 2');
    +    $variant2->weight = -10;
    

    Why do we need to make this change?

juampynr’s picture

StatusFileSize
new0 bytes
new2.7 KB
new240.77 KB

Here 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.

The last submitted patch, 160: test-only-2550879-160.patch, failed testing.

juampynr’s picture

StatusFileSize
new19.34 KB
new246.55 KB

Here 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

tim.plunkett’s picture

The patch is too big and has a massive scope. Everything that @andrewbelcher called out (and more) should be split to a new issue.

eclipsegc’s picture

1.) 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

yanniboi’s picture

2. 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.

juampynr’s picture

StatusFileSize
new1.18 KB
new245.7 KB

Here 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-10991695

andrewbelcher’s picture

@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 wizardOperations though as an alternative UI/use for plugins will probably still need to provide configuration forms for their variant plugins. Perhaps we can do something like configuration_forms?

juampynr’s picture

StatusFileSize
new3.26 KB
new247.55 KB

This 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?

Status: Needs review » Needs work

The last submitted patch, 169: use_ctools_wizard_api-2550879-169.patch, failed testing.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new1.8 KB
new247.46 KB

This patch fixes the failing test by inspecting the result of the AJAX request.

juampynr’s picture

StatusFileSize
new1.38 KB
new247.48 KB

Third 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-10991695

juampynr’s picture

juampynr’s picture

@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?

andrewbelcher’s picture

I 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.

eclipsegc’s picture

Status: Needs review » Needs work
  1. +++ b/page_manager_ui/src/Controller/PageManagerController.php
    @@ -147,14 +163,14 @@ class PageManagerController extends ControllerBase {
    +    $static_context = $page->getStaticContext($data_type);
    

    This seems like a regression, don't we need to get the contexts from the variant since that's where they're stored?

  2. +++ b/page_manager_ui/src/Controller/PageManagerController.php
    @@ -300,7 +316,22 @@ class PageManagerController extends ControllerBase {
    +    $cached_values = $this->tempstore->get('page_manager.block_display')->get($block_display);
    

    This route is meant to be reusable so odds are the tempstore id should be passed in as well.

  3. +++ b/page_manager_ui/src/Controller/PageManagerController.php
    @@ -300,7 +316,22 @@ class PageManagerController extends ControllerBase {
    +    foreach ($cached_values['contexts'] as $context_name => $context_definition) {
    +      $contexts[$context_name] = new Context($context_definition);
    +    }
    +    $variant_plugin->setContexts($contexts);
    

    I assume that we don't have the page_variant here to ask for contexts?

  4. +++ b/page_manager_ui/src/Form/PageAccessForm.php
    @@ -0,0 +1,81 @@
    +    $triggering_element = $form_state->getTriggeringElement();
    +    if ($triggering_element['#value']->getUntranslatedString() == 'Update') {
    +      return;
    +    }
    

    This looks like a prime candidate for a ctools patch, but fair enough for this patch for now, we can file a follow up.

  5. +++ b/page_manager_ui/src/Form/PageGeneralForm.php
    @@ -0,0 +1,190 @@
    +          'parameters' => $this->t('Page parameters'),
    

    As mentioned previously, page parameter configuration is only available when there are slugs in the path.

  6. +++ b/page_manager_ui/src/Form/PageGeneralForm.php
    @@ -0,0 +1,190 @@
    +            'label' => $form['variant_plugin_id']['#options'][$variant_plugin_id],
    

    LOL, ok sure.

  7. +++ b/page_manager_ui/src/Form/PageGeneralForm.php
    @@ -0,0 +1,190 @@
    +      if ($cached_values['variant_plugin_id'] != $form_state->getValue('variant_plugin_id') && !empty($cached_values['page_variant'])) {
    +        $page_variant = $cached_values['page_variant'];
    +        /** @var $page_variant \Drupal\page_manager\Entity\PageVariant */
    +        $page_variant->set('variant', $form_state->getValue('variant_plugin_id'));
    +        $page_variant->set('variant_settings', []);
    +        $cached_values['variant_plugin_id'] = $form_state->getValue('variant_plugin_id');
    +      }
    +
    

    Do we have test coverage for changing our mind about the type of variant we're creating mid-wizard?

  8. +++ b/page_manager_ui/src/Form/PageVariantSelectionForm.php
    @@ -0,0 +1,103 @@
    +    $triggering_element = $form_state->getTriggeringElement();
    +    if ($triggering_element['#value']->getUntranslatedString() != 'Add Condition') {
    +      return;
    +    }
    

    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.

  9. +++ b/page_manager_ui/src/Tests/PageManagerVariantAdminTest.php
    @@ -0,0 +1,59 @@
    \ No newline at end of file
    

    No newline!

  10. +++ b/page_manager_ui/src/Wizard/PageAddWizard.php
    @@ -0,0 +1,70 @@
    +      'form' => '\Drupal\page_manager_ui\Form\PageVariantContextsForm',
    ...
    +      'form' => '\Drupal\page_manager_ui\Form\PageVariantSelectionForm',
    ...
    +      'form' => '\Drupal\page_manager_ui\Form\PageVariantConfigureForm',
    

    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.

  11. +++ b/page_manager_ui/src/Wizard/PageVariantAddWizard.php
    @@ -0,0 +1,194 @@
    +    $operations['configure'] = [
    +      'title' => $this->t('Configure variant'),
    +      'form' => '\Drupal\page_manager_ui\Form\PageVariantConfigureForm',
    +    ];
    ...
    +      if ($variant_plugin instanceof PluginWizardInterface) {
    +        if ($variant_plugin instanceof ContextAwareVariantInterface) {
    +          $variant_plugin->setContexts($page_variant->getContexts());
    +        }
    +        $cached_values['plugin'] = $variant_plugin;
    +        foreach ($variant_plugin->getWizardOperations($cached_values) as $name => $operation) {
    +          $operation['values']['plugin'] = $variant_plugin;
    +          $operations[$name] = $operation;
    +        }
    +      }
    

    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.

  12. +++ b/page_manager_ui/src/Wizard/RouteParameters.php
    @@ -0,0 +1,84 @@
    +        'form' => 'Drupal\page_manager_ui\Form\ParameterAssignContextForm',
    ...
    +        'form' => 'Drupal\page_manager_ui\Form\ParameterSettingsForm',
    

    Another of those situations where we can do ClassName::class

  13. +++ b/src/Entity/Page.php
    @@ -394,25 +409,27 @@ class Page extends ConfigEntityBase implements PageInterface {
    +    // Avoid serializing the page executable as it represents runtime state.
    +    $key = array_search('executable', $vars);
    +    if ($key !== FALSE) {
    +      unset($vars[$key]);
    

    Pretty sure this doesn't exist anymore and we can stop doing this.

  14. +++ b/src/Entity/PageVariant.php
    @@ -69,7 +70,7 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    +  public $weight = 0;
    

    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

eclipsegc’s picture

StatusFileSize
new36.54 KB

So 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

andrewbelcher’s picture

In 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 PageEditWizard which 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, PageVariantConfigureForm doesn'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.

juampynr’s picture

Thanks 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.

juampynr’s picture

I 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.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new9.42 KB
new248.39 KB

I 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.

Status: Needs review » Needs work

The last submitted patch, 182: use_ctools_wizard_api-2550879-182.patch, failed testing.

eclipsegc’s picture

I'll look at this first thing in the morning.

Eclipse

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new2.37 KB
new249.14 KB

I 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.

juampynr’s picture

StatusFileSize
new259.41 KB
new10.41 KB

Here I have removed StaticContextAddForm.php, StaticContextEditForm.php and StaticContextFormBase.php because they have been replaced by StaticContextConfigure.php and StaticContextDelete.php.

andrewbelcher’s picture

I 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?

juampynr’s picture

StatusFileSize
new3.17 KB

@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.

juampynr’s picture

StatusFileSize
new3.5 KB
new260.16 KB

I 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.

eclipsegc’s picture

+++ b/src/Entity/Page.php
@@ -317,6 +319,19 @@ class Page extends ConfigEntityBase implements PageInterface {
+          $value = isset($parameter['value']) ?: NULL;

That will always return boolean or NULL.

+++ b/src/Entity/Page.php
@@ -317,6 +319,19 @@ class Page extends ConfigEntityBase implements PageInterface {
+      if ($this->isNew()) {

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

juampynr’s picture

StatusFileSize
new14.89 KB
new258.68 KB

First 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:

1. This seems like a regression, don't we need to get the contexts from the variant since that's where they're stored?

Pending. I have not looked at this yet.

2. This route is meant to be reusable so odds are the tempstore id should be passed in as well.

Pending. I have not looked at this yet.

3. I assume that we don't have the page_variant here to ask for contexts?

Pending. I have not looked at this yet.

4. This looks like a prime candidate for a ctools patch, but fair enough for this patch for now, we can file a follow up.

Ok, ignoring it until then.

5. As mentioned previously, page parameter configuration is only available when there are slugs in the path.

Pending. I have not looked at this yet.

6. LOL, ok sure.

Pending. I have not looked at this yet.

7. Do we have test coverage for changing our mind about the type of variant we're creating mid-wizard?

Pending. I have not looked at this yet.

8. 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.

Pending. I have not looked at this yet.

9. No newline!

Removed whole test as it was not testing anything.

10. 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.

Changed these and other instances.

11. 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.

Pending. I have not looked at this yet.

12. Another of those situations where we can do ClassName::class

Fixed this and many other instances in the patch.

13. Pretty sure this doesn't exist anymore and we can stop doing this.

Removed.

14. Do we still need this with the way #2692397: Adding/removing variants leaves Page::$variants out of date is working?

Removed.

eclipsegc’s picture

StatusFileSize
new255.61 KB
new38.21 KB

This is a cross-post to 191, so it does not include the interdiff from there.

Changes:

  1. I've updated ctools to include contexts, so the schema, routing and UI have been converted to that use case.
  2. This means we have description support for contexts now.
  3. Fixed a bug that redirected context deletes to the selection criteria step.
  4. Added logic to add/remove the parameters step when appropriate. I did not yet update the general page to correspond to this.
  5. Improved the logic of the various parameter methods on the page entity so that they won't return parameters except for those defined in the path of the page.
  6. Added parameters to the contexts of the page.
  7. Added logic to correctly sort contexts from the page/variant.
  8. Switched to using the ctools.context_mapper (identical to page_managers, but that was code that should live in ctools)
  9. Added additional test coverage for the preSave logic that surrounds parameters to ensure that what's saved is clean.
  10. Updated tests to match the new ctools contexts stuff.

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

Status: Needs review » Needs work

The last submitted patch, 192: 2550879-192.patch, failed testing.

eclipsegc’s picture

Ok, 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

juampynr’s picture

Ok, 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.

I 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!

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new11.75 KB
new255.83 KB

Here it is. I will now go through a second round on the feedback at #177 plus @andrewbelcher's on #179.

juampynr’s picture

StatusFileSize
new2.36 KB
new256.4 KB

Second 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:

1. This seems like a regression, don't we need to get the contexts from the variant since that's where they're stored?

This callback is not used. Removed.

2. This route is meant to be reusable so odds are the tempstore id should be passed in as well.

Adjusted callback.

3. I assume that we don't have the page_variant here to ask for contexts?

Pending. I have not looked at this yet.

4. This looks like a prime candidate for a ctools patch, but fair enough for this patch for now, we can file a follow up.

Ok, ignoring it until then.

5. As mentioned previously, page parameter configuration is only available when there are slugs in the path.

This is gone already.

6. LOL, ok sure.

This is gone.

7. Do we have test coverage for changing our mind about the type of variant we're creating mid-wizard?

Pending. I have not looked at this yet.

8. 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.

OK. Ignoring it then.

9. No newline!

Removed whole test as it was not testing anything.

10. 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.

Changed these and other instances.

11. 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.

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?

12. Another of those situations where we can do ClassName::class

Fixed this and many other instances in the patch.

13. Pretty sure this doesn't exist anymore and we can stop doing this.

Removed.

14. Do we still need this with the way #2692397: Adding/removing variants leaves Page::$variants out of date is working?

Removed.

eclipsegc’s picture

Ignore 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

tim.plunkett’s picture

  1. +++ b/src/Entity/Page.php
    @@ -223,7 +240,11 @@ class Page extends ConfigEntityBase implements PageInterface {
       public function getParameters() {
    -    return $this->parameters;
    +    $names = $this->getParameterNames();
    +    if ($names) {
    +      return array_intersect_key($this->parameters, array_flip($names));
    +    }
    +    return [];
       }
    
    @@ -281,8 +302,10 @@ class Page extends ConfigEntityBase implements PageInterface {
    -    foreach ($this->getParameters() as $name => $parameter) {
    -      if (empty($parameter['type'])) {
    +    $names = $this->getParameterNames();
    +    foreach ($this->get('parameters') as $name => $parameter) {
    +      // Remove parameters without any type, or which are no longer valid.
    +      if (empty($parameter['type']) || !in_array($name, $names)) {
    

    If you change getParameters, why do you need to change filterParemeters as well?

  2. +++ b/src/Entity/PageVariant.php
    @@ -248,7 +285,7 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    +      $this->contexts = array_reverse(array_merge(array_reverse($static_contexts), array_reverse($page_contexts)));
    

    reverse x3? Are we sure that's needed? Is there test coverage for it?

  3. +++ b/src/Entity/PageVariant.php
    @@ -411,7 +448,7 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    -    return \Drupal::service('page_manager.context_mapper');
    +    return \Drupal::service('ctools.context_mapper');
    
    index b2a0db2..0000000
    --- a/src/Entity/PageVariantConfigMapper.php
    
    --- a/src/Entity/PageVariantConfigMapper.php
    +++ /dev/null
    

    Out of scope

  4. +++ b/src/Entity/PageVariant.php
    @@ -429,7 +466,10 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    -    unset($vars[array_search('contexts', $vars)]);
    +    $key = array_search('contexts', $vars);
    +    if ($key !== FALSE) {
    +      unset($vars[$key]);
    +    }
    
    +++ b/src/Plugin/DisplayVariant/HttpStatusCodeDisplayVariant.php
    @@ -84,4 +84,13 @@ class HttpStatusCodeDisplayVariant extends VariantBase {
    +    $key = array_search('stringTranslation', $vars);
    +    if ($key !== FALSE) {
    +      unset($vars[$key]);
    +    }
    
    +++ b/src/Plugin/DisplayVariant/PageBlockDisplayVariant.php
    @@ -300,4 +314,10 @@ class PageBlockDisplayVariant extends BlockDisplayVariant {
    +    unset($vars[array_search('stringTranslation', $vars)]);
    

    Pick one way to do it and stick to it

  5. +++ b/src/Plugin/DisplayVariant/HttpStatusCodeDisplayVariant.php
    @@ -84,4 +84,13 @@ class HttpStatusCodeDisplayVariant extends VariantBase {
    +  public function __sleep() {
    
    +++ b/src/Plugin/DisplayVariant/PageBlockDisplayVariant.php
    @@ -300,4 +314,10 @@ class PageBlockDisplayVariant extends BlockDisplayVariant {
    +  public function __sleep() {
    

    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?

  6. +++ b/src/Plugin/DisplayVariant/PageBlockDisplayVariant.php
    @@ -21,6 +21,8 @@ use Drupal\Core\Render\Element;
    +use Drupal\page_manager_ui\Form\VariantPluginContentForm;
    
    @@ -248,6 +250,18 @@ class PageBlockDisplayVariant extends BlockDisplayVariant {
    +  public function getWizardOperations($cached_values) {
    +    return [
    +      'content' => [
    +        'title' => $this->t('Content'),
    +        'form' => VariantPluginContentForm::class,
    +      ],
    +    ];
    +  }
    

    Any way for this to be added on somehow by the UI?

andrewbelcher’s picture

@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?

reverse x3? Are we sure that's needed? Is there test coverage for it?

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...

eclipsegc’s picture

Status: Needs review » Needs work

199.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

eclipsegc’s picture

Status: Needs work » Needs review
StatusFileSize
new278.2 KB
new31.01 KB

Ok, 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.

  1. Add Variant Wizard opened in a tiny modal: FIXED
  2. Page contexts should reflect the current state of the Parameters without needing to "save" the page. This was an interesting bug and had a number of moving parts, but the biggest issue here was that during UI we load parameter settings from the route object. This is honestly awesome except that we can't differentiate between global contexts and route parameters at the "context" layer. In order to get this working I hard-coded an array that could contain a list of global contexts. That sucks, but we have exactly 1 of those right now, so it's no onerous. We should probably retool the context gathering process and include in that the ability to denote where contexts are coming from to make more intelligent decisions here. This is DEFINITELY a follow up to this issue.
  3. The "Add Variant Wizard" is awesome, and also the newest bit of this code path. Testing it I found that Contexts and selection criteria didn't work at all during the actual wizard. This is due to the fact that it uses a different tempstore and a whole new set of urls, so I had to introduce classes and routes to match. It works now, we need test coverage to prove it.
  4. Also of note, in 201 I mentioned that we should standardize on the PageVariant::__sleep approach in our code, however... StaticContextTest fails when we switch over to this methodology. Towards the end of the interdiff you'll see my big WTF comment around this which includes the two sets of code side by side. If you'd like, you can uncomment and run StaticContextTest for yourself and watch it fail. I don't know what gives here and it is possible that I've just been staring at the same code for 12 hours today and can't see it properly any longer.

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

yanniboi’s picture

Status: Needs review » Needs work

@EclipseGc I've had a look at the differences in PageBlockDisplayVariant::__sleep()

For reference, the 2 versions are as follows:

<?php
    $vars = parent::__sleep();
    $key = array_search('stringTranslation', $vars);
    if ($key !== FALSE) {
      unset($vars[$key]);
    }
    return $vars;

    // And...

    $vars = parent::__sleep();
    unset($vars[array_search('stringTranslation', $vars)]);
    return $vars;

?>

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 to unset($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.

andrewbelcher’s picture

As mentioned in #200 - I've been working on the __sleep issue - 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.

yanniboi’s picture

StatusFileSize
new282.91 KB
new882 bytes

Tiny typo fix 'acess' => 'access'

yanniboi’s picture

StatusFileSize
new56.97 KB

Also I spotted something weird with the context selection dropdown.

Context 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.

eclipsegc’s picture

Yanni,

Can you file 206 against ctools?

Eclipse

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new390 bytes
new282.66 KB

There 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.

Status: Needs review » Needs work

The last submitted patch, 208: use_ctools_wizard_api-2550879-208.patch, failed testing.

juampynr’s picture

And 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:

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state, $page = NULL) {
    $form = parent::buildForm($form, $form_state); // TODO: Change the autogenerated stub

    // Get the page tempstore so we can modify the unsaved page.
    if (!isset($cached_values['page']) || !$cached_values['page']->id()) {
      $cached_values = $form_state->getTemporaryValue('wizard');
eclipsegc’s picture

Juampy,

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

eclipsegc’s picture

StatusFileSize
new277.35 KB
new1.48 KB

Ok, 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

eclipsegc’s picture

Status: Needs work » Needs review

oops

The last submitted patch, 65: page_manager-wizard-2550879-65.patch, failed testing.

The last submitted patch, 74: use_ctools_wizard_api-2550879-74.patch, failed testing.

The last submitted patch, 75: use_ctools_wizard_api-2550879-75.patch, failed testing.

The last submitted patch, 76: use_ctools_wizard_api-2550879-76.patch, failed testing.

The last submitted patch, 79: use_ctools_wizard_api-2550879-79.patch, failed testing.

The last submitted patch, 81: use_ctools_wizard_api-2550879-81.patch, failed testing.

The last submitted patch, 78: use_ctools_wizard_api-2550879-78.patch, failed testing.

The last submitted patch, 105: use_ctools_wizard_api-2550879-105.patch, failed testing.

The last submitted patch, 110: use_ctools_wizard_api-2550879-110.patch, failed testing.

The last submitted patch, 132: use_ctools_wizard_api-2550879-132.patch, failed testing.

The last submitted patch, 133: use_ctools_wizard_api-2550879-133.patch, failed testing.

The last submitted patch, 205: 2550879-204.patch, failed testing.

andrewbelcher’s picture

Ok, 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.?

samuel.mortenson’s picture

Status: Needs review » Needs work

Doing a quick manual review:

  1. I can't re-order variants - complete the wizard with one variant, add another variant, then try to re-order those variants at "Reorder variants"
  2. Using the "Block Page" variant - I can't drag Blocks between regions. Re-ordering within regions or using the dropdown works, but actually dragging one block between regions no longer works.
  3. I got one of my pages to start throwing the error: "Fatal error: Call to a member function id() on a non-object in .../page_manager/page_manager_ui/src/Wizard/PageEditWizard.php on line 39". From my debugging it looks like somehow Block placement in the "Block Page" variant is using the same tempstore key as deleted variants, which sounds crazy but can be replicated. 1) Add a page that uses the Block Variant, place any block. 2) After the wizard is done, move that block to a new region/change its weight and click "Update". 3) Attempt to delete the Block Page variant.
eclipsegc’s picture

Status: Needs work » Needs review
StatusFileSize
new284.65 KB
new8.13 KB

Test coverage for the context and selection criteria steps in the Add Variant wizard.

Hopped on a hangout with mortenson re:227:

  1. Variants are reordered properly but the reorder screen does not order them appropriately. I'm working on this now.
  2. I was aware of this one and am working on it after the reordering issue.
  3. I've not attempted this yet, but I'll dig into it after I fix the previous two. I have some suspicions but this is a complex bit.
eclipsegc’s picture

StatusFileSize
new284.83 KB
new745 bytes

Fix for 227.1

eclipsegc’s picture

227.2 is reproduce-able in HEAD without the wizard patch, so I'm calling that out of scope.

eclipsegc’s picture

I could not reproduce 227.3 Maybe we can do a hangout tomorrow and nail this down?

Eclipse

andrewbelcher’s picture

As per conversation with @EclipseGc, I've opened #2696683: Update wizard to support link templates as a follow up and removed the pm-ui-blocker tag from #2690211: Allow link templates for wizards.

andrewbelcher’s picture

StatusFileSize
new287.28 KB
new18.75 KB

I'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...

Status: Needs review » Needs work

The last submitted patch, 233: 2550879-233-non_ui_changes.patch, failed testing.

andrewbelcher’s picture

StatusFileSize
new8.22 KB

Hmm... interdiff didn't upload, here's to trying again!

andrewbelcher’s picture

A quick skim over the API changes:

  1. index dab379b..05fe7bf 100644
    --- a/config/schema/page_manager.schema.yml
    
    --- a/config/schema/page_manager.schema.yml
    +++ b/config/schema/page_manager.schema.yml
    
    +++ b/config/schema/page_manager.schema.yml
    @@ -65,6 +65,7 @@ page_manager.page_variant.*:
    
    @@ -65,6 +65,7 @@ page_manager.page_variant.*:
           label: 'Display variant'
         variant_settings:
           type: display_variant.plugin.[%parent.variant]
    +      label: 'Variant settings'
         page:
           type: string
           label: 'Parent page'
    @@ -81,18 +82,8 @@ page_manager.page_variant.*:
    
    @@ -81,18 +82,8 @@ page_manager.page_variant.*:
           type: sequence
           label: Static context list
           sequence:
    -        - type: mapping
    +        - type: ctools.context
               label: 'Static context'
    -          mapping:
    -            label:
    -              type: label
    -              label: 'Label of the context'
    -            type:
    -              type: string
    -              label: 'Context type'
    -            value:
    -              type: string
    -              label: 'Context value'
    

    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...

  2. +++ b/config/schema/page_manager.schema.yml
    @@ -81,18 +82,8 @@ page_manager.page_variant.*:
    diff --git a/page_manager.module b/page_manager.module
    
    diff --git a/page_manager.module b/page_manager.module
    deleted file mode 100644
    
    deleted file mode 100644
    index 422f159..0000000
    
    index 422f159..0000000
    --- a/page_manager.module
    
    --- a/page_manager.module
    +++ /dev/null
    
    +++ /dev/null
    +++ /dev/null
    @@ -1,19 +0,0 @@
    
    @@ -1,19 +0,0 @@
    -<?php
    -
    -/**
    - * @file
    - * Provides hook implementations for Page Manager.
    - */
    -
    -use Drupal\page_manager\Entity\PageVariantConfigMapper;
    -
    -/**
    - * Implements hook_config_translation_info_alter().
    - *
    - * @todo Remove once https://www.drupal.org/node/2670712 is in.
    - */
    -function page_manager_config_translation_info_alter(&$info) {
    -  if (isset($info['page_variant'])) {
    -    $info['page_variant']['class'] = PageVariantConfigMapper::class;
    -  }
    -}
    

    @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?

  3. +++ b/src/Entity/Page.php
    @@ -244,7 +246,11 @@ class Page extends ConfigEntityBase implements PageInterface {
       public function getParameters() {
    -    return $this->parameters;
    +    $names = $this->getParameterNames();
    +    if ($names) {
    +      return array_intersect_key($this->parameters, array_flip($names));
    +    }
    +    return [];
       }
    

    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?

  4. +++ b/src/Entity/Page.php
    @@ -244,7 +246,11 @@ class Page extends ConfigEntityBase implements PageInterface {
    @@ -266,6 +272,12 @@ class Page extends ConfigEntityBase implements PageInterface {
    
    @@ -266,6 +272,12 @@ class Page extends ConfigEntityBase implements PageInterface {
           'type' => $type,
           'label' => $label,
         ];
    +    // Reset contexts when a parameter is added or changed.
    +    $this->contexts = [];
    +    // Reset the contexts of every variant.
    +    foreach ($this->getVariants() as $page_variant) {
    +      $page_variant->resetCollectedContexts();
    +    }
         return $this;
       }
     
    @@ -274,6 +286,12 @@ class Page extends ConfigEntityBase implements PageInterface {
    
    @@ -274,6 +286,12 @@ class Page extends ConfigEntityBase implements PageInterface {
        */
       public function removeParameter($name) {
         unset($this->parameters[$name]);
    +    // Reset contexts when a parameter is removed.
    +    $this->contexts = [];
    +    // Reset the contexts of every variant.
    +    foreach ($this->getVariants() as $page_variant) {
    +      $page_variant->resetCollectedContexts();
    +    }
         return $this;
       }
    

    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?

  5. +++ b/src/Entity/Page.php
    @@ -274,6 +286,12 @@ class Page extends ConfigEntityBase implements PageInterface {
    @@ -302,8 +320,10 @@ class Page extends ConfigEntityBase implements PageInterface {
    
    @@ -302,8 +320,10 @@ class Page extends ConfigEntityBase implements PageInterface {
        * @return $this
        */
       protected function filterParameters() {
    -    foreach ($this->getParameters() as $name => $parameter) {
    -      if (empty($parameter['type'])) {
    +    $names = $this->getParameterNames();
    +    foreach ($this->get('parameters') as $name => $parameter) {
    +      // Remove parameters without any type, or which are no longer valid.
    +      if (empty($parameter['type']) || !in_array($name, $names)) {
             $this->removeParameter($name);
           }
         }
    

    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...

  6. +++ b/src/Entity/Page.php
    @@ -321,8 +341,26 @@ class Page extends ConfigEntityBase implements PageInterface {
       public function getContexts() {
    +    // @todo add the other global contexts here as they are added
    +    // @todo maybe come up with a non-hardcoded way of doing this?
    +    $global_contexts = [
    +      'current_user'
    +    ];
         if (!$this->contexts) {
           $this->eventDispatcher()->dispatch(PageManagerEvents::PAGE_CONTEXT, new PageManagerContextEvent($this));
    +      foreach ($this->getParameters() as $machine_name => $configuration) {
    +        // Parameters can be updated in the UI, so unless it's a global context
    +        // we'll need to rely on the current settings in the tempstore instead
    +        // of the ones cached in the router.
    +        if (!isset($global_contexts[$machine_name])) {
    +          $value = NULL;
    +          if (isset($this->contexts[$machine_name])) {
    +            $value = $this->contexts[$machine_name]->getContextValue();
    +          }
    +          $context_definition = new ContextDefinition($configuration['type'], $configuration['label']);
    +          $this->contexts[$machine_name] = new Context($context_definition, $value);
    +        }
    +      }
         }
         return $this->contexts;
       }
    

    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?

  7. +++ b/src/Entity/Page.php
    @@ -425,4 +463,18 @@ class Page extends ConfigEntityBase implements PageInterface {
    +  /**
    +   * {@inheritdoc}
    +   */
    +  protected function urlRouteParameters($rel) {
    +    // @fixme Remove when https://www.drupal.org/node/2690211 gets fixed.
    +    if ($rel == 'edit-form') {
    +      $uri_route_parameters = [];
    +      $uri_route_parameters['machine_name'] = $this->id();
    +      $uri_route_parameters['step'] = 'general';
    +      return $uri_route_parameters;
    +    }
    +
    +    return parent::urlRouteParameters($rel);
    +  }
    

    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?

  8. +++ b/src/Entity/PageVariant.php
    @@ -222,6 +222,9 @@ class PageVariant extends ConfigEntityBase implements PageVariantInterface {
    +      if (empty($this->variant_settings['uuid'])) {
    +        $this->variant_settings['uuid'] = $this->uuidGenerator()->generate();
    +      }
    

    Is this necessary for the UI changes?

  9. +++ b/src/Plugin/DisplayVariant/PageBlockDisplayVariant.php
    @@ -248,6 +250,18 @@ class PageBlockDisplayVariant extends BlockDisplayVariant {
       /**
        * {@inheritdoc}
        */
    +  public function getWizardOperations($cached_values) {
    +    return [
    +      'content' => [
    +        'title' => $this->t('Content'),
    +        'form' => VariantPluginContentForm::class,
    +      ],
    +    ];
    +  }
    

    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.

  10. +++ b/src/Tests/PageTestHelperTrait.php
    @@ -13,13 +13,6 @@ namespace Drupal\page_manager\Tests;
       /**
    -   * @see \Drupal\simpletest\TestBase::$container
    -   *
    -   * @var \Symfony\Component\DependencyInjection\ContainerInterface
    -   */
    -  protected $container;
    

    Is this change necessary for our UI changes?

juampynr’s picture

@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 76

This is a CTools error. I have fixed it locally and will create an issue at the module's issue queue.

juampynr’s picture

juampynr’s picture

I 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.

juampynr’s picture

@EclipseGc, @samuel.mortenson, I could not reproduce #227.3 either.

eclipsegc’s picture

StatusFileSize
new285.37 KB
new2.44 KB

This 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:

  1. Create a page with any variant.
  2. Delete that variant
  3. Add a new block_page variant with two blocks in the same regions
  4. Click "Finish"
  5. reorder the two blocks (still in same region)
  6. Click "Update"
  7. Delete the variant.

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:


[
'0' => PageVariant...,
'1' => PageVariant...,
'2' => PageVariant...,
]

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

eclipsegc’s picture

StatusFileSize
new280.41 KB

Rebased for other commits.

Eclipse

juampynr’s picture

Just 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.

andrewbelcher’s picture

StatusFileSize
new280.43 KB
new1.47 KB
new20.41 KB

This patch addresses:

#236.7 by switching to an @todo to remove as part of #2696683: Update wizard to support link templates.
#236.10 by adding an @fixme to 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_ui for easy review.

andrewbelcher’s picture

StatusFileSize
new281.17 KB
new2.98 KB
new21.15 KB

I'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.

andrewbelcher’s picture

@EclipseGc regarding #236.9 it looks to me like we have five options:

1. As is but without silent dependency
Which would mean wrapping ::getWizardOperations in a check whether page_manager_ui is 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 of PluginWizardInterface.

4. Pull the information from annotations
::getWizardOperations could inspect the annotation to see whether there are any wizard operations to make use of. page_manager_ui can 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.

eclipsegc’s picture

Responding to 236:

  • 236.1
    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.
  • 236.2
    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.
  • 236.3
    It won't be saved improperly because of ::filterParameters which cleans up during ::preSave().
  • 236.4
    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.
  • 236.5
    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.
  • 236.6
    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).
  • 236.7
    Looks like you handled that already.
  • 236.8
    It is necessary yes.
  • 236.9
    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.
  • 236.10
    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

eclipsegc’s picture

Status: Needs review » Fixed
StatusFileSize
new281.17 KB

After 7 months of effort from a crew of great contributors I'm calling this done. I've attached the committed patch.

Eclipse

tim.plunkett’s picture

This 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.

eclipsegc’s picture

Indeed you did, sorry I just copied what d.o generated. My bad.

Eclipse

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

damienmckenna’s picture