Skip to content

Refactor fields.inc to be configuration only (CFM-218) #342

Merged
merged 14 commits into from
Nov 22, 2025
Merged
Show file tree
Hide file tree
Changes from 12 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
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 )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I attempted to add the subnavigation for API Sources config similar to File Sources, Sql Sources (etc). When this block is included it throws an error similar to what we see in https://todos.internet2.edu/browse/CFM-475

Copy link
Contributor

Choose a reason for hiding this comment

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

What's the plan to address this? ie: CFM-475 is marked resolved, so either we should have a plan to address the underlying issue or we shouldn't commit a bunch of commented out broken code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will pull this code out for now. We'll need to review all such places where subnavigation should be used - where configuration (for example) should be on a tab next to its entity.

// $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,16 @@
* @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' => 'external_identity_source_id',
if(!empty($vv_push_endpoint)) {
$alerts = [
[
'type' => 'information',
'message' => __d('api_connector', 'information.endpoint.push', [$vv_push_endpoint])
]
]);
];
}

$fields = [
'external_identity_source_id'
];

This file was deleted.

19 changes: 12 additions & 7 deletions app/availableplugins/ApiConnector/templates/ApiSources/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@
* @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') {
print '<li class="info-title"><h3>' . __d('api_connector', 'field.ApiSources.push_mode') . '</h3></li>';
$alerts = [
[
'type' => 'information',
'message' => __d('information', 'plugin.config.none')
]
];

print $this->element('notify/banner', [
'info' => __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
@@ -1,48 +1,63 @@
<?php
/**
* COmanage Registry Passwords Fields
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.2.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/
/**
* COmanage Registry Passwords Fields
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.2.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// We provide the current password status in a banner message since that's all the
// information we really want to display about a password.
$alerts = [
[
'type' => 'information',
'message' => $vv_status->comment
]
];

print $this->element('notify/banner', ['info' => $vv_status->comment]);
$fields = [];

if(!$vv_status->locked) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'password',
$fields = [
'password',
'password2' => [
'type' => 'password'
]
]);
];
// Inject the parent keys
$hidden = [
'password_authenticator_id' => $vv_authenticator->password_authenticator->id,
'person_id' => $vv_status->person_id
];
} else {
$suppress_submit = true;
}

print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'password2',
'fieldOptions' => [
'type' => 'password'
]
]
]);
}
$topLinks[] = [
'icon' => 'history',
'order' => 'Default',
'label' => __d('operation', 'reset'),
'link' => [
'controller' => 'authenticators',
'action' => 'reset',
]
];

This file was deleted.

Loading