Problem/Motivation

We want to allow moderation of an entity without going to its Edit page. That supports both alternate user workflows and user permissions (as you may want someone moderating but not editing a given entity.)

Proposed resolution

Create a free-standing form that we can inject into an entity, conditionally based on its view mode. For now, this form should contain only a select box showing the states that can be moved to and a submit button. (It will be redesigned later.) On submit, load the entity, set its state accordingly, and save it.

On the Moderation configuration form on the bundle, offer a set of checkboxes to pick which view modes the form should be embedded in.

When configuring a view mode, if that view mode has the form configured to show on it, display it as an "extra field" so that its position can be reordered.

The form should never show if the entity being displayed is the default-revision. It should only show for forward-revisions, ever, always.

Remaining tasks

Implement the above.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Crell created an issue. See original summary.

Crell’s picture

Issue tags: +Release blocker

Tagging as release blocker, as this is the last "we're not done unless this exists" issue. (Plenty more work to do, though, but iterate!)

Crell’s picture

Hm. Open question. What do we do for entities that have don't have their own display page, such as Block Content? How's this going to work? I... have no idea.

Crell’s picture

Priority: Normal » Critical
Crell’s picture

Title: Add form to select view modes to manage moderation » Add form to certain view modes to manage moderation
becw’s picture

This form should only have accessible destination states that are different from the current moderation state.

Crell’s picture

Assigned: Unassigned » Crell
dawehner’s picture

On the Moderation configuration form on the bundle, offer a set of checkboxes to pick which view modes the form should be embedded in.

What about providing an alternative formatter for the moderation_state field which renders the form? Once there, you don't need any kind of special purpose configuration UI.

Crell’s picture

dawehner: Bec suggested the same thing, actually. I'm still undecided about it, as it means you have to get your formatter setup right, too. It's another moving part that can break. I don't know if it's more work to make it appear only for the right people, either.

I'm still working on building the form itself, though, so the exact method of attaching the form is still on the table and I'm happy to be convinced one way or another.

dawehner’s picture

l undecided about it, as it means you have to get your formatter setup right, too. It's another moving part that can break. I don't know if it's more work to make it appear only for the right people, either.

Seriously, do you really install a workflow module and configure that, but at the same time you are not able to configure formatters and like hiding the author information from pages, which is almost the first thing many people do on their site.

Crell’s picture

This is still a WIP, but it gets some code out there for review. Next step is to actually wire the form up and make it do something. :-) So far this is all plumbing.

Status: Needs review » Needs work

The last submitted patch, 11: 2645490-moderation-form.patch, failed testing.

The last submitted patch, 11: 2645490-moderation-form.patch, failed testing.

The last submitted patch, 11: 2645490-moderation-form.patch, failed testing.

dawehner’s picture

So just a random point that this is horrible: Sorting.

becw’s picture

  1. +++ b/tests/src/Unit/StateTransitionValidationTest.php
    @@ -16,59 +22,147 @@ use Drupal\workbench_moderation\StateTransitionValidation;
    +    $entity_storage->loadMultiple()->willReturn($states);
    

    Do these prophesied $states not need ->reveal() called on them?

  2. +++ b/tests/src/Unit/StateTransitionValidationTest.php
    @@ -90,4 +185,71 @@ class StateTransitionValidationTest extends \PHPUnit_Framework_TestCase {
    +  /**
    

    Whitespace.

Crell’s picture

Well, I tried adding a reveal() call and it seems to pass both ways. Which is... odd. Anyway, I left in the extra reveal() calls.

New patch, now has the form showing up and doing stuff! It's butt ugly, but the functionality seems to be there.

Still todo:
* Why is testbot angry about the previous patch?
* I have a gut feeling that I need some cache information bubbling handling stuff in here somewhere, but I'm not sure exactly where. Will hopefully figure that out tomorrow by asking someone.

Status: Needs review » Needs work

The last submitted patch, 17: 2645490-moderation-form.patch, failed testing.

The last submitted patch, 17: 2645490-moderation-form.patch, failed testing.

The last submitted patch, 17: 2645490-moderation-form.patch, failed testing.

Crell’s picture

becw’s picture

  1. +++ b/src/EntityOperations.php
    @@ -55,4 +64,44 @@ class EntityOperations {
    +      unset($build['moderation_state']);
    

    It was confusing to me that this output disappeared when the workbench_moderation_control was displayed.

  2. +++ b/src/EntityTypeInfo.php
    @@ -178,6 +179,73 @@ class EntityTypeInfo {
    +   *   following keys: entity type, bundle name, context (either 'form' or
    +   *   'display'). The keys are the name of the elements as appearing in the
    

    Any reason to duplicate core docs here? Maybe reference \Drupal\Core\Entity\EntityFieldManagerInterface::getExtraFields() instead?

  3. +++ b/src/EntityTypeInfo.php
    --- /dev/null
    +++ b/src/Form/BundleModerationConfigurationForm.php
    

    This whole file is just moved/renamed, right? No changes in here?

  4. +++ b/src/Form/EntityModerationForm.php
    @@ -1,30 +1,42 @@
    + * Contains EntityModerationForm.php
    

    Contains class name, please.

  5. +++ b/src/Form/EntityModerationForm.php
    @@ -32,151 +44,80 @@ class EntityModerationForm extends EntityForm {
    +      '#value' => $this->t('Set'),
    

    "Set" is unsettlingly short; perhaps "moderate", "apply", or "update"?

  6. +++ b/src/ModerationInformationInterface.php
    @@ -18,6 +18,18 @@ use Drupal\Core\Form\FormInterface;
    +  public function loadBundleEntity($bundle_entity_type_id, $bundle_id);
    

    I'm not really sure why this is here. It's a convenience method, but it's only implemented and used once, so...

becw’s picture

Are you planning to provide a browser test for the form UI?

Crell’s picture

1) I wasn't sure about that line; with this form, showing the field makes no sense at all but it doesn't make sense elsewhere either. Removed that line; we'll hide that field another way.

2) Mainly to simplify finding the right docs, and to keep PHP Storm happy. I'll trim it down.

3) Correct.

4) Damnit, PHPStorm!

5) Changed to Update.

6) Building a better set of primitives in the domain language. It's a routine that ought to be in core, but isn't. Having the richer primitive set makes the code easier to read elsewhere, and also lets people not think about how they'd go about doing that logic the next time they need it.

7) BTB isn't usable in core yet, so we can't or it would break testbot. :-(

Updated patch attached.

becw’s picture

Status: Needs review » Needs work

Because this is critical functionality for workbench_moderation, I think that it would be sensible to add a simpletest, even one with a limited or incomplete test case, for this form.

Your other changes are good to go, I think.

Crell’s picture

  • becw committed 2195bde on 8.x-1.x
    Issue #2645490 by Crell: Add form to certain view modes to manage...
becw’s picture

Status: Needs review » Fixed

Lovely.

dawehner’s picture

Too bad, but IMHO this is a local maximum we went into.

Status: Fixed » Closed (fixed)

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