Edit and delete my reviews functionality

Created on 31 March 2025, 2 months ago

Problem/Motivation

Currently there is no way for a user to edit or delete their reviews even if they have permissions to do so.

Steps to reproduce

Proposed resolution

Add user facing interface elements to allow editing and deleting reviews.

Remaining tasks

  • Create a route for user access to the review edit form (the same add review form should work for editing too)
  • Create an access controller for the edit form/button.
  • Create a edit form title function.
  • Create a view for the user's reviews.

User interface changes

  • Add "Edit my review" action button to the review page.
  • Add "Delete my review" action button to the review page.
  • Add a tab to the user's page with a view of all the reviews they left and action buttons for those.

API changes

Data model changes

✨ Feature request
Status

Active

Version

1.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @rhovland
  • πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

    Feature all done. Ready for review

  • πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon
  • πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

    Some notes about how the user facing entity list is handled:
    The default entity list builder is designed for administrative use. It does not filter the list based on the current user.
    The columns presented in the list are relevant for admin users but mostly useless for customers.
    As a result it makes more sense to create a separate list builder for customers since the feature set is completely different.

    The user list is a route that points to the ProductReviewController to render a page.
    The overviewPage() function that gets called to render a page uses the createHandlerInstance() feature of EntityTypeManagerInterface to set a custom handler, in this case a list builder. It then returns a rendered list built by the Entity system.

    The one dangling question comes from the comment on createHandlerInstance()

    * Usually \Drupal\Core\Entity\EntityTypeManagerInterface::getHandler() is
    * preferred since that method has additional checking that the class exists
    * and has static caches.

    In this case the class always exists because it's part of the module so I'd think a check for that would be unnecessary.
    That leaves the question of is this page being output cached? Or do we need to manually cache it?

  • πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

    Here's a preview of how the customer's My Reviews page looks (in a bootstrap theme):

    The action links for a user that has already left a review on a product's review page:

Production build 0.71.5 2024