Skip to content

Commit

Permalink
Fix login identifier breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Sep 24, 2025
1 parent eba8522 commit 029f1c3
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function buildRelatedAttributes(
* @return string Display field
*/
public function generateDisplayField(\PipelineToolkit\Model\Entity\IdentifierMapper $entity): string {
return $entity->flange->description;
return $entity->name ?? $entity->description ?? $entity->flange->description;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ public function buildRules(RulesChecker $rules): RulesChecker {
return $rules;
}

/**
* Table specific logic to generate a display field.
*
* @since COmanage Registry v5.2.0
* @param \PipelineToolkit\Model\Entity\LoginIdentifierType $entity Entity to generate display field for
* @return string Display field
*/
public function generateDisplayField(\PipelineToolkit\Model\Entity\LoginIdentifierType $entity): string {
return __d('pipeline_toolkit', 'controller.LoginIdentifierTypes', [1]);
}

/**
* Application Rule to determine if a specific Type is already configured.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ protected function getChanges(
* @return string Display field
*/
public function generateDisplayField(\SqlConnector\Model\Entity\SqlSource $entity): string {
return __d('sql_connector', 'display.SqlSource', [$entity->external_identity_source->description]);
$value = $entity->name ?? $entity->description ?? $entity->external_identity_source->description;
return __d('sql_connector', 'display.SqlSource', [$value]);
}


Expand Down
3 changes: 2 additions & 1 deletion app/plugins/EnvSource/src/Model/Table/EnvSourcesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ public function initialize(array $config): void {
* @return string Display field
*/
public function generateDisplayField(\EnvSource\Model\Entity\EnvSource $entity): string {
return __d('env_source', 'display.EnvSource', [$entity->external_identity_source->description]);
$value = $entity->name ?? $entity->description ?? $entity->external_identity_source->description;
return __d('env_source', 'display.EnvSource', [$value]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function initialize(array $config): void {
* @return string Display field
*/
public function generateDisplayField(\SshKeyAuthenticator\Model\Entity\SshKeyAuthenticator $entity): string {
return $entity->authenticator->description;
return $entity->name ?? $entity->description ?? $entity->authenticator->description;
}

/**
Expand Down
3 changes: 0 additions & 3 deletions app/src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,8 @@ public function isActiveRoute(array $target): bool
unset($params['query']);
}

// Default request method and extension are not required for match()
// Build URL first to ensure consistency (optional)
Router::url($target, false);

// Router::match expects a request-style array; provide defaults
$params += [
'plugin' => $params['plugin'] ?? null,
'prefix' => $params['prefix'] ?? null,
Expand Down
45 changes: 42 additions & 3 deletions app/src/Controller/StandardPluginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ public function beforeRender(\Cake\Event\EventInterface $event) {
// For the Pipeline Toolkit
if($this->getPlugin() == 'PipelineToolkit') {
$identifierMapperTable = $this->fetchTable(IdentifierMappersTable::class);
$identifierMapperEntity = null;

// Edit/View
if ($this->viewBuilder()->getVar('vv_obj') && $request->getParam('action') != 'add') {
if ($this->viewBuilder()->getVar('vv_obj') && $request->getParam('action') !== 'add') {
$obj = $this->viewBuilder()->getVar('vv_obj');
// Load IdentifierMapper if identifier_mapper_id is set
if (empty($obj->identifier_mapper_id) && $obj->getSource() !== 'PipelineToolkit.IdentifierMappers') {
Expand All @@ -159,9 +161,46 @@ public function beforeRender(\Cake\Event\EventInterface $event) {
throw new \RuntimeException('Identifier Mapper Record not found');
}
$this->set('vv_identifier_mapper', $identifierMapperEntity);
$breadcrumbs = $this->buildPipelineBreadcrumbs($identifierMapperEntity);

// Always add pipeline/flange breadcrumbs from the mapper entity
$pipelineCrumbs = $this->buildPipelineBreadcrumbs($identifierMapperEntity);

// Conditionally add the two extra crumbs ONLY when the current entity has identifier_mapper_id
$extraCrumbs = [];
$vvObj = $this->viewBuilder()->getVar('vv_obj');
if ($request->getParam('action') === 'edit'
&& $vvObj instanceof \Cake\Datasource\EntityInterface
&& (int)($vvObj->get('identifier_mapper_id') ?? 0) > 0) {

$identifierMapperId = (int)$vvObj->get('identifier_mapper_id');

// Identifier Mapper edit
$extraCrumbs['identifier_mappers:' . $identifierMapperId] = [
'label' => __('Identifier Mappers'),
'target' => [
'plugin' => 'PipelineToolkit',
'controller' => 'IdentifierMappers',
'action' => 'edit',
$identifierMapperId,
],
];

// Current entity index filtered by identifier_mapper_id
$controller = (string)$request->getParam('controller');
$plugin = (string)($request->getParam('plugin') ?? '');
$extraCrumbs[strtolower($controller) . ':index:' . $identifierMapperId] = [
'label' => \App\Lib\Util\StringUtilities::localizeController($controller, $plugin ?: null, true),
'target' => [
'plugin' => $plugin ?: null,
'controller' => $controller,
'action' => 'index',
'?' => ['identifier_mapper_id' => $identifierMapperId],
],
];
}

$vv_bc_parents = (array)$this->viewBuilder()->getVar('vv_bc_parents');
$this->set('vv_bc_parents', [...$breadcrumbs, ...$vv_bc_parents]);
$this->set('vv_bc_parents', [...$pipelineCrumbs, ...$extraCrumbs, ...$vv_bc_parents]);
}

return parent::beforeRender($event);
Expand Down
2 changes: 1 addition & 1 deletion app/src/Lib/Traits/BreadcrumbsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,4 @@ protected function buildPipelineBreadcrumbs(EntityInterface $entity): array

return $parents;
}
}
}
2 changes: 1 addition & 1 deletion app/src/Model/Table/PetitionsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function initialize(array $config): void {
'type' => 'enum',
'class' => 'PetitionStatusEnum'
],
'couIds' => [
'cous' => [
'type' => 'select',
'model' => 'Cous'
]
Expand Down

0 comments on commit 029f1c3

Please sign in to comment.