Content moderations shows the state label instead of transition label on the default ModerationStateWidget

Created on 10 February 2019, almost 6 years ago
Updated 21 April 2024, 8 months ago

Problem/Motivation

When editing a moderated node type, "Change to" select list shows the state label instead of the transition label. In this scenario the state label is a bit confusing for content editors. Most people don't realize that creating a new draft leaves the default revision published.

We also allow site builders to edit the transition labels, but those transition labels are never used by Drupal Core. You can edit a string that is never used.

Proposed resolution

Give site builders the choice to use either "State" labels, or "Transition" labels.

This issue/patch doesn't completely solve the problem. Ideally the transition label for published->draft should be something like "Create a new draft (leave the existing revision published)" but that will need to be a different issue. At least with this patch site builders can make that change on their own.

UI changes

Current Drupal Core (or with patch, but use "State" labels)

Create node

Edit node

With patch, using "Transition" labels

Create node

Edit node

API changes

None.

Data model changes

Added new field widget settings to content_moderation.schema.yml.

String changes

Added the strings:
* "Change"
* 'Which labels should be displayed for transitions between moderation states?'
* 'Moderation transition labels'
* 'State labels'
* 'Transition labels'

TODO

* Fixing issues reported in #60
* Fixing issues reported in #62
* Existing tests are attaching a SQL file. That's not sustainable. Rewrite the tests to not use an .sql.gz file and remove it from the patch.
* Create new issue to change "Create New Draft" to be something more helpful like "Create New Draft (and leave the current revision published)"
* Write a change record
* Manual testing on an existing site

Feature request
Status

Needs work

Version

11.0 🔥

Component
Content moderation 

Last updated 18 days ago

Created by

🇯🇴Jordan Anas_maw

Live updates comments and jobs are added and updated live.
  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • 🇮🇳India Akhil Yadav

    added patch against #43 in 10.1 version

  • Status changed to Needs review almost 2 years ago
  • Status changed to Needs work almost 2 years ago
  • 🇮🇳India mohit_aghera Rajkot

    @Akhil Yadav,
    One test case and attached file is missing from the re-roll.
    The patch in #43 has additional test cases and database zip file.

    Can you please re-roll again.

  • 🇮🇳India pooja saraah Chennai

    Fixed failed commands on #51
    Attached patch against Drupal 10.1.x

  • Status changed to Needs review almost 2 years ago
  • Status changed to Needs work almost 2 years ago
  • The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India Nitin shrivastava

    Fix custom command failures.

  • 🇧🇪Belgium BramDriesen Belgium 🇧🇪

    Hiding patches #51 and #54 since they are omitting important changes.

    Adding it to the list... #3339883: Employees of Dotsquares are posting mass re-roll patches which are invalid and/or incomplete

  • 🇮🇳India mohit_aghera Rajkot

    - Doing full re-roll from my patch in #43
    - Re-roll diff doesn't contain significant difference due to change in database zip file for testing update.
    I had to update the database zip files because there are changes related to theme and bartik theme is removed from core in D10.
    - commit-code-check is passing on local.
    - Both the test cases are passing on local.
    - Hiding few more patches are they are causing noise.

  • Status changed to Needs work almost 2 years ago
  • 🇺🇸United States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

    git apply failed with whitespace issues but patch -p1 worked just an FYI.

    Tried testing patch #59 wasn't super clear that I need to go to my content type to change this setting. So definitely will need a change record.

    Selecting transition labels did not update the labels. Cleared cache multiple times.

  • 🇺🇸United States zipymonkey Durham, NH

    The patch only supports using the transitions label on the Edit page. This does not work on the Layout form. The Layout builder change is set in content_moderation_entity_form_display_alter() hook but that knows nothing about the setting. The patch will need to be updated to handle the form alter. The following changes the transition but that needs to be pulled from the moderation_labels need to be pulled from the form settings.

      if ($context['form_mode'] === 'layout_builder') {
        $form_display->setComponent('moderation_state', [
          'type' => 'moderation_state_default',
          'weight' => -900,
          'settings' => [
            'moderation_labels' => 'transition', // Get the field setting from form display?  
          ],
        ]);
      }
    

    Alternatively, this could be a setting on each workflow instead of a settings on the field Widget.

  • 🇮🇹Italy kopeboy Milan

    Since we are here adding options on the Manage display tab, I would also add the option to only show the moderation state.

    This can be useful to remind the author that he might want/need to edit the content, without showing a (imho confusing & bad looking) form on a page display! This should even bring performance improvements, allowing to cache the View page for more users, right?

  • 🇨🇦Canada dalin Guelph, 🇨🇦, 🌍

    @kopeboy We try to keep issues as small and self-contained as possible. I suggest creating a new issue.

    I've updated the ticket description with what I think are the remaining tasks. Including a new one: Rewrite the tests to not use an .sql.gz file and remove it from the patch.

  • 🇨🇦Canada dalin Guelph, 🇨🇦, 🌍
  • 🇮🇹Italy kopeboy Milan

    @dalin #64: Fair. I've put it as a related issue: Add a moderation state pseudo field on the view mode Active

Production build 0.71.5 2024