Problem/Motivation

Content moderation has been marked as stable in Drupal 8.5.0. We should showcase it in Umami!

Proposed resolution

Enable Workflows and Content Moderation on install. Create separate roles, users and workflows to demonstrate a publishing workflow enforced by Content Moderation.

Remaining tasks

Create example editor users.
Add all node types to the workflow on install.

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#36 Screen Shot 2018-07-27 at 10.51.21.png16.83 KBmarkconroy
#36 Screen Shot 2018-07-27 at 10.53.07.png372.87 KBmarkconroy
#35 interdiff-2953376-32-35.txt5.46 KBchr.fritsch
#35 2953376-35.patch29.95 KBchr.fritsch
#32 interdiff_28-32.txt518 bytesanmolgoyal74
#32 2953376-32.patch26.54 KBanmolgoyal74
#28 interdiff_26-28.txt2.02 KBanmolgoyal74
#28 2953376-28.patch26.51 KBanmolgoyal74
#26 interdiff_2953376_25_26.txt1.76 KBEli-T
#26 2953376_26_add_editors.patch27.04 KBEli-T
#25 interdiff_23_25.txt1.22 KBEli-T
#25 2953376_25_fix_tests.patch25.63 KBEli-T
#23 interdiff_18_23.txt5.08 KBEli-T
#23 2953376_23_remove_moderation_field_from_all_entity_edit_forms.patch24.25 KBEli-T
#18 interdiff_2953376_15_18.txt5.34 KBEli-T
#18 2953376_18_remove_moderation_field_from_all_node_display_modes.patch16.67 KBEli-T
#16 2953376_15_remove_moderation_field_and_grant_view_admin_theme_to_new_roles.patch8.42 KBEli-T
#14 interdiff_2953376_8_14.txt1.69 KBEli-T
#14 2953376_14_remove_moderation_field_and_grant_view_admin_theme_to_new_roles.patch8.36 KBEli-T
#9 Screen Shot 2018-07-05 at 16.35.06.png31.97 KBJohn Cook
#9 Screen Shot 2018-07-05 at 16.30.21.png104.7 KBJohn Cook
#9 Screen Shot 2018-07-05 at 16.26.51.png399.28 KBJohn Cook
#8 interdiff-2953376-2-8.txt1.83 KBJohn Cook
#8 2953376_8_initial_content_moderation.patch6.61 KBJohn Cook
#2 2953376_2_initial_content_moderation.patch5.72 KBEli-T
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Eli-T created an issue. See original summary.

Eli-T’s picture

Issue summary: View changes
Status: Active » Needs work
FileSize
5.72 KB

Here's a start! This patch

  • enables workflow and content moderation on install
  • creates two new roles, Author and Editor
  • assigns what I think are sensible permissions to each
  • sets all users created at install time to have the Author role

When workflow is enabled, it automatically creates an example workflow called Editorial which I think is adequate for our needs. However if I try to apply in to the relevant entity types, the exported workflows.workflow.editorial config entity will no longer apply on installation, raising the error message

% drush site:install demo_umami -y

 // You are about to DROP all tables in your 'ootb86' database. Do you want to continue?: yes.

 [notice] Starting Drupal installation. This takes a while. Consider using the --notify global option.
 [error]  Configuration objects provided by <em class="placeholder">content_moderation</em> have unmet dependencies: <em class="placeholder">workflows.workflow.editorial (node.type.article, node.type.page, node.type.recipe)</em>

This is odd because the node.type.article, node.type.page, node.type.recipe config entities are already in our configuration.

Eli-T’s picture

Issue tags: +dcruhr18
Eli-T’s picture

Issue tags: -dcruhr18 +Nwdug_may18
markconroy’s picture

Status: Needs work » Postponed

@Eli-T,

I'm going to mark this as postponed for now, and let's revisit it asap once we get unhidden. I think this will make a great feature (and others are free to work on it in the meantime if they wish).

I am attaching the 'Umami new feature' tag to this item.

markconroy’s picture

Issue tags: +Umami new feature
martin_q’s picture

John Cook’s picture

I didn't get the error reported in #2 when I used the patch. I suspect it was fixed in other issues.

The patch from #2 sets up the workflow but it wasn't enabled on the content type.

I've made a new patch that has the workflow enabled on article, page, and recipe content types.

John Cook’s picture

