Skip to content

Provide Person-centric Group management; includes subnavigation refactoring (CFM-291) #367

Merged
merged 3 commits into from
Mar 13, 2026
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -48,6 +48,14 @@ class ApiSourceEndpointsController extends StandardPluginController {
*/

public function beforeRender(\Cake\Event\EventInterface $event) {
$link = $this->getPrimaryLink(true);

if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->ApiSourceEndpoints->Apis->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->ApiSourceEndpoints->Apis->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->ApiSourceEndpoints->Apis->getPrimaryKey());
}

$vv_obj = $this->viewBuilder()->getVar('vv_obj');

if(!empty($vv_obj->external_identity_source->api_source->id)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

namespace ApiConnector\Controller;

use Cake\Event\EventInterface;
use Cake\Routing\Router;
use App\Controller\StandardPluginController;

Expand All @@ -38,4 +39,25 @@ class ApiSourcesController extends StandardPluginController {
'ApiSources.id' => 'asc'
]
];

/**
* Callback run prior to the request render.
*
* @param EventInterface $event Cake Event
*
* @return Response|void
* @since COmanage Registry v5.0.0
*/

public function beforeRender(EventInterface $event) {
$link = $this->getPrimaryLink(true);

if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->ApiSources->ExternalIdentitySources->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->ApiSources->ExternalIdentitySources->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->ApiSources->ExternalIdentitySources->getPrimaryKey());
}

