When a user's role has the permission to view the "track role" tabs, the "role ID" column is completely blank when the user's role doesn't also have the "administer permissions" permission.

Can this just be a text description instead of a link back to edit the role for these users? (Or, failing that, a text description for everyone? There's so many other ways to get into edit the role and this one doesn't seem that necessary.)

Comments

kpaxman created an issue. See original summary.

kpaxman’s picture

Issue summary: View changes
kpaxman’s picture

Checking further, this is also true on the Role Watchdog History page, even though those are just text and not a link. Surely there's *some* way of showing the name of the role though...

gaurav.kapoor’s picture

As of now only solution is to give the required permission to view the User Role labels. Please do update here if you find any other solution. Thanks.

kid_mousikos’s picture

For those of you that are looking for a workaround, I implemented the following hook. It will display roles for users with the 'access role_watchdog reports' permission. Add it to your module of choice and you should be good to go. This is not intended as a proper fix for the issue, just a workaround. A proper fix will require the module to undergo some architectural changes.

/**
 * Implements hook_entity_access().
 */
function YOURMODULE_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
  // Allow access to user role entities, if the user has the right permissions and is visiting an authorized page.
  $route = \Drupal::routeMatch()->getRouteObject();
  if (!empty($route)) {
    $current_contextual_path = $route->getPath();
    $allowed_paths = [
      '/admin/role-watchdog-history',
      '/user/{user}/track-grants',
      '/user/{user}/track-history',
    ];

    foreach ($allowed_paths as $allowed_path) {
      if (strpos($current_contextual_path, $allowed_path) !== FALSE && $entity instanceof Role) {
        $result = AccessResult::neutral();

        if ($operation == 'view') {
          $result = AccessResult::allowedIfHasPermission($account, 'access role_watchdog reports');
        }

        return $result;
      }
    }
  }

}
gaurav.kapoor’s picture

@kid_mousikos Thanks for the workaround, what architectural changes do you think we should do?

gaurav.kapoor’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
berliner’s picture