Skip to content

Commit

Permalink
Provide application user roles persistently for use in the views, and…
Browse files Browse the repository at this point in the history
… improve configuration wayfinding for platform administrators. (CFM-310)
  • Loading branch information
arlen committed Sep 21, 2023
1 parent 39349a5 commit cac5f70
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/resources/locales/en_US/information.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="{0}">platform-wide configurations</a>? Those are found in the <a href="{1}">COmanage CO</a>."

msgid "cmp.welcome"
msgstr "The COmanage CO provides platform-wide <a href="{0}">configurations</a>."

msgid "entity.id"
msgstr "ID: {0}"

Expand Down
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/menu.po
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,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"

Expand Down
3 changes: 3 additions & 0 deletions app/src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
40 changes: 40 additions & 0 deletions app/src/Controller/Component/RegistryAuthComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
29 changes: 28 additions & 1 deletion app/templates/Dashboards/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

<section class="inner-content">
<?php if(!empty($vv_platform_menu_items)): ?>
<h2 class="config-subtitle"><?= __d('menu','co.configuration.panel.platform') ?></h2>
<p class="menu-panel-links-desc"><?= __d('menu','co.configuration.panel.platform.desc') ?></p>
<ul id="platform-menu" class="config-menu">
<?php foreach($vv_platform_menu_items as $label => $cfg): ?>
<li>
Expand All @@ -50,7 +52,8 @@
?>
</li>
<?php endforeach; // $vv_configuration_menu_items ?>
</ul>
</ul>
<h2 class="config-subtitle mb-2"><?= __d('menu','co.configuration.title.common') ?></h2>
<?php endif; // $vv_platform_menu_items ?>
<ul id="configuration-menu" class="config-menu">
<?php foreach($vv_configuration_menu_items as $label => $cfg): ?>
Expand All @@ -72,6 +75,30 @@
</ul>
</section>

<?php if(empty($vv_platform_menu_items) && $vv_user_roles['platform']): ?>
<?php
$noticeUrls = [
$this->Url->build([
'plugin' => null,
'controller' => 'dashboards',
'action' => 'configuration',
'?' => [
'co_id' => 1
]]),
$this->Url->build([
'plugin' => null,
'controller' => 'dashboards',
'action' => 'dashboard',
'?' => [
'co_id' => 1
]])
];
?>
<div class="config-platform-notice">
<?= $this->Alert->alert(__d('information','cmp.config.notice', $noticeUrls), 'information', true) ?>
</div>
<?php endif; ?>

<div class="comanage-version">
<?php print __('registry.version', chop(file_get_contents(CONFIG . "VERSION"))); ?>
</div>
8 changes: 8 additions & 0 deletions app/templates/Dashboards/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

?>

<div id="introduction">
<?= $this->element('flash', $flashArgs); ?>
<p><?= __d('menu','menu.introduction') ?></p>
</div>
16 changes: 15 additions & 1 deletion app/templates/layout/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@

<!-- Primary layout -->
<div id="comanage-wrapper">

<!-- Include custom header -->
<?php if(!empty($vv_theme_header)): ?>
<header id="customHeader">
Expand Down Expand Up @@ -158,6 +157,21 @@
<?= $this->element('menuTop') ?>
</div>
</div>

<?php if(!empty($vv_cur_co) && ($vv_cur_co->id == 1) && ($vv_action != 'select')): ?>
<?php
$platformConfigUrl = $this->Url->build([
'plugin' => null,
'controller' => 'dashboards',
'action' => 'configuration',
'?' => [
'co_id' => 1
]]);
?>
<div id="platform-notice">
<?= __d('information','cmp.welcome', [$platformConfigUrl]) ?>
</div>
<?php endif; ?>

<div id="main-wrapper">
<?php if(!empty($vv_user) && !empty($vv_cur_co) && !$isCoSelectView): ?>
Expand Down
16 changes: 16 additions & 0 deletions app/webroot/css/co-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,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;
Expand All @@ -938,6 +948,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;
Expand Down

0 comments on commit cac5f70

Please sign in to comment.