The form that appears at node/%/latest should not be hard-coded into the page for all content types

It should (perhaps optionally) be wrapped inside a block.

If the maintainers would like, this can be an optional switch that turns off the form delivery at node/%/latest while providing the block.

That would be at admin/structure/types/manage/%/moderation where % is the content type being configured.

Current users should be able to continue using the system as-is and other users can have a block that they'll place wherever they think it makes sense.

A warning should inform users that checking this checkbox means the workbench moderation form is going away, preferably before submitting the form, so that they know the form is going away and it will need to be put into place via the block.

Comments

brantwynn created an issue. See original summary.

saltednut’s picture

Issue summary: View changes
saltednut’s picture

Issue summary: View changes
saltednut’s picture

To be honest, I am not sure if it should be a global setting or a per-content-type setting really. I guess its two things. One: hiding the form for some content types and Two: giving us the form as a block.

Crell’s picture

Form in block is just that: A block, use it or not. Disabling the form seems like a per-bundle toggle; especially since we only support per-bundle-level configuration right now. :-)

devin carlson’s picture

Status: Active » Needs review
StatusFileSize
new6.9 KB

An initial attempt with test coverage for the testbot.

saltednut’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/Block/WorkbenchModerationLatestBlock.php
@@ -0,0 +1,105 @@
+ * @Block(
+ *   id = "workbench_moderation_latest_block",
+ *   admin_label = @Translation("Latest version")
+ * )

You can inherit the node context and you may not need the RouteMatchInterface.

 * @Block(
 *   id = "workbench_moderation_latest_block",
 *   admin_label = @Translation("Latest version"),
 *   context = {
 *     "node" = @ContextDefinition("entity:node", label = @Translation("Node"))
 *   }
 * )
 *
 */
+++ b/src/Plugin/Block/WorkbenchModerationLatestBlock.php
@@ -0,0 +1,105 @@
+    if ($node = $this->routeMatch->getParameter('node')) {

$node = $this->getContextValue('node');

devin carlson’s picture

Status: Needs work » Needs review
StatusFileSize
new17.31 KB

An updated patch to address #7 and include a per-bundle configuration option for displaying the moderation information on the "latest version" tab.

Status: Needs review » Needs work

The last submitted patch, 8: 2685163-8.patch, failed testing.

The last submitted patch, 8: 2685163-8.patch, failed testing.

The last submitted patch, 8: 2685163-8.patch, failed testing.

jibran’s picture

Title: (optionally?) Replace the workbench moderation form from node/%/latest with a block » Allow the workbench moderation form from node/%/latest with a block

The last submitted patch, 8: 2685163-8.patch, failed testing.

saltednut’s picture

Title: Allow the workbench moderation form from node/%/latest with a block » Provide the workbench moderation form from node/%/latest with a block

If we're going for clarity with this re-title...

devin carlson’s picture

Status: Needs work » Needs review
StatusFileSize
new18.11 KB

A reroll of #8 to incorporate the latest changes and add context information to the block test.

Status: Needs review » Needs work

The last submitted patch, 15: 2685163-15.patch, failed testing.

The last submitted patch, 15: 2685163-15.patch, failed testing.

The last submitted patch, 15: 2685163-15.patch, failed testing.

devin carlson’s picture

Status: Needs work » Needs review
StatusFileSize
new19.14 KB

Fixed the test failure.

saltednut’s picture

One issue I am finding in testing this: We redirect users to node/%/latest whenever a [insert_state_here] is transitioned to "draft" -- however, if there is no published version of the node, then the draft shows up at node/% -- and you get an access denied error trying to visit node/%/latest

Example to try:

  1. Add a new moderation state called "pre-draft"
  2. Add transitions for moving content, you'll need "pre-draft to pre-draft" (for creating new content) and "pre-draft to draft" (for moving pre-draft to draft, obviously)
  3. Set "pre-draft" as the default moderation state for new Article nodes
  4. Create a new Article (should be in "pre-draft" state)
  5. Use the Moderation form block to transition from pre-draft to draft
  6. Note the redirect to node/%/latest upon submitting this state change

Edit: This is likely happening because the original form assumes one is always at node/%/latest where it originally lived before we introduced this more flexible block that could occur just about anywhere, regardless of current state.

samuel.mortenson’s picture

StatusFileSize
new20.16 KB
new951 bytes

Minor update - I noticed that when using the Block no Entity validation was being run, which would allow for users to move Entities to invalid states. This update adds a validation method to the EntityModerationForm, which prevents users from circumventing the ModerationStateValidator.

Status: Needs review » Needs work

The last submitted patch, 21: 2685163-21.patch, failed testing.

The last submitted patch, 21: 2685163-21.patch, failed testing.

samuel.mortenson’s picture

mstrelan’s picture

+    /** @var $user \Drupal\node\NodeInterface */
+    $node = $this->getContextValue('node');

Variable name for type hinting is wrong, should be @var $node.