Skip to content

Provide application user roles persistently for use in the views, and improve configuration wayfinding for platform administrators. (CFM-310) #113

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 "<a href="{0}">Platform-wide configurations</a> are available in the <a href="{1}">COmanage CO</a>."

msgid "cmp.co.notice"
msgstr "You are viewing the platform-level COmanage CO."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more minor nit: I try to avoid second person language in the interface and documentation. (I realize others have different styles, and also cos.select run exactly counter to this statement.) We should pick a style and be consistent, and also maybe clarify the language a bit more. eg: "This is the COmanage CO, which is used for platform wide configurations".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me. The phrase here is very similar to the first commit, which was "The COmanage CO provides platform-wide configurations." I'll change it to your phrasing. The assertion of "This is" makes things clearer.


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

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

Expand All @@ -58,16 +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"
msgstr "CO Configuration"

msgid "co.connections"
msgstr "Connections"
Expand Down
6 changes: 5 additions & 1 deletion app/src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,16 @@ 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)) {
// 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
37 changes: 37 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 administrator of the current CO
$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,17 @@ 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 {
return !empty($this->authenticatedUser);
}

/**
* Determine if the current user is a CO Administrator.
*
Expand Down
30 changes: 29 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,9 @@
?>
</li>
<?php endforeach; // $vv_configuration_menu_items ?>
</ul>
</ul>
<h2 class="config-subtitle mb-2"><?= __d('menu','co.configuration.title') ?></h2>
<p class="menu-panel-links-desc"><?= __d('menu','co.configuration.desc') ?></p>
<?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 +76,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>
27 changes: 25 additions & 2 deletions app/templates/element/menuPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@
<?php endif; // $vv_platform_menu_items ?>
<ul class="menu-panel-links">
<li>
<h3><?= __d('menu','co.configuration.panel.setup') ?></h3>
<p class="menu-panel-links-desc"><?= __d('menu','co.configuration.panel.setup.desc') ?></p>
<h3><?= __d('menu','co.configuration.title') ?></h3>
<p class="menu-panel-links-desc"><?= __d('menu','co.configuration.desc') ?></p>
<ul class="menu-panel-links-inner">
<li>
<?php
Expand Down Expand Up @@ -411,6 +411,29 @@
</ul>
*/ ?>
</div>
<?php if($vv_cur_co->id != 1 && $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>
Expand Down
14 changes: 13 additions & 1 deletion app/templates/layout/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
?>
<body class="<?= $bodyClasses ?>" onload="jsOnLoadCallHooks()">
<div id="skip-to-content-box">
Expand All @@ -97,7 +104,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 +164,12 @@
<?= $this->element('menuTop') ?>
</div>
</div>

<?php if($isPlatformCO): ?>
<div id="platform-notice">
<?= __d('information','cmp.co.notice') ?>
</div>
<?php endif; ?>

<div id="main-wrapper">
<?php if(!empty($vv_user) && !empty($vv_cur_co) && !$isCoSelectView): ?>
Expand Down
30 changes: 30 additions & 0 deletions app/webroot/css/co-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -965,6 +975,26 @@ 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;
}
#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;
Expand Down
6 changes: 6 additions & 0 deletions app/webroot/css/co-responsive.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -294,6 +297,9 @@
bottom: 2rem;
margin: 0;
}
#main-menu .menu-panel .config-platform-notice {
margin: 10em 0 4em;
}
/* GENERAL */
.table-container {
overflow: unset;
Expand Down