Problem/Motivation

Node primary local tasks tabs do not appear on node revisions on entity.node.revision route. As a content author, I would expect to see the 'View', 'Edit', 'Delete' and 'Revisions' tabs when navigating to previous revisions, so I could navigate back to the revisions path, view or edit the node.

Steps to reproduce

* Install Drupal 11.x using the Standard profile
* Set Claro as the default theme.
* Create a basic page node and save it
* Edit the basic page node and create a new revision
* Go to the node's revisions tab at the path: node/1/revisions
* Click the initial node revision to view it, /node/1/revisions/1/view
* Notice that there are no primary tabs present at this path
Screenshot showing no primary tabs

Proposed resolution

* adding the following link to node.links.task.yml, displays all tabs, but duplicates Revisions tabs: 1 for entity.node.version_history route/task and one for entity.node.revision route/task

entity.node.revision:
  route_name: entity.node.revision
  base_route: entity.node.canonical
  title: 'Revisions'

Screenshot showing the view, edit, delete and revisions primary tabs after applying the proposed solution

Remaining tasks

N/A

User interface changes

Primary tabs are visible when viewing the list of revisions of a node to make it easier to navigate.

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Issue fork drupal-2885278

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

jasonawant created an issue. See original summary.

prajaankit’s picture

Assigned: Unassigned » prajaankit
jasonawant’s picture

Adding a possible related issue

Version: 8.4.x-dev » 8.5.x-dev

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

jasonawant’s picture

Assigned: prajaankit » Unassigned

Marking as unassigned to let others know this is available. Feel free to assign it back to yourself if you are working on this.

benjifisher’s picture

StatusFileSize
new624.58 KB

I applied the patch from #2730631: Upcast node and node_revision parameters of node revision routes, and it does not seem to fix this issue.

screenshot showing missing local tasks

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

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

oknate’s picture

This patch adds the local task back in and solves the problem of missing route parameters by removing it in a hook_menu_link_alter on other routes.

It depends on the patch that upcasts the node_revision parameter: https://www.drupal.org/files/issues/2730631-35.patch

oknate’s picture

StatusFileSize
new1.4 KB

Updated patch that fixes the "no newline" message.

Note: patch depends on #2730631: Node revision routes don't convert {node} param

oknate’s picture

StatusFileSize
new1.34 KB

I realized I don't need to lookup the route.

oknate’s picture

StatusFileSize
new1.21 KB

I updated the patch, I realized there was a more efficient way to do it without a for loop.

Note: patch depends on #2730631: Node revision routes don't convert {node} param

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.

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

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

rp7’s picture

I got #11 working, thank you. My feedback:

  1. It adds a new local task "View Revision", which is only visible on the revision page. When navigating to a different local task (such as "Edit"), the new "View Revision" local task is not visible. This feels off, local tasks disappearing when navigating between local tasks.
  2. I personally expected the "Revisions" local task to be active, which is not the case. Or is this a wrong expectation?

