Problem/Motivation

We have no UI for editing/viewing/reverting custom block revisions.

Proposed resolution

Build apon #2350939: Implement a generic revision UI to add view history, revert revision, and delete revision functionality.

View revision functionality will not be added as viewing the latest Block Content entity is not supported.

Remaining tasks

  • Write patch
  • Write tests
  • Reviews

User interface changes

New UI for viewing custom block revisions

Revision history

Revision history

Revision revert form

Revision revert form

Revision delete form

Revision delete form

API changes

New routes added.
New entity operations added for Block content.
New permissions added for each Block content type.

Release notes snippet

There is now a UI for viewing, reverting and deleting Block Content revisions.

CommentFileSizeAuthor
#87 1984588-83-d10.0.patch12.36 KBfenstrat

Issue fork drupal-1984588

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Component: block.module » custom_block.module
larowlan’s picture

Assigned: larowlan » Unassigned
star-szr’s picture

Category: Task » Feature request
Issue summary: View changes

I really like this idea, but I think this has to be a feature request. Could be a cool contrib module? :)

dawehner’s picture

Version: 8.0.x-dev » 8.1.x-dev

This is certainly not in scope for 8.0.x ... views had an issue for revisions for itself since quite a while,
but this got pushed back in badcamp 2012 already.

jibran’s picture

webchick’s picture

Component: custom_block.module » block_content.module
jibran’s picture

@dawehner, can you please provide the steps to proceed with this issue so that everyone can understand better?

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

bennash’s picture

Block revisions in Drupal 8 do not exist as far as I can tell.

jibran’s picture

Right now, in core, you can create block content revisions only programatically see BlockContentRevisionsTest for reference.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jibran’s picture

Status: Postponed » Active

Custom block UI after #2669802: Add a content entity form which allows to set revisions .

Create block

Edit block

This is not postpone anymore.

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

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

kattekrab’s picture

Yeah - kinda need a UI of some kind for this, otherwise doesn't seem much point to making blocks revisionable.

Revisionable. Is that even a word? :)

Alex Bukach’s picture

In fact it has already been nicely implemented in Entity API module, so one should simply consider merging the respective part to the core and updating the entities definitions.

