From 25d201bb33cbd4e7fc4a446edfbe964238e49f37 Mon Sep 17 00:00:00 2001
From: Liam Morland <lkmorlan@uwaterloo.ca>
Date: Tue, 9 Mar 2021 15:44:23 -0500
Subject: [PATCH] ISTWCMS-4636: Add "People" and "Reports" links to the toolbar
 under "Workbench"

---
 uw_cfg_common.module | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/uw_cfg_common.module b/uw_cfg_common.module
index e2eafaba..8741e9eb 100644
--- a/uw_cfg_common.module
+++ b/uw_cfg_common.module
@@ -7,6 +7,7 @@
 
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Url;
 use Drupal\uw_cfg_common\Service\UWService;
 use Drupal\webform\WebformInterface;
 use Drupal\webform\WebformSubmissionStorageInterface;
@@ -197,6 +198,22 @@ function uw_cfg_common_toolbar_alter(&$items) {
   elseif (!UWService::userIsAdmin($current_user)) {
     // Remove "Manage" toolbar item.
     unset($items['administration']);
+    // Add links to "Workbench". 'dashboards' is renamed in
+    // uw_dashboard_toolbar_alter().
+    $links = [
+      'entity.user.collection' => t('People'),
+      'system.admin_reports' => t('Reports'),
+    ];
+    foreach ($links as $route => $title) {
+      $url = Url::fromRoute($route);
+      if ($url->access()) {
+        $items['dashboards']['tray']['dashboards']['#items'][] = [
+          '#type' => 'link',
+          '#title' => $title,
+          '#url' => $url,
+        ];
+      }
+    }
   }
 }
 
-- 
GitLab