When adding a new entity to the system, the ability to log a revision message makes very little sense, and in some cases, e.g. media, the visual prominence is overwhelming and takes attention away from the task at hand.

Revision log takes up a huge part of the screen.

Proposal from @rlnorthcutt: Let's only show this on content/media/etc. edit instead.

Before / After

Nodes

Before

After

Custom Blocks

Before

After

Media entities

Before

After

Issue fork drupal-3096906

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

webchick created an issue. See original summary.

webchick’s picture

Issue summary: View changes
rlnorthcutt’s picture

StatusFileSize
new811 bytes

The attached patch makes a very simple change to the showRevisionUi() method on content entity forms. It checks to make sure that this is NOT a new entity in order to display the revision field.

rlnorthcutt’s picture

Note that this patch works for nodes, but doesn't seem to work for media.

berdir’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: 3096906-4.patch, failed testing. View results

berdir’s picture

Seems like it's working too for media based on the test fails.

For the record, I'm fairly sure this was done like this on purpose, what we've done is to hide the checkbox and keep this. The first revision can still have a comment.

berdir’s picture

> the visual prominence is overwhelming and takes attention away from the task at hand.

Don't disagree with that, wondering how that looks in Claro? Also, if we were to apply the sidebar layout of the node form to to other forms then that might help with that?

rlnorthcutt’s picture

StatusFileSize
new650 bytes

I found a much more effective change. It simply hides the revision information on new entity forms. This means it can be undone by a form alter (vs. an unset).

This helps to provide a cleaner UX for authors, it is easily reversible by contrib, and works for nodes as well as media

anavarre’s picture

Issue summary: View changes
StatusFileSize
new9.71 KB
new6.21 KB
new12.76 KB
new12.95 KB
new23.41 KB
new21.99 KB

Adding a few before/after screenshots.

lauriii’s picture

aleevas’s picture

Status: Needs work » Needs review
StatusFileSize
new3.02 KB
new3.32 KB

Fixed filed tests from #10

kevinfunk’s picture

I've tested the patch in #13 and can confirm that the revision log message is not shown when creating a new block, node, or media item and it is shown when editing a block, node, or media item.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

priyanka.sahni’s picture

Assigned: Unassigned » priyanka.sahni
priyanka.sahni’s picture

Assigned: priyanka.sahni » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new95.3 KB
new133.19 KB
new89.55 KB

Verified and tested by applying patch#13.It looks good to me.Moving it to RTBC.

Steps to test -
1. Go to the admin site.
2. Go to /admin/content -> Click on Create content type.
3. Verify if revision log is available or not.
4. Go to /admin/content/media ->Click on Create media.
5. Verify if revision log is available or not.
6. Go to admin/structure/block/block-content -> Click on Create block.
7. Verify if revision log is available or not.

Content Type -
After Patch

Block -
After Patch

Media -
After Patch

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/lib/Drupal/Core/Entity/ContentEntityForm.php
    @@ -130,6 +130,11 @@ public function form(array $form, FormStateInterface $form_state) {
    +    // Hide the revision log field on new entity forms.
    +    if ($this->entity->isNew()) {
    +      $form['revision_information']['#access'] = FALSE;
    +    }
    

    This is better written as

    // Hide the revision log field on new entity forms.
    $form['revision_information']['#access'] = !$this->entity->isNew();
    

    I.e. without the if. This is so the form keys don't change. Makes things simpler for alters.

  2. I think there is also some interesting code in prepareEntity()
      /**
       * {@inheritdoc}
       */
      protected function prepareEntity() {
        parent::prepareEntity();
    
        // Hide the current revision log message in UI.
        if ($this->showRevisionUi() && !$this->entity->isNew() && $this->entity instanceof RevisionLogInterface) {
          $this->entity->setRevisionLogMessage(NULL);
        }
      }
    

    it makes me wonder if the correct fix is for \Drupal\Core\Entity\ContentEntityForm::showRevisionUi() to be

    return !$this->entity->isNew()  && $this->entity->getEntityType()->showRevisionUi();
    
  3. One thing I'm wondering about is what will the impact of the change be on a site where someone has altered the revision_log_message to be required. I've test locally - yeah we need to detect if it is required and show it in those cases.
deepak goyal’s picture

Assigned: Unassigned » deepak goyal
deepak goyal’s picture

Assigned: deepak goyal » Unassigned
StatusFileSize
new3 KB

Hi @alexpott
Updated point 1 please review.

alexpott’s picture

Issue tags: +Needs tests

I think we need an explicit test plus #18.2 and #18.3 probably should be addressed.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mandclu’s picture

+1 for getting this changed, it would be a big improvement.

andregp’s picture

StatusFileSize
new2.94 KB
new2.5 KB
new456.61 KB
new433.29 KB
new433.39 KB
new433.29 KB

@alexpott I tried to address the points #18.2 and #18.3 on this new patch.

Regarding the #18.2 I tried to use

return !$this->entity->isNew()  && $this->entity->getEntityType()->showRevisionUi();

instead of the approach on the patch, but it had the opposite desired effect. I discovered that in some cases the default code already hides the revision field on the creation of new content types, and by changing this return line the revision field starts to appear. (see on "..._alternative_code" pictures).

About #18.3 I added the additional validation. I wasn't able to test with required revision fields, but at least this field isn't showing when, for example, I try to create a new block.

One concern that I got when working on this issue is about the code removal from PagePreviewTest::testPagePreviewWithRevisions. The name of the test refers to testing the page "with revisions" so removing the assertion that checks the revision just to make it pass doesn't sound as the right approach. Maybe rebuild the test, or remove it entirely an replace with a more specific one? I'm not an expert so I don't know what is the right thing to do.

Keeping on needs work as it still needs dedicated tests.

andregp’s picture

Status: Needs work » Needs review
StatusFileSize
new3.02 KB
new790 bytes

Addressing the test fails.

andregp’s picture

Status: Needs review » Needs work

Sorry, I didn't mean to change the status.
It still needs work as we still need dedicated tests.

Johnny Santos’s picture

Assigned: Unassigned » Johnny Santos

Im going to give it a try with the tests

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mlncn’s picture

Any luck with the tests, Johnny Santos, or should this be un-assigned?

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

bkosborne’s picture

+1 to this, very unexpected to have this shown on new entity forms

pbouchereau’s picture

Assigned: Johnny Santos » Unassigned

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.