From 0f05b0d8f114fee207a39252d8e2e6b2362e04b3 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Fri, 28 Jul 2023 13:56:50 -0400 Subject: [PATCH 1/4] Provide application user roles persistently for use in the views, and improve configuration wayfinding for platform administrators. (CFM-310) --- app/resources/locales/en_US/information.po | 6 +++ app/resources/locales/en_US/menu.po | 3 ++ app/src/Controller/AppController.php | 3 ++ .../Component/RegistryAuthComponent.php | 40 +++++++++++++++++++ app/templates/Dashboards/configuration.php | 29 +++++++++++++- app/templates/Dashboards/dashboard.php | 8 ++++ app/templates/layout/default.php | 16 +++++++- app/webroot/css/co-base.css | 16 ++++++++ 8 files changed, 119 insertions(+), 2 deletions(-) diff --git a/app/resources/locales/en_US/information.po b/app/resources/locales/en_US/information.po index 841a93e7b..48ed85c46 100644 --- a/app/resources/locales/en_US/information.po +++ b/app/resources/locales/en_US/information.po @@ -36,6 +36,12 @@ msgstr "You are not an active member in any collaboration. If your request for e msgid "cos.select" msgstr "Please select the collaboration (CO) you wish to manage." +msgid "cmp.config.notice" +msgstr "Looking for platform-wide configurations? Those are found in the COmanage CO." + +msgid "cmp.welcome" +msgstr "The COmanage CO provides platform-wide configurations." + msgid "entity.id" msgstr "ID: {0}" diff --git a/app/resources/locales/en_US/menu.po b/app/resources/locales/en_US/menu.po index 72149952c..53b9e0115 100644 --- a/app/resources/locales/en_US/menu.po +++ b/app/resources/locales/en_US/menu.po @@ -69,6 +69,9 @@ msgstr "CO Setup" msgid "co.configuration.panel.setup.desc" msgstr "Settings for the current CO" +msgid "co.configuration.title.common" +msgstr "Common CO Settings" + msgid "co.connections" msgstr "Connections" diff --git a/app/src/Controller/AppController.php b/app/src/Controller/AppController.php index d29da07e6..a189d1de6 100644 --- a/app/src/Controller/AppController.php +++ b/app/src/Controller/AppController.php @@ -146,6 +146,9 @@ public function beforeRender(\Cake\Event\EventInterface $event) { if(isset($this->RegistryAuth)) { // Components might not be loaded on error, so check $this->set('vv_menu_permissions', $this->RegistryAuth->getMenuPermissions($this->getCOID())); + + // Provide the user's application roles to the views. + $this->set('vv_user_roles', $this->RegistryAuth->getApplicationUserRoles($this->getCOID())); } return parent::beforeRender($event); diff --git a/app/src/Controller/Component/RegistryAuthComponent.php b/app/src/Controller/Component/RegistryAuthComponent.php index b59f0511a..71a15017e 100644 --- a/app/src/Controller/Component/RegistryAuthComponent.php +++ b/app/src/Controller/Component/RegistryAuthComponent.php @@ -422,6 +422,32 @@ public function calculatePermissionsForView(string $action, ?int $id=null): arra return $this->calculatePermissions($id); } + /** + * Obtain the application role of the user for general use in the views + * + * @since COmanage Registry v5.0.0 + * @param int $coId Current CO ID, if known + * @return array $appRoles Array of roles + */ + + public function getApplicationUserRoles(?int $coId): array { + $appUserRoles = []; + + // True for platform administrator + $appUserRoles['platform'] = $this->isPlatformAdmin(); + + // True for CO administrator + $appUserRoles['co'] = $this->isCoAdmin($coId); + + // TODO: add other application roles such as 'cou' and 'support' + // See: https://spaces.at.internet2.edu/display/COmanage/Registry+PE+Permissions + + // True if user is authenticated + $appUserRoles['authuser'] = $this->isAuthenticatedUser(); + + return $appUserRoles; + } + /** * Obtain the identifier of the currently authenticated user. * @@ -546,6 +572,20 @@ public function isApiUser(): bool { return $this->authenticatedApiUser; } + /** + * Determine if the current user is authenticated. + * + * @since COmanage Registry v5.0.0 + * @return bool True if the current user is authenticated + */ + + public function isAuthenticatedUser(): bool { + if(!empty($this->getAuthenticatedUser())) { + return true; + } + return false; + } + /** * Determine if the current user is a CO Administrator. * diff --git a/app/templates/Dashboards/configuration.php b/app/templates/Dashboards/configuration.php index e7ab5bec9..5bfae097c 100644 --- a/app/templates/Dashboards/configuration.php +++ b/app/templates/Dashboards/configuration.php @@ -34,6 +34,8 @@
+

