See meta-issue: #2511554: [meta] Move some parts of Page Manager into CTools

Currently, Page Manager has BlockDisplayVariant, which contains much of the same code that we'd want in Panels' display variant, but we don't want Panels to depend on Page Manager.

Also, there are people sub-classing BlockDisplayVariant for use on Drupal 8 in production today!

The proposal is to move it into CTools and then both Page Manager and Panels can use it. Also, BlockDisplayVariant isn't very useful unless sub-classed, so it makes sense to make it abstract so that the only people who are using it are sub-classing it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dsnopek’s picture

Title: Make an abstract version of Drupal\page_manager\Plugin\DisplayVariant\BlockDisplayVariant from Page Manager » Add an abstract version of Drupal\page_manager\Plugin\DisplayVariant\BlockDisplayVariant from Page Manager
dsnopek’s picture

dsnopek’s picture

Issue tags: +D8panels

Adding to the sprint board because a Panels issue is blocked on this one: #2511582: Extend BlockDisplayVariant rather than copying code from Page Manager

tim.plunkett’s picture

Priority: Normal » Major
Status: Postponed » Active

This is the next step.

lslinnet’s picture

Assigned: Unassigned » lslinnet

Gonna give this a go either later tonight or tomorrow morning, had a quick talk with Tim & Kris regarding the associated traits, it got decided to also move these to ctools.

dsnopek’s picture

@lslinnet: Most of the traits should be moving into CTools in #2511556: Add BlockVariantInterface (and Trait), and BlockPluginCollection from Page Manager, however, some of them got de-scoped (by EclipseGC) because they won't be necessary once #2551633: Make variants into their own config entity is done. That said, if we need them just to finish this issue, I'd be all for adding them back to the scope of that issue, and then removing them later when they are obsolete.

lslinnet’s picture

Status: Active » Needs work
FileSize
27.26 KB

Here is the initial go at the move, fairly certain additional work is needed (like tests)

japerry’s picture

Status: Needs work » Needs review
FileSize
24 KB

Here is a re-write of them

dsnopek’s picture

Unfortunately, #2551633: Make variants into their own config entity makes lots of changes to BlockDisplayVariant (actually, simplifying it and removing some of the necessary interfaces and traits). I don't really know how long it'll take to get that committed (hopefully, not long!) but it might make sense to postpone this one on that one.

japerry’s picture

Status: Needs review » Needs work
FileSize
44.37 KB

Heya, so unfortunately I think we're going to do this first because its blocking a whole bunch of issues.

Here is some re-writing with tests that need to be redone by Tim.

EclipseGc’s picture

This is a review of 8, should basically apply to 10.

  1. +++ b/src/Form/AjaxFormTrait.php
    @@ -0,0 +1,48 @@
    +  protected function getAjaxAttributes() {
    +    return [
    +      'class' => ['use-ajax'],
    +      'data-dialog-type' => 'modal',
    +      'data-dialog-options' => Json::encode([
    +        'width' => 'auto',
    +      ]),
    +    ];
    +  }
    +
    +  /**
    +   * Gets attributes for use with an add button AJAX modal.
    +   *
    +   * @return array
    +   */
    +  protected function getAjaxButtonAttributes() {
    +    return NestedArray::mergeDeep($this->getAjaxAttributes(), [
    +      'class' => [
    +        'button',
    +        'button--small',
    +        'button-action',
    +      ],
    +    ]);
    

    Not a problem for this code move, but I think we should consider making these static methods.

  2. +++ b/src/Plugin/BlockVariantTrait.php
    @@ -0,0 +1,120 @@
    +  public function getRegionNames() {
    +    return [
    +      'top' => 'Top',
    +      'bottom' => 'Bottom',
    +    ];
    +  }
    

    Don't implement this. The user of the trait will need to manually implement this method.

  3. +++ b/src/Plugin/ConditionVariantInterface.php
    @@ -0,0 +1,92 @@
    +<?php
    +
    +/**
    + * @file
    + * Contains \Drupal\ctools\Plugin\ConditionVariantInterface.
    + */
    +
    +namespace Drupal\ctools\Plugin;
    +
    +use Drupal\Core\Display\VariantInterface;
    +
    +/**
    + * Provides an interface for variant plugins that use condition plugins.
    + */
    +interface ConditionVariantInterface extends VariantInterface {
    

    Ok... so I'll move this to ctools, but no one can ever ever use this beyond the scope of this patch because we need to move this back out ultimately and apply these methods to the PageVariant entity we have pending.

  4. +++ b/src/Plugin/ContextAwareVariantInterface.php
    @@ -0,0 +1,33 @@
    +<?php
    +
    +/**
    + * @file
    + * Contains \Drupal\ctools\Plugin\ContextAwareVariantInterface.
    + */
    +
    +namespace Drupal\ctools\Plugin;
    +
    +/**
    + * Provides an interface for variant plugins that are context-aware.
    + */
    +interface ContextAwareVariantInterface {
    

    We're trying to get this into core right now, so we're likely to remove this shortly, but ok.

Also there are 21 use statements on our BlockDisplayVariant... I didn't apply this code yet, are they all used? Please delete those which aren't if any.

Eclipse

dsnopek’s picture

Is there any way we could fast track review/commit of #2551633: Make variants into their own config entity? It's also blocking some important issues, including the massively important wizard changes!

Also, the patch on #2551633: Make variants into their own config entity removes all the code that EclipseGC doesn't like. :-) So, this patch would be much, much simpler after the other is merged.

japerry’s picture

FileSize
42.16 KB

Here are some other changes based on EclipseGC's review. Still need one test done but lets see if this passes the others.

japerry’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 13: 2511566-13.patch, failed testing.

japerry’s picture

Status: Needs work » Needs review
FileSize
42.16 KB

Try it again.

Status: Needs review » Needs work

The last submitted patch, 16: 2511566-13.patch, failed testing.

The last submitted patch, 16: 2511566-13.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
30.29 KB
15.27 KB

The last submitted patch, 13: 2511566-13.patch, failed testing.

The last submitted patch, 16: 2511566-13.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 19: 2511566-ctools-18.patch, failed testing.

japerry queued 19: 2511566-ctools-18.patch for re-testing.

The last submitted patch, 19: 2511566-ctools-18.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
30.29 KB
2.23 KB

A couple bugs still. Since VariantBase now uses RefinableCacheableDependencyTrait, we cannot use it while extending.

Status: Needs review » Needs work

The last submitted patch, 25: 2511566-ctools-25.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
30.23 KB
2.81 KB

More fixes.

The last submitted patch, 25: 2511566-ctools-25.patch, failed testing.

  • tim.plunkett committed 45fbd13 on 8.x-3.x
    Issue #2511566 by japerry, tim.plunkett, lslinnet: Add an abstract...
tim.plunkett’s picture

Status: Needs review » Fixed

Committed!

Status: Fixed » Closed (fixed)

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