(See https://gist.github.com/alex-bukach/75c13b674ea1a22bae43788d51326265 for a quick and dirty solution.)

dawehner’s picture

There is 100% an issue for bringing the generic functionality from entity module into core.

Alex Bukach’s picture

@dawehner if you mean my patch, I realize that it's unacceptable to do it that way, and I made it temporary until the solution in the core appears, since it was a major issue for me not to have it working.

Otherwise, if you mean merging Entity API code to core, as the module page of Entity API states:

The Drupal 8 version of the Entity API module is used for improvements to Drupal 8's Entity API which will be moved to Drupal core one day

I believe it's the case when we should move this piece into the core.

dawehner’s picture

There is #2350939: Implement a generic revision UI but it doesn't yet contain the version from entity API.

Alex Bukach’s picture

Right, I didn't see that issue. I wonder how happened that the work had been duplicated between the core and Entity API.

dawehner’s picture

Well the entity API started with the core patch but then slowly improved it over time.

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.

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.

dpi’s picture

Created a project for adding revisions UI to Block Content making use of patches in #2350939: Implement a generic revision UI: https://www.drupal.org/project/block_content_revision_ui

Rather than integrate the UI into block content in that issue, should we do it here?

AaronMcHale’s picture

Status: Active » Postponed

In line with similar issues for Media and other projects/initiatives, postponing this in favour of the issue referenced above in #23

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.

Nigel Cunningham’s picture

I've also created "Config entity revisions", doing a similar thing for webforms. I've only come across this now because I made it generic and was planning on applying it to blocks, views and other config entities too. I'll take a look at the code in #23. Perhaps we can work together...

Nigel Cunningham’s picture

On further checking, it looks like blocks aren't config entities (as I had previously been led to believe), so this is a different problem.

iyyappan.govind’s picture

Hi All,

Block is content entity, it not a config entity. It has it's own fields definitions. So we need to implement the re-visioning that already implemented in the node module.

Thanks

tim.plunkett’s picture

"Custom block" aka \Drupal\block_content\Entity\BlockContent is a content entity.
That's what's being discussed here, not block plugins, not block entities (Block UI placements), not custom block types (the config entities that are equivalent to bundles for custom blocks).

iyyappan.govind’s picture

Hi @tim.plunkett,

Thanks for the great explanation. I am willing to contribute in this feature. Any guidance for me? Thanks

AaronMcHale’s picture

Hi @30iyyappan.govind

We postponed this issue (and similar issues for other core modules) in favour of #2350939: Implement a generic revision UI which aims to address this for all Content Entity Types, so if you want to contribute I’d recommend doing it over on that issue.

Thanks
-Aaron

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.

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.

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.

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.

dpi’s picture

Title: Add a UI for viewing/reverting custom block revisions » Add Block Content revision UI
Status: Postponed » Active

#2350939: Implement a generic revision UI is merged, unblocking this issue.

Matching the issue title at #2936995: Add taxonomy term revision UI

dpi’s picture

Assigned: Unassigned » dpi

dpi’s picture

Assigned: dpi » Unassigned
Status: Active » Needs review

MR adds the UI + tests for block content adapted from tests introduced by #2350939: Implement a generic revision UI.

There are three tests from 2350939 relevant to this issue, each revision revert, delete revision, and version history. Adapted surface level of tests, but not the small details as they are still covered and don't differ from the generic tests.

Couple of fixes to existing tests required: JSON API endpoints accessible by administer permission, and needed a relation type plugin definition.

Some differences between Block Content Revision UI contrib:

  • Block content doesn't have a view route. So it doesn't make sense to add a revision view route.
  • Permissions have different naming, more in line with core permissions.
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

So initial testing

Install hook applied cleanly
Verified Revisions tab is appearing on the block_content form
Created several different revisions of the block and verified I saw all the revisions being stored
Reverted back and forth between revisions verifying they were switching correctly.
Tested the deleting of revisions and that worked too.

Great work!

mstrelan’s picture

I think we need an Issue Summary update and Change Record.

dpi’s picture

Created change record at https://www.drupal.org/node/3319245

Updated summary.

dpi’s picture

"Rerolled"

acbramley’s picture

May be NW based on allowedIfHasPermissions change but it's used elsewhere so maybe there's a reason not to use it

quietone’s picture

I made a small change to the CR. The title of the CR is a bit cryptic and doesn't mention the UI, should it?

dpi’s picture

I opted for listing each new UI available rather than a "UI" umbrella. Feel free to rearrange the title.

quietone’s picture

Oh, I see what you mean now. Can it be "Revision history, revert, and delete forms added to Block Content"?

dpi’s picture

Revision history is not a form.

Maybe "Revision history, and revert and delete forms, added to Block Content"

AaronMcHale’s picture

How about "Block Content now provides a UI for viewing, reverting and deleting revisions"?

Seems a little cleaner to me, keeping the module name near the start is also probably a good idea.

dpi’s picture

Updated title. I'm not invested in CR details, feel free to update further as it's wiki-like.

AaronMcHale’s picture

larowlan’s picture

Issue summary: View changes

Adding a release notes snippet and updating the change record somewhat

larowlan’s picture

Manually tested and noticed that the breadcrumbs aren't great

But we already have an issue for that #2317981: Move block content edit and delete routes under admin/content/block to improve IA for editors and fix breadcrumbs because its present on the delete and translate tabs too.

Left some minor comments on the MR

smustgrave’s picture

Status: Needs review » Needs work

Moving to NW for those changes.

dpi’s picture

I've addressed feedback from @larowlan in a local branch, however I'm unable to push new work to this repo due to a Gitlab bug. Requested assistance in Slack#gitlab. If there is no resolution I'll create a new MR soon enough.

Until then, new work/commits can be viewed at https://github.com/dpi/drupal/compare/10.1.x...dpi:drupal:1984588-block-...

Edit: updated and resolved less than 24 hours later. Thanks to @hestenet for stepping in.

dpi’s picture

Status: Needs work » Needs review

Feedback for @larowlan pushed and is green.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Tested this out and confirmed the feedback was addressed.

larowlan’s picture

Saving issue credits

larowlan’s picture

  • 86caf6f committed on 10.1.x
    Issue #1984588 by dpi, larowlan, AaronMcHale, smustgrave, acbramley: Add...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Merged to 10.1.x and published the change record, nice one folks 🎉

larowlan’s picture

Status: Fixed » Reviewed & tested by the community

Actually, sorry folks, I decided to revert this as I had a thought after the event.

I think we should also prevent reverting/deleting revisions for block content entities that are not reusable (aka inline blocks in layout builder).

And we should expand test coverage for that.

The issue for those blocks is LB references them by revision ID. But if you revert to a previous revision, LB will keeping showing the old revision as it doesn't update its reference.

I think the simplest thing to do here is prevent 'delete revision' and 'revert revision' on non-reusable blocks.

I don't see any harm in allowing viewing of those revisions though however in that scenario I think our current access logic (from this patch) is wrong, because we combine that with the parent access - so to view the block revisions you also need the equivalent 'view revisions' operation to return TRUE for the parent entity. I'm not sure that is right.

I thought about doing this in a followup, but I thought it was safer to revert instead

  • larowlan committed 1e984e3 on 10.1.x
    Revert "Issue #1984588 by dpi, larowlan, AaronMcHale, smustgrave,...
larowlan’s picture

Status: Reviewed & tested by the community » Needs work

For #66

shree.yesare’s picture

Need this for 9.4.x. is there any patch available for version 9.4.x ?

AaronMcHale’s picture

Need this for 9.4.x. is there any patch available for version 9.4.x ?

@shree.yesare for 9.4, 9.5 and 10.0 you should use the Block Content Revision UI contrib module, as the work in this issue is simply implementing the work done in #2350939: Implement a generic revision UI which was only committed to 10.1.

dpi’s picture

Status: Needs work » Needs review

@ #66

BlockContentAccessControlHandler seems to already prevent access for delete and revert when the entity is not reusable out of the box, under certain circumstances (dependency checks).

Created new MR:

  • The same Git commit lineage as the formerly merged PR.
  • Always check if non re-usable for revert/delete revision operations. Disallow even before dependency checks.
  • Reworked test to allow asserting access result messages.
  • Rearranged dataprovider arguments by non optional.
  • Switch out access strings for class object instance checks: removes a bunch of switch lines and easier to read.
dpi’s picture

Back for review.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Retested the MR very quickly and see that block revisions are working still.

xjm’s picture

Status: Reviewed & tested by the community » Needs review
Related issues: +#3318110: [meta] Reorganize Block items in the administration menu

Have we thought about the IA for this in terms of the block IA reorganization, which has one issue committed already and a second issue close?
#3318110: [meta] Reorganize Block items in the administration menu.

dpi’s picture

Status: Needs review » Reviewed & tested by the community

This issue tackles tasks around individual entities, rather than collection/index routes. So I'd say we're not affected unless paths of Block Content entities themselves are changing.

  • Menu's are not added/changed.
  • New paths (routes) are added, inherit whatever treatment canonical receives.
  • New local tasks (tasks are unrelated to IA changes?)
  • No new/changed actions

Breadcrumbs for individual Block Content entities, which typically include a collection link, are being tackled in #2317981: Move block content edit and delete routes under admin/content/block to improve IA for editors and fix breadcrumbs. This is new ground so is unlikely subjected to the re-org.

AaronMcHale’s picture

Based on my understanding of what this issue does, and @dpi's explanation in #76, and the fact I'm close to what's going on in #3318110: [meta] Reorganize Block items in the administration menu, I'm happy to second @dpi's comment.

It looks likely that this issue will be done prior to #2317981: Move block content edit and delete routes under admin/content/block to improve IA for editors and fix breadcrumbs being done, if so that issue will just need to account for the new paths this issue is introducing.

xjm’s picture

Issue tags: +Needs screenshots

Thanks @dpi and @AaronMcHale for the quick feedback!

The one thing we could do with then I think is screenshots showing the change. I think this is basically "before, there is no tab; after, there is a new tab" as in #57. Could we put screenshots of that and other parts of the new user interface in the IS? Thanks!

dpi’s picture

Issue summary: View changes

Added screens for the three UIs to IS + CR

dpi’s picture

Issue tags: -Needs screenshots
xjm’s picture

Sorry another question; what is up with the fact that there are two merge requests open and which is canonical? And why does one say "merged"? Did @larowlan actually use the GitLab merge feature? Or what is that about?

dpi’s picture

One MR is marked as merged, later reverted. I don’t think I can push to merged MRs.

Moved on with a new MR with the same commits.

  • larowlan committed d686df4a on 10.1.x
    Issue #1984588 by dpi, larowlan, AaronMcHale, smustgrave, xjm, acbramley...

larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Ok, take two, this is in 🎉 - thanks folks for sticking it out, it's been a long haul.

Status: Fixed » Closed (fixed)

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

fenstrat’s picture

FileSize
12.36 KB

Here's a version of #83 for anyone who needs this on Drupal 10.0.

Note it also depends on #2350939-314: Implement a generic revision UI and #2809291-192: Add "edit block $type" permissions

Andrew.Macpherson’s picture

Not sure if I should be posting here or not, but I have tested a few sites, and I can't actually see any option to VIEW any revision. That is, I can use the action buttons to either revert to or delete any revision listed, but I can't actually see the revision content itself. The 'view' link that is on the date listed in the node revision interface is not appearing for blocks (although the link to the user is).

acbramley’s picture

@Andrew.Macpherson block content doesn't have a view route so therefore doesn't have a view revision operation either.