Add permission to control role-based access to Entity Usage overview page

Created on 28 August 2025, about 2 months ago

Problem/Motivation

Currently, the Entity Usage Explorer overview page does not have a dedicated permission.
Access to this page cannot be controlled role-wise, which means site administrators cannot restrict or grant access to specific roles.

Steps to reproduce

1. Enable the Entity Usage Explorer module.
2. Log in as a user with a role that does not have the `administer content` permission.
3. Try visiting `/admin/usage/{entity_type}/{entity_id}`.
- The page is not accessible, since only users with the `administer content` permission can currently view it.
4. Go to `/admin/people/permissions`.
- There is no dedicated permission available to grant role-specific access to the Entity Usage overview page.

Proposed resolution

- Add a custom permission: Access Entity Usage overview page.
- Apply this permission to the route `entity_usage_explorer.usage_page`.
- Update `hook_entity_operation()` so that the “Usage” operation link is only shown if the current user has this permission.
- This will allow site administrators to grant or deny access role-wise.

Remaining tasks

- Add the new permission in `entity_usage_explorer.permissions.yml`.
- Update the route definition to require the new permission.
- Update `hook_entity_operation()` to check the permission via `$account->hasPermission()`.
- Test with different roles to ensure the link only appears when permission is granted.
- Add/update automated tests if available.

User interface changes

- A new permission “Access Entity Usage overview page” will appear on the `/admin/people/permissions` page.
- Site admins can assign or revoke this permission per role.

API changes

None.

Data model changes

None.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India keshav patel

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

Comments & Activities

Production build 0.71.5 2024