Before arriving at this ticket, I already had worked on an alternative solution. Instead of creating a new local task, I just use the node canonical local tasks on the node revision page. I also make sure that the revision history ("Revisions" local task) is marked active. Unsure if this is the way forward, but it does seem to work. See the patch attached. (FYI: this does *not* depend on the patch in #2730631: Upcast node and node_revision parameters of node revision routes).

kle’s picture

@rp7: thank you very much !

cgmonroe’s picture

Just in case people don't realize this...

You don't have to patch core to use this solution. You can take the code from the patch which is just a hook implementations and add it to a custom module. May be able to do this in the theme file but I didn't test it.

In my case, i have a custom module that fixes #2730631: Upcast node and node_revision parameters of node revision routes (See comment #18 of this issue). I just added the hook to this module's .module file and viola.. I don't have problems with code that gets the current node and I have tabs on revisions.

Thanks to all who have debugged this issue.

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.

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.

andrewmriv’s picture

This builds off of #15. In addition to adding hook_menu_local_tasks_alter() to add the the local tasks, I also modified node_is_page() to also check node revision routes to ensure they display properly.

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.

nsciacca’s picture

+1 for the patch in #21 - works as expected and is exactly what I needed

cilefen’s picture

Status: Active » Needs review
abhijith s’s picture

StatusFileSize
new21.55 KB
new12.74 KB

Applied patch #21 on 9.5.x and it works fine.

Before Patch:
before

After Patch:
after

RTBC +1

dishakatariya’s picture

Assigned: Unassigned » dishakatariya
dishakatariya’s picture

Assigned: dishakatariya » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new72.84 KB
new74.52 KB
new60.2 KB

Verified and tested #21 patch applied successfully and looks good to me
Testing steps-
1. Install Drupal Standard profile
2. Set Claro as the default theme.
3. Create basic page content item and save
4. Edit same page node, create new revision
5. Go to node's revisions tab, node/1/revisions
6. Click the initial node revision to view it, /node/1/revisions/1/view
7. Observe no tabs present on revision path

Testing Results-
Node local tasks tabs appears on node revisions after applying the patch
Can be move to RTBC

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs usability review, +Needs tests
+++ b/core/modules/node/node.module
@@ -32,6 +32,8 @@
 
 /**
  * Implements hook_help().
@@ -371,10 +373,18 @@ function node_revision_delete($revision_id) {

@@ -371,10 +373,18 @@ function node_revision_delete($revision_id) {
  */
 function node_is_page(NodeInterface $node) {
   $route_match = \Drupal::routeMatch();
-  if ($route_match->getRouteName() == 'entity.node.canonical') {
+  if ($route_match->getRouteName() == 'entity.node.canonical' || $route_match->getRouteName() == 'entity.node.revision') {
     $page_node = $route_match->getParameter('node');

node_is_page() deliberately only returns TRUE on entity.node.canonical - I don't think we can just change the behaviour here.

It might be necessary to refactor whatever logic is calling node_is_page() to do check something else (like just the full view mode?) and deprecate the function instead.

Also needs test coverage.

Other questions:

- what happens if someone has already added tabs on the node revisions page?

- is it OK to show, for example, the edit tab here?
- this marks the 'Revisions' tab as active, but the revisions tab is a list of revisions, not an individual revision, so it's misinforming the user where they are on the site.

To be honest I think leaving things how they are with no tabs but a breadcrumb back to the canonical node page is fine, but leaving open for opinions.

catch’s picture

Category: Bug report » Task
Issue tags: +Bug Smash Initiative

Discussed this briefly in bugsmash with @smustgrave and @darvanen and between us we agreed just copying the node local tasks over is going to be confusing for people.

I think we should consider repurposing this to add explicit local tasks to the revisions page if there are ones that are needed.

darvanen’s picture

I agree with @catch.

I can think of a few things I would want to see from a revision view:

  • View
  • Revert to this revision
  • Latest revision
  • Revisions

Where 'view' is the active tab, i.e. the revision being viewed, and could potentially be labelled in a similar way to how they're shown in the revisions tab, e.g. "26/07/2022 - 10:40 by admin". Maybe just the date/time portion, idk.

toomanynights’s picture

@andrewmriv Thank you for your patch, did exactly what I needed :) And you fixed the double title thing too - perfection!

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.

liquidcms’s picture

Thanks. Fixes missing tabs for me as well.. and does also fix our double title issue (which i had fixed with a preprocess function).

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.

yoroy’s picture

Title: Node local tasks tabs do not appear on node revisions » Add useful local tasks tabs when viewing a node revision
Issue tags: -Needs usability review +Usability
StatusFileSize
new15.56 KB
new7.07 KB

Had a quick look at how Google docs and Gitlab wiki pages do this. Both explicitly *remove* the UI for editing when showing an older revision of a document.

Google docs adds a primary button to revert to this revision
big blue google button screenshot

Gitlab wiki provides links to the current revision and the revision history overview
gitlab wiki revision display

So I tend to agree with @29 in that we should not add the standard set of node local actions. Adding the option to directly restore to the currently shown revision seems useful. How's this for a new title for this issue?

henry tran’s picture

StatusFileSize
new2.36 KB

I've re-rolled the patch for Drupal 10.1

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new2.46 KB

Rerolled for 9.5.x.

smustgrave’s picture

Status: Needs review » Needs work

Moving to NW for the test

Thanks!

johnpitcairn’s picture

StatusFileSize
new15.62 KB

Based on the code in this patch, I've implemented a revision pager of sorts as secondary tasks:
Node revision navigation tabs

I don't really see a problem with keeping the node canonical tabs in place if revision-related tasks are always secondary. I'm considering adding a "Revert" option to this.

I originally had something like this way back in Drupal 6 and remember my editors liking it. The revision label changes to "Latest revision (xx)" or "Published revision (xx)" when on those revisions.

But maybe making navigating between revisions easier is something worth considering here? It's easy to get lost if you have to keep going back to the full revision list.

djsagar’s picture

Status: Needs work » Needs review
StatusFileSize
new1.2 MB
new994.88 KB

Verified and tested #38 patch applied successfully and resolved.

Steps to reproduce
1. Install Drupal Standard profile
2. Set Claro as the default theme.
3. Create basic page content item and save
4. Edit same page node, create new revision
5. Go to node's revisions tab, node/1/revisions
6. Click the initial node revision to view it, /node/1/revisions/1/view
7. Observe no tabs present on revision path

For reference:
Before patch
Before patch

After patch
After patch

Results:
After applying the patch, the Node Local Tasks tabs are visible on node revisions.
RTBC ++

smustgrave’s picture

Status: Needs review » Needs work

Please please read the tags and issue summary, this was tagged for tests which are still needed.

djsagar’s picture

@smustgrave My apologies. I will adhere to tags moving forward.

farse’s picture

I can confirm that the patch in https://www.drupal.org/project/drupal/issues/2885278#comment-15144519 works for Drupal 10.1.6 version.

oily made their first commit to this issue’s fork.

ironnuts’s picture

Issue tags: +Needs reroll
ironnuts’s picture

I cannot apply patch #37 or #38 to the fork for Drupal 11.x. A reroll is required

ironnuts’s picture

I have added commits to the issue fork. I have used an existing functional test function but added assertions. There is now a failing test that will hopefully pass once the the patch(es) are applied.

I tried re-rolling both patches at #37 and #38 without success. It would be good if someone who has worked on the fix could add commits to the issue fork to see if they can make the test pass.

mrinalini9 made their first commit to this issue’s fork.

ironnuts’s picture

Status: Needs work » Needs review
ironnuts’s picture

Changing the status since the functional test assertions are passing in the pipeline following #50.

ironnuts’s picture

Status: Needs review » Needs work
ironnuts’s picture

I'm not sure why but the MR does not contain the new test assertions. They were added to the fork in an old commit. Will need to add them once again to prove that the 'fix' makes the test pass.

ironnuts’s picture

Not sure if phpunit has been upgraded but my local phpunit has stopped working. Seems the test assertions for this issue are also not running in the pipeline. The code is added to the MR and the MR should be ready to review (if phpunit is working).

ironnuts’s picture

Status: Needs work » Needs review
ironnuts’s picture

Status: Needs review » Needs work

Testing the MR via the browser I am seeing this: "fatal error: Cannot use Drupal\Core\Cache\CacheableMetadata as CacheableMetadata because the name is already in use in /var/www/html/core/modules/node/node.module on line 38"

There is also a test failure in the pipeline:

"1) Drupal\Tests\node\Functional\NodeRevisionsUiTest::testNodeRevisionsTabWithDefaultRevision
Behat\Mink\Exception\ElementNotFoundException: Element matching xpath "//ul[@class="tabs primary"]/li[@class="tabs__tab is-active"]/a[@href="node/1/revisions"]" not found."

oily changed the visibility of the branch 2885278-add-useful-local to hidden.

oily changed the visibility of the branch 2885278-add-useful-local to active.

ironnuts’s picture

ironnuts’s picture

First, I fixed a phpstan issue in the MR so that the pipeline shows green. After that, created a new FunctionalJavascript test using the Claro (admin) theme. It is passing with the MR applied so changing the status to 'Needs Review'.

ironnuts’s picture

Status: Needs work » Needs review
ironnuts’s picture

Issue summary: View changes
ironnuts’s picture

Issue summary: View changes
ironnuts’s picture

Issue summary: View changes
ironnuts’s picture

Issue summary: View changes
ironnuts’s picture

Issue summary: View changes
ironnuts’s picture

Issue summary: View changes
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.47 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

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

ironnuts’s picture

Status: Needs work » Needs review

Applied bot fix.

ironnuts’s picture

anish.a’s picture

Issue tags: -Needs reroll
ironnuts’s picture

Issue tags: -Needs tests
smustgrave’s picture

Status: Needs review » Needs work

Left comment on MR.

ironnuts’s picture

Status: Needs work » Needs review

Test is moved to the node module.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

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

oily changed the visibility of the branch 2885278-add-useful-local to hidden.

ironnuts’s picture

After running into rebasing problems, created a new 11.x branch and added the patches/ MR's to it.

Several tests need to be fixed.

ramprassad made their first commit to this issue’s fork.

ramprassad’s picture

I have committed the changes to fix the MR, now the failing tests are fixed. Please check

ramprassad’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Left comments.

ironnuts’s picture

Thank you @ramprassad, the tests seem fixed now: the pipeline runs all green except for the test-only test. It fails like it should.

That seems to leave several out-of-scope typehints @smustgrave has identified that need to be removed from the MR.

smustgrave’s picture

May need to think approach as not seeing why we are adding comment hooks into node. Should try and keep things separate if possible.

sstapleton made their first commit to this issue’s fork.

sstapleton’s picture

Status: Needs work » Needs review

I went through the MR and removed the type hinting and the node hooks as per the MR review.

smustgrave’s picture

Status: Needs review » Needs work

Hooks will need to be converted to OOP functions

sstapleton’s picture

Status: Needs work » Needs review

Marking as needs review since I updated the merge request to use a hook object instead of a regular hook.

sstapleton’s picture

I wasn't able to apply the patch on 10.4.8, so I re-applied the changes here.

https://www.drupal.org/files/issues/2025-06-10/2885278-add-local-tasks-t...

smustgrave’s picture

Status: Needs review » Needs work

Left comments on MR

sstapleton’s picture

Moved the config translation hook over to the NodeHooks file and removed the additional NodeLocalTaskHooks.
Fixed some lint errors.

https://git.drupalcode.org/project/drupal/-/merge_requests/10289

sstapleton’s picture

smustgrave’s picture

Status: Needs review » Needs work

Thanks for fixing those, seems we are getting test-failures now, re-ran twice

sstapleton’s picture

Okay, thanks for your time. I'll fix the tests. To be clear, are there specific tests that need to be passed or all of them?
I am not sure if some tests may be failing due to something unrelated.

hmdnawaz’s picture

StatusFileSize
new2.65 KB

patch for 11.2.2 without tests.

hmdnawaz’s picture

StatusFileSize
new2.93 KB
eelkeblok’s picture

@sstapleton In general, tests are always expected to pass on all merge requests, any test failures are almost certainly due to the changes in the current merge request, as changes are not allowed in when they are causing tests failures.

@hmdnawaz Please update the merge request if there are changes you want to make.

eelkeblok’s picture

Updated the MR for the latest 11.x. Unfortunately, the test is now failing. For some reason, the Revisions tab is no longer active (even though the code seems to be running fine).

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.

hmdnawaz’s picture

StatusFileSize
new5.78 KB

Patch from the MR for 11.3.3

eelkeblok changed the visibility of the branch 11.x to hidden.

eelkeblok changed the visibility of the branch 2885278-new-11.x to hidden.

eelkeblok’s picture

I created a new MR against main, with the changes against 11.x, because targeting main didn't seem to go over well. I took the easy way out by squashing the whole thing into a single commit.

ishani patel made their first commit to this issue’s fork.