Skip to content

Commit

Permalink
Improve alert banner configuration (CFM-218/CFM-465)
Browse files Browse the repository at this point in the history
  • Loading branch information
arlen committed Nov 13, 2025
1 parent e8084bf commit e015a94
Show file tree
Hide file tree
Showing 21 changed files with 117 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@


if(!empty($vv_push_endpoint)) {
// XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning)
$banners = [
__d('api_connector', 'information.endpoint.push', [$vv_push_endpoint])
$alerts = [
[
'type' => 'information',
'message' => __d('api_connector', 'information.endpoint.push', [$vv_push_endpoint])
]
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning)
$banners = [
__d('information', 'plugin.config.none')
$alerts = [
[
'type' => 'information',
'message' => __d('information', 'plugin.config.none')
]
];

// XXX Revisit this - what's the "Push Mode" text attempting to convey here (with no other information)?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@

// We provide the current password status in a banner message since that's all the
// information we really want to display about a password.

// XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning)
$banners = [
$vv_status->comment

$alerts = [
[
'type' => 'information',
'message' => $vv_status->comment
]
];

$fields = [];
Expand Down
8 changes: 5 additions & 3 deletions app/plugins/CoreApi/templates/MatchCallbacks/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
*/

if(!empty($vv_api_endpoint)) {
// XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning)
$banners = [
__d('core_api', 'information.endpoint.match.callback', [$vv_api_endpoint])
$alerts = [
[
'type' => 'information',
'message' => __d('core_api', 'information.endpoint.match.callback', [$vv_api_endpoint])
]
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ declare(strict_types = 1);
$this->Field->disableFormEditMode();

// There are currently no configurable options for the SSH Key Authenticator

// XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning)
$banners = [
__d('information', 'plugin.config.none')
$alerts = [
[
'type' => 'information',
'message' => __d('information', 'plugin.config.none')
]
];
26 changes: 13 additions & 13 deletions app/src/View/Helper/FieldHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -736,56 +736,56 @@ public function restructureFieldArguments(array $fieldArgs) {

// Pull out the top-level field options that are intended for Cake, and
// insert them into the $fieldOptions array.
if(isset($fieldArgs['empty'])) {
if(array_key_exists('empty', $fieldArgs)) {
$fieldOptions['empty'] = $fieldArgs['empty'];
unset($fieldArgs['empty']);
}
if(isset($fieldArgs['required'])) {
if(array_key_exists('required', $fieldArgs)) {
$fieldOptions['required'] = $fieldArgs['required'];
unset($fieldArgs['required']);
}
if(isset($fieldArgs['default'])) {
if(array_key_exists('default', $fieldArgs)) {
$fieldOptions['default'] = $fieldArgs['default'];
unset($fieldArgs['default']);
}
if(isset($fieldArgs['readonly'])) {
if(array_key_exists('readonly', $fieldArgs)) {
$fieldOptions['readonly'] = $fieldArgs['readonly'];
unset($fieldArgs['readonly']);
}
if(isset($fieldArgs['value'])) {
if(array_key_exists('value', $fieldArgs)) {
$fieldOptions['value'] = $fieldArgs['value'];
unset($fieldArgs['value']);
}
if(isset($fieldArgs['type'])) {
if(array_key_exists('type', $fieldArgs)) {
$fieldOptions['type'] = $fieldArgs['type'];
unset($fieldArgs['type']);
}
if(isset($fieldArgs['options'])) {
if(array_key_exists('options', $fieldArgs)) {
// select options that are set explicitly
$fieldOptions['options'] = $fieldArgs['options'];
unset($fieldArgs['options']);
}
if(isset($fieldArgs['placeholder'])) {
if(array_key_exists('placeholder', $fieldArgs)) {
$fieldOptions['placeholder'] = $fieldArgs['placeholder'];
unset($fieldArgs['placeholder']);
}
if(isset($fieldArgs['class'])) {
if(array_key_exists('class', $fieldArgs)) {
$fieldOptions['class'] = $fieldArgs['class'];
unset($fieldArgs['class']);
}
if(isset($fieldArgs['id'])) {
if(array_key_exists('id', $fieldArgs)) {
$fieldOptions['id'] = $fieldArgs['id'];
unset($fieldArgs['id']);
}
if(isset($fieldArgs['style'])) {
if(array_key_exists('style', $fieldArgs)) {
$fieldOptions['style'] = $fieldArgs['style'];
unset($fieldArgs['style']);
}
if(isset($fieldArgs['checked'])) {
if(array_key_exists('checked', $fieldArgs)) {
$fieldOptions['checked'] = $fieldArgs['checked'];
unset($fieldArgs['checked']);
}
if(isset($fieldArgs['label'])) {
if(array_key_exists('label', $fieldArgs)) {
// The label field maps to the CakePHP label field (can be "false" to hide the label)
$fieldOptions['label'] = $fieldArgs['label'];
unset($fieldArgs['label']);
Expand Down
4 changes: 2 additions & 2 deletions app/templates/ApiUsers/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

// Output advisory banner when co=1
if($vv_cur_co->isCOmanageCO()) {
$banners = [
__d('information','api.cmp')
$alerts = [
['message' => __d('information','api.cmp')]
];
}

Expand Down
4 changes: 2 additions & 2 deletions app/templates/ApiUsers/fields-generate.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

$banners = [
__d('information', 'api.key')
$alerts = [
['message' => __d('information', 'api.key')]
];

$fields = [
Expand Down
4 changes: 2 additions & 2 deletions app/templates/ApiUsers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/

if($vv_cur_co->isCOmanageCO()) {
$banners = [
__d('information', 'api.cmp')
$alerts = [
['message' => __d('information', 'api.cmp')]
];
}

Expand Down
4 changes: 2 additions & 2 deletions app/templates/Dashboards/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

// $flashArgs pass banner messages to the flash element container
$flashArgs = [];
if(!empty($banners)) {
$flashArgs['vv_banners'] = $banners;
if(!empty($alerts)) {
$flashArgs['vv_alerts'] = $alerts;
}

?>
Expand Down
6 changes: 5 additions & 1 deletion app/templates/ExtIdentitySourceRecords/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ $indexColumns = [
// We start with id to ensure there is a clickable field in the row
'id' => [
'type' => 'link',
'sortable' => true
'sortable' => true,
'class' => 'cm-modal-link nospin', // launch this in a modal
'dataAttrs' => [
['data-cm-modal-title', __d('controller', 'ExtIdentitySourceRecords', 1)]
]
],
'source_key' => [
'type' => 'echo',
Expand Down
8 changes: 5 additions & 3 deletions app/templates/ExtIdentitySourceRecords/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ $noticeText = __d(
]
);

// XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning)
$banners = [
$noticeText
$alerts = [
[
'type' => 'information',
'message' => $noticeText
]
];

// This view does not support add or edit
Expand Down
10 changes: 6 additions & 4 deletions app/templates/ExternalIdentities/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ if(!empty($vv_obj->ext_identity_source_record)) {
]
);

// XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning)
// XXX Also: the placement here is wrong; this should be displaying under the subtitle, not the main title.
$banners = [
$noticeText
// XXX The placement here is wrong; this should be displaying under the subtitle, not the main title.
$alerts = [
[
'type' => 'information',
'message' => $noticeText
]
];
}

Expand Down
4 changes: 2 additions & 2 deletions app/templates/HistoryRecords/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

$banners = [
$alerts = [
// CFM-76 info message pending eventual "virtual" view consolidating all History Record types
__d('information', 'HistoryRecords.xref')
['message' => __d('information', 'HistoryRecords.xref')]
];

$indexColumns = [
Expand Down
49 changes: 25 additions & 24 deletions app/templates/Standard/add-edit-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,32 @@
}
include($templatePath . DS . $fieldsFile);

// $flashArgs pass banner messages to the flash element container
// $flashArgs pass alert messages to the flash element container.
// $alertMessages will hold the messages to pass to $flashArgs.
$flashArgs = [];
if(!empty($banners)) {
// Pass in any configured banners from the fields file
$flashArgs['vv_banners'] = $banners;
$alertMessages = [];

// Check for changelog archive view. These alerts come first.
$clfield = $vv_obj->changelogAttributeName();

if($vv_obj->deleted) {
$alertMessages[] = [
'type' => 'information',
'message' => __d('information', 'changelog.deleted')
];
} elseif(!empty($vv_obj->$clfield)) {
$alertMessages[] = [
'type' => 'information',
'message' => __d('information', 'changelog.archived')
];
}

// Include any configured messages from the $alerts array in the fields file
$alertMessages = array_merge($alertMessages, $alerts ?? []);

if(!empty($alertMessages)) {
// We have alerts. Assign them to $flashArgs for later rendering.
$flashArgs['vv_alerts'] = $alertMessages;
}

// If you're looking to set a custom $vv_title, you might be able to use
Expand Down Expand Up @@ -189,26 +210,6 @@
<?= $this->element('flash', $flashArgs) ?>
<?php endif; ?>

<?php
// XXX temporary for CFM-24
// XXX after merge of PR-342 pass these banners in as configuration above
$clfield = $vv_obj->changelogAttributeName();

if($vv_obj->deleted) {
print $this->element('notify/alert',
['type' => 'information',
'message' => __d('information', 'changelog.deleted'),
'dismissible ' => false]
);
} elseif(!empty($vv_obj->$clfield)) {
print $this->element('notify/alert',
['type' => 'information',
'message' => __d('information', 'changelog.archived'),
'dismissible ' => false]
);
}
?>

<?php
$linkId = null;

Expand Down
6 changes: 3 additions & 3 deletions app/templates/Standard/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@

// $flashArgs pass banner messages to the flash element container
$flashArgs = [];
if(!empty($banners)) {
// Pass in any configured banners from columns.inc
$flashArgs['vv_banners'] = $banners;
if(!empty($alerts)) {
// Pass in any configured alerts from columns.inc
$flashArgs['vv_alerts'] = $alerts;
}

// Subnavigation
Expand Down
15 changes: 6 additions & 9 deletions app/templates/element/flash.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
?>

<!-- Flash Messages and defined Info Banners -->
<!-- Flash Messages and defined Info Banners/Alerts -->
<div class="alert-container" id="flash-messages">
<?php
/* Render any Flash messages that have bubbled up.
Expand All @@ -35,16 +35,13 @@
print $this->Flash->render();

/* Render information banners explicitly defined in Configuration.
In columns.inc files, these are defined in the banners[] array.
These are defined in the alerts[] array in columns.inc and fields.inc files.
See app/templates/ApiUsers/columns.inc for an example. These must
be passed in as $vv_banners to this element from the calling template.
NOTE: In fields.inc files, add information banners by referencing
the 'notify/alert' element directly (just as we do here).
be passed in as $vv_alerts to this element from the calling template.
*/
if(!empty($vv_banners)) {
foreach($vv_banners as $b) {
print $this->element('notify/alert', ['message' => $b]);
if(!empty($vv_alerts)) {
foreach($vv_alerts as $a) {
print $this->element('notify/alert', $a);
}
}
?>
Expand Down
3 changes: 1 addition & 2 deletions app/templates/element/notify/alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
*/

$type ??= 'warning';

$alertClass = "alert-{$type}";
$showButton = false;

Expand All @@ -47,7 +46,7 @@
?>

<div class="alert <?= $alertClass ?> co-alert" role="alert">
<div class="alert-body d-flex align-items-center">
<div class="alert-body d-flex align-items-center gap-1">
<span class="alert-title d-flex align-items-center">
<span class="material-symbols-outlined alert-icon"><?= $this->Alert->getAlertIcon($type) ?></span>
<?php if(isset($title)): ?>
Expand Down
Loading

0 comments on commit e015a94

Please sign in to comment.