+ + +

+ + Url->build([ + 'plugin' => null, + 'controller' => 'dashboards', + 'action' => 'configuration', + '?' => [ + 'co_id' => 1 + ]]), + $this->Url->build([ + 'plugin' => null, + 'controller' => 'dashboards', + 'action' => 'dashboard', + '?' => [ + 'co_id' => 1 + ]]) + ]; + ?> +
+ Alert->alert(__d('information','cmp.config.notice', $noticeUrls), 'information', true) ?> +
+ +
\ No newline at end of file diff --git a/app/templates/Dashboards/dashboard.php b/app/templates/Dashboards/dashboard.php index 500d807ba..70f1e2285 100644 --- a/app/templates/Dashboards/dashboard.php +++ b/app/templates/Dashboards/dashboard.php @@ -26,8 +26,16 @@ */ // XXX This is a placeholder + +// $flashArgs pass banner messages to the flash element container +$flashArgs = []; +if(!empty($banners)) { + $flashArgs['vv_banners'] = $banners; +} + ?>
+ element('flash', $flashArgs); ?>

\ No newline at end of file diff --git a/app/templates/layout/default.php b/app/templates/layout/default.php index d804d47c6..8b31dbac9 100644 --- a/app/templates/layout/default.php +++ b/app/templates/layout/default.php @@ -97,7 +97,6 @@
-
@@ -158,6 +157,21 @@ element('menuTop') ?>
+ + id == 1) && ($vv_action != 'select')): ?> + Url->build([ + 'plugin' => null, + 'controller' => 'dashboards', + 'action' => 'configuration', + '?' => [ + 'co_id' => 1 + ]]); + ?> +
+ +
+
diff --git a/app/webroot/css/co-base.css b/app/webroot/css/co-base.css index 090930665..1a9f2a81c 100644 --- a/app/webroot/css/co-base.css +++ b/app/webroot/css/co-base.css @@ -946,6 +946,16 @@ ul.form-list li.alert-banner .co-alert { .top-filters-fields-date .duet-date__toggle { margin-top: -3px; } +/* PLATFORM NOTICE (for COmanage CO) */ +#platform-notice { + padding: 0.5em; + text-align: center; + border-bottom: 1px solid var(--cmg-color-bg-006); + background-color: var(--cmg-color-highlight-004); +} +#platform-notice a:hover { + text-decoration: underline; +} /* CO CONFIGURATION DASHBOARD */ .config-menu { list-style: none; @@ -965,6 +975,12 @@ ul.form-list li.alert-banner .co-alert { border-bottom: 1px solid var(--cmg-color-bg-006); padding-bottom: 1em; } +h2.config-subtitle { + font-size: 1.6em; +} +.config-platform-notice { + margin: 4em 0 -3em; +} /* INDEX ACTION COMMAND MENUS */ th.with-field-actions { padding-left: 2.75em; From 04a03161aa3addd8fe7339412a59693266bd4470 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Fri, 28 Jul 2023 14:46:08 -0400 Subject: [PATCH 2/4] Add controller to persistent view variables, and add platform config notice to config menu panel. (CFM-310) --- app/src/Controller/AppController.php | 3 ++- app/templates/element/menuPanel.php | 23 +++++++++++++++++++++++ app/templates/layout/default.php | 9 ++++++++- app/webroot/css/co-base.css | 14 ++++++++++++++ app/webroot/css/co-responsive.css | 6 ++++++ 5 files changed, 53 insertions(+), 2 deletions(-) diff --git a/app/src/Controller/AppController.php b/app/src/Controller/AppController.php index a189d1de6..f8714ae4d 100644 --- a/app/src/Controller/AppController.php +++ b/app/src/Controller/AppController.php @@ -140,7 +140,8 @@ public function beforeRender(\Cake\Event\EventInterface $event) { $modelsName = $this->name; // Views can also inspect the request object to determine the current - // action, but it seems slightly easier to do it once here. + // controller and action, but it seems slightly easier to do it once here. + $this->set('vv_controller', $this->request->getParam('controller')); $this->set('vv_action', $this->request->getParam('action')); if(isset($this->RegistryAuth)) { diff --git a/app/templates/element/menuPanel.php b/app/templates/element/menuPanel.php index 9ef29eda7..2ae3b3d4f 100644 --- a/app/templates/element/menuPanel.php +++ b/app/templates/element/menuPanel.php @@ -411,6 +411,29 @@ */ ?>
+ id != 1 && $vv_user_roles['platform']): ?> + Url->build([ + 'plugin' => null, + 'controller' => 'dashboards', + 'action' => 'configuration', + '?' => [ + 'co_id' => 1 + ]]), + $this->Url->build([ + 'plugin' => null, + 'controller' => 'dashboards', + 'action' => 'dashboard', + '?' => [ + 'co_id' => 1 + ]]) + ]; + ?> +
+ Alert->alert(__d('information','cmp.config.notice', $noticeUrls), 'information', true) ?> +
+
diff --git a/app/templates/layout/default.php b/app/templates/layout/default.php index 8b31dbac9..7a2fdf035 100644 --- a/app/templates/layout/default.php +++ b/app/templates/layout/default.php @@ -89,6 +89,13 @@ } else { $bodyClasses .= ' logged-out'; } + + // add hints that we're in the platform-level (COmanage) CO + $isPlatformCO = false; + if(!empty($vv_cur_co) && ($vv_cur_co->id == 1) && !($vv_controller == 'Cos' && $vv_action == 'select')) { + $isPlatformCO = true; + $bodyClasses .= ' platform-co'; + } ?>
@@ -158,7 +165,7 @@
- id == 1) && ($vv_action != 'select')): ?> + Url->build([ 'plugin' => null, diff --git a/app/webroot/css/co-base.css b/app/webroot/css/co-base.css index 1a9f2a81c..87c8ac7d0 100644 --- a/app/webroot/css/co-base.css +++ b/app/webroot/css/co-base.css @@ -981,6 +981,20 @@ h2.config-subtitle { .config-platform-notice { margin: 4em 0 -3em; } +#main-menu .menu-panel .config-platform-notice { + margin: 0 0 1em; +} +#main-menu .menu-panel .config-platform-notice a { + display: inline; + padding: 0; +} +#main-menu .menu-panel .config-platform-notice a:hover { + background-color: unset; + text-decoration: underline; +} +#main-menu .menu-panel .config-platform-notice .material-icons-outlined { + font-size: 24px; +} /* INDEX ACTION COMMAND MENUS */ th.with-field-actions { padding-left: 2.75em; diff --git a/app/webroot/css/co-responsive.css b/app/webroot/css/co-responsive.css index 44e9cd472..496e9110c 100644 --- a/app/webroot/css/co-responsive.css +++ b/app/webroot/css/co-responsive.css @@ -239,6 +239,9 @@ #advanced-menu { margin-top: 2rem; } + body.platform-co #advanced-menu li a { + padding: 0.25em; + } #co-menu-collapse { display: flex; justify-content: center; @@ -294,6 +297,9 @@ bottom: 2rem; margin: 0; } + #main-menu .menu-panel .config-platform-notice { + margin: 10em 0 4em; + } /* GENERAL */ .table-container { overflow: unset; From 239314b7b4f6478e2ae482b6178aab6e748f6f92 Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Wed, 11 Oct 2023 14:35:10 -0400 Subject: [PATCH 3/4] Improvements to the messaging and code style for platform admin wayfinding improvements (CFM-296) --- app/resources/locales/en_US/information.po | 6 +++--- app/resources/locales/en_US/menu.po | 15 ++++++--------- .../Component/RegistryAuthComponent.php | 7 ++----- app/templates/Dashboards/configuration.php | 3 ++- app/templates/element/menuPanel.php | 4 ++-- app/templates/layout/default.php | 11 +---------- 6 files changed, 16 insertions(+), 30 deletions(-) diff --git a/app/resources/locales/en_US/information.po b/app/resources/locales/en_US/information.po index 48ed85c46..0510e8bfc 100644 --- a/app/resources/locales/en_US/information.po +++ b/app/resources/locales/en_US/information.po @@ -37,10 +37,10 @@ msgid "cos.select" msgstr "Please select the collaboration (CO) you wish to manage." msgid "cmp.config.notice" -msgstr "Looking for platform-wide configurations? Those are found in the COmanage CO." +msgstr "Platform-wide configurations are available in the COmanage CO." -msgid "cmp.welcome" -msgstr "The COmanage CO provides platform-wide configurations." +msgid "cmp.co.notice" +msgstr "You are viewing the platform-level COmanage CO." msgid "entity.id" msgstr "ID: {0}" diff --git a/app/resources/locales/en_US/menu.po b/app/resources/locales/en_US/menu.po index 53b9e0115..967082c80 100644 --- a/app/resources/locales/en_US/menu.po +++ b/app/resources/locales/en_US/menu.po @@ -42,6 +42,9 @@ msgstr "Attributes" msgid "co.configuration" msgstr "Configuration" +msgid "co.configuration.desc" +msgstr "Configuration for the current CO" + msgid "co.configuration.short" msgstr "Config" @@ -58,19 +61,13 @@ msgid "co.configuration.panel.personalization.desc" msgstr "Dashboards, custom text, and theming" msgid "co.configuration.panel.platform" -msgstr "Platform-Wide Settings" +msgstr "Platform-Wide Configuration" msgid "co.configuration.panel.platform.desc" msgstr "These configurations are found only in the COmanage CO" -msgid "co.configuration.panel.setup" -msgstr "CO Setup" - -msgid "co.configuration.panel.setup.desc" -msgstr "Settings for the current CO" - -msgid "co.configuration.title.common" -msgstr "Common CO Settings" +msgid "co.configuration.title" +msgstr "CO Configuration" msgid "co.connections" msgstr "Connections" diff --git a/app/src/Controller/Component/RegistryAuthComponent.php b/app/src/Controller/Component/RegistryAuthComponent.php index 71a15017e..c88f073b5 100644 --- a/app/src/Controller/Component/RegistryAuthComponent.php +++ b/app/src/Controller/Component/RegistryAuthComponent.php @@ -436,7 +436,7 @@ public function getApplicationUserRoles(?int $coId): array { // True for platform administrator $appUserRoles['platform'] = $this->isPlatformAdmin(); - // True for CO administrator + // True for administrator of the current CO $appUserRoles['co'] = $this->isCoAdmin($coId); // TODO: add other application roles such as 'cou' and 'support' @@ -580,10 +580,7 @@ public function isApiUser(): bool { */ public function isAuthenticatedUser(): bool { - if(!empty($this->getAuthenticatedUser())) { - return true; - } - return false; + return !empty($this->authenticatedUser); } /** diff --git a/app/templates/Dashboards/configuration.php b/app/templates/Dashboards/configuration.php index 5bfae097c..cd16fba0f 100644 --- a/app/templates/Dashboards/configuration.php +++ b/app/templates/Dashboards/configuration.php @@ -53,7 +53,8 @@ -

+

+