Problem/Motivation

ContextAwarePluginAssignmentTrait allows configuring the context mapping where there are multiple matching contexts, but it does not support to not pass a value to a non-required context.

I encountered this with Page Manager, where a matching context needs to be prevented from being passed on to a views block contextual filter.

Proposed resolution

Add a "- None -" option if the context is not required.

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Arla’s picture

Status: Active » Needs review
FileSize
1.04 KB
Arla’s picture

Issue tags: +needs test

In Core, this trait is only used by ConditionFormBase. None of the condition plugins have optional contexts, so, for testing, I guess we need another test condition plugin.

Arla’s picture

The empty mappings should not be stored, because then ContextHandler::applyContextMapping() breaks.

Status: Needs review » Needs work

The last submitted patch, 3: context-optional-2484645-3.patch, failed testing.

Bojhan’s picture

Can we start up the design process? including all the UI work?

The last submitted patch, 3: context-optional-2484645-3.patch, failed testing.

giancarlosotelo’s picture

Rebased and I found a plugin test in Blocks with context mapping, so I am using it and also adding the test to a function that is testing context mapping but I don't know if is the best way.

The last submitted patch, 11: context-optional-ONLYTEST.patch, failed testing.

The last submitted patch, 11: context-optional-ONLYTEST.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 11: context-optional-2484645-11.patch, failed testing.

Status: Needs work » Needs review
Arla’s picture

Status: Needs review » Needs work

Nice. Would be great if we can also test the block in action. I don't really understand the existing test - the block does not appear because it accepts context? Can we not place the block in some region, select "None" for the context mapping, and check that the block shows up? (As said, I'm not really sure how this stuff works...)

giancarlosotelo’s picture

Status: Needs work » Needs review
FileSize
1.47 KB
4.03 KB

Ok, I am editing the block and set the context to none to check the result of the block.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

Test looks OK to me.

In #2377757: Expose Block Context mapping in the UI, toward the end, we discussed making those elements always visible (or I suggested it). That seems useful to me, otherwise it is very hard to understand what context the block is using and there are contexts.

But I'm not sure about doing that here, we might not be able to do that without a UX discussion, especially now in RC code freeze.

So I think it is fine to keep it as it is. It will not show up anywhere in core right now, but it will be useful for example with #2287073: Allow views contextual filters to expose the context using argument validation plugins.

tim.plunkett’s picture

Issue tags: +rc target triage

Straight forward fix that would be hard to fix in contrib.

xjm’s picture

Issue tags: -rc target triage +rc target

The Drupal 8 committers discussed this and agreed that it should be an RC target.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.0.x, thanks!

  • catch committed 76c77b6 on 8.0.x
    Issue #2484645 by giancarlosotelo, Arla: Assigning context mapping:...
borisson_’s picture

In #18 @berdir suggested always showing the form element. @StryKaizer opened a new issue for that in #2603454: Show context in blocks when only one context is available.

Status: Fixed » Closed (fixed)

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