Skip to content

Commit

Permalink
Refactor fields.inc to be configuration only - first pass. (CFM-218)
Browse files Browse the repository at this point in the history
  • Loading branch information
arlen committed Sep 18, 2025
1 parent 3a7a27e commit 7e8d4ed
Show file tree
Hide file tree
Showing 116 changed files with 2,996 additions and 4,550 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ApiSourcesTable extends Table {
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;
use \App\Lib\Traits\TabTrait;

/**
* Perform Cake Model initialization.
Expand Down Expand Up @@ -74,6 +75,24 @@ public function initialize(array $config): void {
$this->setPrimaryLink(['external_identity_source_id']);
$this->setRequiresCO(true);

// All the tabs share the same configuration in the ModelTable file
// XXX Reenable when this doesn't throw an error (same error as https://todos.internet2.edu/browse/CFM-475 )
// $this->setTabsConfig(
// [
// // Ordered list of Tabs
// 'tabs' => ['ExternalIdentitySources', 'ApiConnector.ApiSources', 'ExternalIdentitySources@action.search'],
// // What actions will include the subnavigation header
// 'action' => [
// // If a model renders in a subnavigation mode in edit/view mode, it cannot
// // render in index mode for the same use case/context
// // XXX edit should go first.
// 'ExternalIdentitySources' => ['edit', 'view', 'search'],
// 'ApiConnector.ApiSources' => ['edit'],
// 'ExternalIdentitySources@action.search' => [],
// ],
// ]
// );

$this->setPermissions([
// Actions that operate over an entity (ie: require an $id)
'entity' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,14 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// This view does currently not support read-only
if($vv_action == 'edit') {
if(!empty($vv_push_endpoint)) {
print $this->element('notify/banner', [
'info' => __d('api_connector', 'information.endpoint.push', [$vv_push_endpoint])
]);
}

print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'api_source_id',
]
]);
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])
];
}

$fields = [
'api_source_id'
];

This file was deleted.

20 changes: 14 additions & 6 deletions app/availableplugins/ApiConnector/templates/ApiSources/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@
*/

// This view does currently not support read-only
if($vv_action == 'edit') {
print '<li class="info-title"><h3>' . __d('api_connector', 'field.ApiSources.push_mode') . '</h3></li>';

print $this->element('notify/banner', [
'info' => __d('information', 'plugin.config.none',)
]);
if($vv_action !== 'edit') {
return;
}

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

// XXX Revisit this - what's the "Push Mode" text attempting to convey here (with no other information)?
$fields = [
'SUBTITLE' => [
'subtitle' => __d('api_connector', 'field.ApiSources.push_mode')
]
];
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// This view does currently not support read-only
if($vv_action == 'add' || $vv_action == 'edit') {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'filename',
]
]);
}
$fields = [
'filename'
];
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,10 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// This view does currently not support read-only
if($vv_action == 'add' || $vv_action == 'edit') {
foreach([
'filename',
'format',
'archivedir',
'threshold_check',
'threshold_override',
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field,
]
]);
}
}
$fields = [
'filename',
'format',
'archivedir',
'threshold_check',
'threshold_override',
];
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,20 @@
* @since COmanage Registry v5.2.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

$fields = [
'source_mode',
'min_length',
'max_length',
'format_crypt_php',
'format_sha1_ldap',
'format_plaintext'
];

?>
<script type="text/javascript">

<script>
// JS specific to these fields

function updateGadgets(isPageLoad) {
// Hide or show gadgets according to current state
var source = document.getElementById('source-mode').value;
Expand All @@ -49,51 +59,14 @@
}
}

function jsLocalOnLoad() {
$(function() {
// run on first load
updateGadgets(true);
}
</script>

<?php
// This view does currently not support read-only, and add is not used
if($vv_action == 'edit') {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'source_mode',
'fieldOptions' => [
'onChange' => 'updateGadgets(false)'
]
]
]);

foreach(['min_length',
'max_length'
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field,
]
]);
}

print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'format_crypt_php',
'fieldOptions' => [
// When source is Self Select we want crypt to remain checked
// (though this will also be enforced in the backend)
'onChange' => 'updateGadgets(false)'
]
]
]);

foreach(['format_sha1_ldap',
'format_plaintext'
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field,
]
]);
}
}
// register onchange events
// note that underscores in field names above must be represented with hyphens here.
$('#source-mode, #format_crypt_php').change(function() {
updateGadgets();
});
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,20 @@
// We provide the current password status in a banner message since that's all the
// information we really want to display about a password.

print $this->element('notify/banner', ['info' => $vv_status->comment]);
// XXX https://todos.internet2.edu/browse/CFM-465 send type - this should be 'information' (not a warning)
$banners = [
$vv_status->comment
];

if(!$vv_status->locked) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'password',
]
]);
$fields = [];

print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'password2',
if(!$vv_status->locked) {
$fields = [
'password',
'password2' => [
'fieldOptions' => [
'type' => 'password'
]
]
]);
}
];
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,18 @@

// There are currently no directly configurable fields for this model.)
$suppress_submit = true;
?>

// Top Links
$topLinks[] = [
'icon' => 'transform',
'order' => 'Default',
'label' => __d('pipeline_toolkit', 'controller.LoginIdentifierTypes', [99]),
'link' => [
'plugin' => 'PipelineToolkit',
'controller' => 'LoginIdentifierTypes',
'action' => 'index',
'identifier_mapper_id' => $vv_obj->id
],
'class' => ''
];
?>
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// This view does not support read-only
if($vv_action == 'add' || $vv_action == 'edit') {
foreach (['type_id',
'login'
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field
]]);
}
}
$fields = [
'type_id',
'login'
];
Loading

0 comments on commit 7e8d4ed

Please sign in to comment.