I've looked through the permissions they all OK. Authors can create new content but not make it published, while editors can view content that hasn't been published and then publish it.

The admin screen need to be styled when viewing them with the Umami theme.

The content listing (/admin/content) needs styling. And the "Add content" button is missing, and the user needs to go to /node/add to add content.

The /node/*/edit page needs to be looked at. Especially the "Edit summary" link on the body field.

When viewing an unpublished node, the workflow form appears. This should also be styled.

Eli-T’s picture

We can fix a bunch of the points in #9 by granting the author and editor roles access to the admin theme. Suggest doing that and retesting.

It's likely the workflow form will still need styling work though.

markconroy’s picture

Status: Postponed » Needs work

I don't think we should expand the scope of this to the styling of the Umami theme as an admin theme. It is not an admin theme and we have not done any work on it to make it one.

Those issues - if we want to look at them - can be dealt with in follow up issues.

Setting to 'Needs work' so we can add permission for editor and author roles to use the admin theme.

@Eli-T - should we create a new issue for the workflow form styling? It's likely that the folks working on this issue will not be the same folks working on the CSS for that.

Eli-T’s picture

@markconroy it's a bit of a weird one - workflow by default adds a form to the top of nodes when being viewed so users with the correct permission can change their state. However, there's an alternative where you can change the workflow status on the edit page. So we could use block configuration to remove that form from the view and rely on people editing it in this issue. Then consider in a separate issue if we want to style and reinstate it.

How does that sound?

markconroy’s picture

I think that sounds like a sensible approach - graceful degradation, let's call it!

It means we get this cool feature in sooner, and progressively enhance it later.

Eli-T’s picture

Apologies - I was slightly wrong in #12. The form is removed in the field display settings for each content type, not in block config.

Here is a patch that does that, and grants access to the admin theme to the new Author and Editor roles.

Status: Needs review » Needs work
Eli-T’s picture

Patch that should actually apply (InstallHelper class on 8.6.x changed after generating the original).

No interdiff as interdiff doesn't want to play nicely for some reason.

John Cook’s picture

Status: Needs review » Needs work

The patch from Eli-T in #16 prevents the need to style admin pages by letting the editors and authors view the admin theme.

The Moderation control form still appears, though. This is because it is set to be visible on the other view modes. Because of this, I'm setting this issue back to needs work.

Eli-T’s picture

Good catch @John Cook! Here's another patch that disables the moderation status field for all node display modes.

Putting to Needs Review so someone can verify comments to date have been addressed, but I think we should also consider adding a user with the Editor role with this change too, because as is, you can't create an article and publish it (or publish a new draft of an existing article) without using the admin user. Maybe even two extra users, one with just the Editor role and one with both Author and Editor.

Similarly we should consider paring down the permissions granted to the Authenticated role, as it would be made rather redunandant.

Status: Needs review » Needs work
markconroy’s picture

Might be nice in a future release to allow authenticated users to post comments without approval, and to use the advanced search (just to show off how cool the permissions system is in drupal)

Gábor Hojtsy’s picture

1. I agree to hide the moderation controls for now, but it would be really useful to reinstate it as it is a nice in-place experience where you can actually see what you are moderating as opposed to backend where the form chrome is distracting. Separate issue though. I created one at #2985551: Style and show content moderation form in Umami.

2. I think the approach taken here to add an author and editor roles is good. Adjusting authenticated user roles can also be a followup. I think moderator needs to be able to create draft from published as well, that permission is missing.

It would be nice to swiftly get this in and then work on perfecting the experience. For that the access fails needs to be resolved, the current fails seems to indicate there is a permission issue.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Eli-T’s picture

One of the test fails is due to the the moderation form component not being removed from entity edit forms. This patch explicitly removes it.

Putting back to needs review, but expected the other permissions based test failures will still fail.

Status: Needs review » Needs work
Eli-T’s picture

Status: Needs work » Needs review
FileSize
25.63 KB
1.22 KB

Fixes the remaining test fails.

Still need to create a couple of editors.

Eli-T’s picture

This patch adds the editors and completes the functionality as envisaged.

I'd suggest someone tests and looks at how the different roles interact now we have content moderation configured like this.

For example, authors can create new articles, and create new drafts of their own articles, but not create new drafts of articles created by other users. Is that too restrictive? What other details do we need to consider?

Note before this patch/issue, the non-admin users had no role other than Authenticated User, and couldn't do anything other than log in.

Gábor Hojtsy’s picture

Status: Needs review » Needs work

Some nitpicks, some followup:

  1. +++ b/core/profiles/demo_umami/config/install/core.entity_form_display.block_content.footer_promo_block.default.yml
    @@ -56,4 +56,6 @@ content:
    -hidden: {  }
    +hidden:
    +  moderation_state: true
    +
    

    Extra newline

  2. +++ b/core/profiles/demo_umami/config/install/core.entity_form_display.media.remote_video.default.yml
    @@ -14,7 +14,7 @@ mode: default
     content:
       created:
         type: datetime_timestamp
    -    weight: 10
    +    weight: 2
         region: content
         settings: {  }
         third_party_settings: {  }
    @@ -28,7 +28,7 @@ content:
    
    @@ -28,7 +28,7 @@ content:
         region: content
       path:
         type: path
    -    weight: 30
    +    weight: 3
         region: content
         settings: {  }
         third_party_settings: {  }
    @@ -36,12 +36,12 @@ content:
    
    @@ -36,12 +36,12 @@ content:
         type: boolean_checkbox
         settings:
           display_label: true
    -    weight: 100
    +    weight: 4
         region: content
         third_party_settings: {  }
       uid:
         type: entity_reference_autocomplete
    -    weight: 5
    +    weight: 1
         settings:
           match_operator: CONTAINS
           size: 60
    

    Let's leave these as-is. I can see how its re-weighted once saved, but for easier diffs with standard, it would be nice to keep as-is.

  3. +++ b/core/profiles/demo_umami/config/install/user.role.author.yml
    @@ -0,0 +1,48 @@
    +  - 'create page content'
    ...
    +  - 'delete own page content'
    ...
    +  - 'edit own page content'
    ...
    +  - 'view page revisions'
    

    Normally I think page creation would be separate from article/recipe authoring, but it would be overkill to add even more roles, so this should be fine.

  4. +++ b/core/profiles/demo_umami/config/install/user.role.author.yml
    @@ -0,0 +1,48 @@
    +  - 'create terms in tags'
    

    Last time I looked the terms widget did not allow to create new, so authors would need to go to a different UI to create the terms, this is super confusing.

    Also categories were chosen in a textfield rather than a dropdown. I think both of these are fixable as a standalone issue, just noting that giving authors the tag creation permission does not make them able to create tags if the widget does not allow them to :)

anmolgoyal74’s picture

anmolgoyal74’s picture

Status: Needs work » Needs review

The last submitted patch, 2: 2953376_2_initial_content_moderation.patch, failed testing. View results

Gábor Hojtsy’s picture

Status: Needs review » Needs work
+++ b/core/profiles/demo_umami/config/install/user.role.author.yml
@@ -19,7 +19,6 @@
   - 'create terms in recipe_cuisine'
-  - 'create terms in tags'
   - 'create url aliases'

Erm, I did not suggest this to be removed?!

anmolgoyal74’s picture

my bad, I misinterpret the suggestions in #27.

anmolgoyal74’s picture

Status: Needs work » Needs review
markconroy’s picture

Status: Needs review » Needs work

Hi @anmolgoyal74

The 'moderation state' widget needs to be positioned for each content type on the 'Manage Form Display' page, and the widget needs to be set as "moderation widget' not 'text field'.

When that is complete, I think this is ready for RTBC.

chr.fritsch’s picture

Status: Needs work » Needs review
FileSize
29.95 KB
5.46 KB

Added the moderation widget to article, recipe and page type.

markconroy’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
FileSize
372.87 KB
16.83 KB

Moving to RTBC.

Moderation form appears on node edit page:
drupal moderation in drupal core

Screenshot of article for an admin of an article with word "Updated" in title and article set to 'draft' state side by side with anonymous user version and title remaining at 'Published' state.
drupal moderation in drupal core

  • Gábor Hojtsy committed 8dc4c5a on 8.7.x
    Issue #2953376 by Eli-T, anmolgoyal74, John Cook, chr.fritsch,...

  • Gábor Hojtsy committed fe48728 on 8.6.x
    Issue #2953376 by Eli-T, anmolgoyal74, John Cook, chr.fritsch,...
Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Yay looks good, thanks! I love that we have actual roles and users demonstrating moderation.

Status: Fixed » Closed (fixed)

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