return parent::beforeRender($event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ if(!empty($vv_push_endpoint)) {
$fields = [
'external_identity_source_id'
];

$subnav = [
'tabs' => ['Apis', 'ApiConnector.ApiSourceEndpoints'],
'action' => [
'Apis' => ['edit'],
'ApiConnector.ApiSourceEndpoints' => ['edit']
]
];
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,12 @@ $fields = [
'subtitle' => __d('api_connector', 'field.ApiSources.push_mode')
]
];

$subnav = [
'tabs' => ['ExternalIdentitySources', 'ApiConnector.ApiSources', 'ExternalIdentitySources@action.search'],
'action' => [
'ExternalIdentitySources' => ['edit', 'view', 'search'],
'ApiConnector.ApiSources' => ['edit'],
'ExternalIdentitySources@action.search' => [],
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,33 @@
namespace FileConnector\Controller;

use App\Controller\StandardPluginController;
use Cake\Event\EventInterface;

class FileProvisionersController extends StandardPluginController {
protected array $paginate = [
'order' => [
'FileProvisioners.id' => 'asc'
]
];

/**
* Callback run prior to the request render.
*
* @param EventInterface $event Cake Event
*
* @return Response|void
* @since COmanage Registry v5.0.0
*/

public function beforeRender(EventInterface $event) {
$link = $this->getPrimaryLink(true);

if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->FileProvisioners->ProvisioningTargets->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->FileProvisioners->ProvisioningTargets->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->FileProvisioners->ProvisioningTargets->getPrimaryKey());
}

return parent::beforeRender($event);
}
Comment on lines +51 to +61
Copy link
Contributor

Choose a reason for hiding this comment

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

We seem to be adding a bunch of copy/paste boilerplate to plugins for logic that should instead be dynamically calculated in a parent controller (ie: StandardPluginController) or possibly a Trait. It looks like we're trying to render the breadcrumbs like

ProvisioningTargets > FileProvisioners

but for the most part we can determine our parent object via getPrimaryLink and then automatically inflect that and inject the appropriate breadcrumb without needing to hardcode this in every plugin controller. (There may be a small number of exceptions that need to be hand crafted, but those should be the exception, not the rule.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, there actually already seems to be similar logic in StandardPluginController::beforeRender (and StandardEnrollerController), so why are we not using/updating that?

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class FileSourcesTable extends Table {
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;
use \App\Lib\Traits\TabTrait;

// Cache of the field configuration
protected $fieldCfg = null;
Expand Down Expand Up @@ -89,23 +88,6 @@ public function initialize(array $config): void {
]
]);

// All the tabs share the same configuration in the ModelTable file
$this->setTabsConfig(
[
// Ordered list of Tabs
'tabs' => ['ExternalIdentitySources', 'FileConnector.FileSources', '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'],
'FileConnector.FileSources' => ['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 @@ -27,4 +27,12 @@

$fields = [
'filename'
];
];

$subnav = [
'tabs' => ['ProvisioningTargets', 'FileConnector.FileProvisioners'],
'action' => [
'ProvisioningTargets' => ['edit'],
'FileConnector.FileProvisioners' => ['edit']
]
];
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,12 @@ $fields = [
'threshold_check',
'threshold_override',
];

$subnav = [
'tabs' => ['ExternalIdentitySources', 'FileConnector.FileSources', 'ExternalIdentitySources@action.search'],
'action' => [
'ExternalIdentitySources' => ['edit', 'view', 'search'],
'FileConnector.FileSources' => ['edit'],
'ExternalIdentitySources@action.search' => [],
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,33 @@
namespace KerberosConnector\Controller;

use App\Controller\StandardPluginController;
use Cake\Event\EventInterface;

class KerberosServersController extends StandardPluginController {
protected array $paginate = [
'order' => [
'KerberosServers.hostname' => 'asc'
]
];

/**
* Callback run prior to the request render.
*
* @param EventInterface $event Cake Event
*
* @return Response|void
* @since COmanage Registry v5.0.0
*/

public function beforeRender(EventInterface $event) {
$link = $this->getPrimaryLink(true);

if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->KerberosServers->Servers->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->KerberosServers->Servers->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->KerberosServers->Servers->getPrimaryKey());
}

return parent::beforeRender($event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ $fields = [
'keytab_path'
];

$subnav = [
'tabs' => ['Servers', 'KerberosConnector.KerberosServers'],
'action' => [
'Servers' => ['edit'],
'KerberosConnector.KerberosServers' => ['edit']
]
];
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,33 @@
namespace PasswordAuthenticator\Controller;

use App\Controller\StandardPluginController;
use Cake\Event\EventInterface;

class PasswordAuthenticatorsController extends StandardPluginController {
protected array $paginate = [
'order' => [
'PasswordAuthenticators.id' => 'asc'
]
];

/**
* Callback run prior to the request render.
*
* @param EventInterface $event Cake Event
*
* @return Response|void
* @since COmanage Registry v5.0.0
*/

public function beforeRender(EventInterface $event) {
$link = $this->getPrimaryLink(true);

if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->PasswordAuthenticators->Authenticators->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->PasswordAuthenticators->Authenticators->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->PasswordAuthenticators->Authenticators->getPrimaryKey());
}

return parent::beforeRender($event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ $fields = [
'format_plaintext'
];

$subnav = [
'tabs' => ['Authenticators', 'PasswordAuthenticator.PasswordAuthenticators'],
'action' => [
'Authenticators' => ['edit'],
'PasswordAuthenticator.PasswordAuthenticators' => ['edit']
]
]

?>

<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
namespace SqlConnector\Controller;

use App\Controller\StandardPluginController;
use Cake\Event\EventInterface;

class SqlProvisionersController extends StandardPluginController {
protected array $paginate = [
Expand All @@ -38,6 +39,27 @@ class SqlProvisionersController extends StandardPluginController {
]
];

/**
* Callback run prior to the request render.
*
* @param EventInterface $event Cake Event
*
* @return Response|void
* @since COmanage Registry v5.0.0
*/

public function beforeRender(EventInterface $event) {
$link = $this->getPrimaryLink(true);

if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->SqlProvisioners->ProvisioningTargets->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->SqlProvisioners->ProvisioningTargets->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->SqlProvisioners->ProvisioningTargets->getPrimaryKey());
}

return parent::beforeRender($event);
}

/**
* Reapply the target database schema.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class SqlSourcesTable extends Table {
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\QueryModificationTrait;
use \App\Lib\Traits\TabTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;

Expand Down Expand Up @@ -157,23 +156,6 @@ public function initialize(array $config): void {
]
]);

// All the tabs share the same configuration in the ModelTable file
$this->setTabsConfig(
[
// Ordered list of Tabs
'tabs' => ['ExternalIdentitySources', 'SqlConnector.SqlSources', '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'],
'SqlConnector.SqlSources' => ['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 @@ -32,6 +32,14 @@ $fields = [
]
];

$subnav = [
'tabs' => ['ProvisioningTargets', 'SqlConnector.SqlProvisioners'],
'action' => [
'ProvisioningTargets' => ['edit'],
'SqlConnector.SqlProvisioners' => ['edit']
]
];

// Top Links
$topLinks = [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ $fields = array_merge($fields, [
'threshold_override'
]);

$subnav = [
'tabs' => ['ExternalIdentitySources', 'SqlConnector.SqlSources', 'ExternalIdentitySources@action.search'],
'action' => [
'ExternalIdentitySources' => ['edit', 'view', 'search'],
'SqlConnector.SqlSources' => ['edit'],
'ExternalIdentitySources@action.search' => [],
],
];

?>

<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ class MatchCallbacksController extends StandardPluginController {
*/

public function beforeRender(EventInterface $event) {
// Generate the callback URL
$link = $this->getPrimaryLink(true);

if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->MatchCallbacks->Apis->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->MatchCallbacks->Apis->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->MatchCallbacks->Apis->getPrimaryKey());
}

// Generate the callback URL
$this->set('vv_api_endpoint', \Cake\Routing\Router::url('/', true) . 'api/match/' . $this->getCOID() . '/v1/resolution');

return parent::beforeRender($event);
Expand Down
Loading