Skip to content

Commit

Permalink
Simplify $subnav declaration (CFM-291)
Browse files Browse the repository at this point in the history
  • Loading branch information
arlen committed Mar 12, 2026
1 parent d9c5de4 commit 80ca5d9
Show file tree
Hide file tree
Showing 34 changed files with 48 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ $fields = [
'external_identity_source_id'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['Apis', 'ApiConnector.ApiSourceEndpoints'],
'action' => [
'Apis' => ['edit'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ $fields = [
]
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['ExternalIdentitySources', 'ApiConnector.ApiSources', 'ExternalIdentitySources@action.search'],
'action' => [
'ExternalIdentitySources' => ['edit', 'view', 'search'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ $fields = [
'filename'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['ProvisioningTargets', 'FileConnector.FileProvisioners'],
'action' => [
'ProvisioningTargets' => ['edit'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ $fields = [
'threshold_override',
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['ExternalIdentitySources', 'FileConnector.FileSources', 'ExternalIdentitySources@action.search'],
'action' => [
'ExternalIdentitySources' => ['edit', 'view', 'search'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ $fields = [
'keytab_path'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['Servers', 'KerberosConnector.KerberosServers'],
'action' => [
'Servers' => ['edit'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ $fields = [
'format_plaintext'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['Authenticators', 'PasswordAuthenticator.PasswordAuthenticators'],
'action' => [
'Authenticators' => ['edit'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ $fields = [
]
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['ProvisioningTargets', 'SqlConnector.SqlProvisioners'],
'action' => [
'ProvisioningTargets' => ['edit'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ $fields = array_merge($fields, [
'threshold_override'
]);

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['ExternalIdentitySources', 'SqlConnector.SqlSources', 'ExternalIdentitySources@action.search'],
'action' => [
'ExternalIdentitySources' => ['edit', 'view', 'search'],
Expand Down
3 changes: 1 addition & 2 deletions app/plugins/CoreApi/templates/MatchCallbacks/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ $fields = [
'server_id'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['Apis', 'CoreApi.MatchCallbacks'],
'action' => [
'Apis' => ['edit'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ $fields = [
'enable_transliteration'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['IdentifierAssignments', 'CoreAssigner.FormatAssigners'],
'action' => [
'IdentifierAssignments' => ['edit'],
Expand Down
3 changes: 1 addition & 2 deletions app/plugins/CoreAssigner/templates/SqlAssigners/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ $fields = [
'type_id'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['IdentifierAssignments', 'CoreAssigner.SqlAssigners'],
'action' => [
'IdentifierAssignments' => ['edit'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ $fields = [
'redirect_on_denial'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['EnrollmentFlowSteps', 'CoreEnroller.ApprovalCollectors'],
'action' => [
'EnrollmentFlowSteps' => ['edit', 'view'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ $topLinks[] = [
'class' => ''
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['EnrollmentFlowSteps', 'CoreEnroller.AttributeCollectors', 'EnrollmentFlowSteps.Hierarchy'],
'action' => [
'EnrollmentFlowSteps' => ['edit', 'view'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ $fields = [
'cou_id'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['EnrollmentFlowSteps', 'CoreEnroller.BasicAttributeCollectors'],
'action' => [
'EnrollmentFlowSteps' => ['edit', 'view'],
Expand Down
3 changes: 1 addition & 2 deletions app/plugins/CoreEnroller/templates/EmailVerifiers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ $fields = [
]
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['EnrollmentFlowSteps', 'CoreEnroller.EmailVerifiers'],
'action' => [
'EnrollmentFlowSteps' => ['edit', 'view'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ $indexColumns = [
]
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['EnrollmentFlowSteps', 'CoreEnroller.AttributeCollectors', 'EnrollmentFlowSteps.Hierarchy'],
'action' => [
'EnrollmentFlowSteps' => ['edit', 'view'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ if (
$fields[] = 'hidden';
}

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['EnrollmentFlowSteps', 'CoreEnroller.AttributeCollectors', 'EnrollmentFlowSteps.Hierarchy'],
'action' => [
'EnrollmentFlowSteps' => ['edit', 'view'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ $fields = [
'type_id'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['EnrollmentFlowSteps', 'CoreEnroller.IdentifierCollectors'],
'action' => [
'EnrollmentFlowSteps' => ['edit', 'view'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ $fields = [
'welcome_message'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['EnrollmentFlowSteps', 'CoreEnroller.InvitationAccepters'],
'action' => [
'EnrollmentFlowSteps' => ['edit', 'view'],
Expand Down
3 changes: 1 addition & 2 deletions app/plugins/CoreServer/templates/HttpServers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ $fields = [
'skip_ssl_verification'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['Servers', 'CoreServer.HttpServers'],
'action' => [
'Servers' => ['edit'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ $indexColumns = [
]
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['Servers', 'CoreServer.MatchServers', 'CoreServer.MatchServerAttributes'],
'action' => [
'Servers' => ['edit'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ foreach ([

$fields[] = 'required';

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['Servers', 'CoreServer.MatchServers', 'CoreServer.MatchServerAttributes'],
'action' => [
'Servers' => ['edit'],
Expand Down
3 changes: 1 addition & 2 deletions app/plugins/CoreServer/templates/MatchServers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ if(!empty($vv_obj->url)) {
];
}

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['Servers', 'CoreServer.MatchServers', 'CoreServer.MatchServerAttributes'],
'action' => [
'Servers' => ['edit'],
Expand Down
3 changes: 1 addition & 2 deletions app/plugins/CoreServer/templates/Oauth2Servers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ $fields['access_token'] = [
'labelIsTextOnly' => true
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['Servers', 'CoreServer.Oauth2Servers'],
'action' => [
'Servers' => ['edit'],
Expand Down
3 changes: 1 addition & 2 deletions app/plugins/CoreServer/templates/SmtpServers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ $fields = [
'override_to'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['Servers', 'CoreServer.SmtpServers'],
'action' => [
'Servers' => ['edit'],
Expand Down
3 changes: 1 addition & 2 deletions app/plugins/CoreServer/templates/SqlServers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ $fields = [
'password'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['Servers', 'CoreServer.SqlServers'],
'action' => [
'Servers' => ['edit'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ $fields = [
]
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['EnrollmentFlowSteps', 'EnvSource.EnvSourceCollectors'],
'action' => [
'EnrollmentFlowSteps' => ['edit', 'view'],
Expand Down
3 changes: 1 addition & 2 deletions app/plugins/EnvSource/templates/EnvSources/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ foreach($defaultNames as $field => $envName) {
];
}

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['ExternalIdentitySources', 'EnvSource.EnvSources', 'ExternalIdentitySources@action.search'],
'action' => [
'ExternalIdentitySources' => ['edit', 'view', 'search'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ $fields = [
]
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['EnrollmentFlowSteps', 'OrcidSource.OrcidSourceCollectors'],
'action' => [
'EnrollmentFlowSteps' => ['edit', 'view'],
Expand Down
3 changes: 1 addition & 2 deletions app/plugins/OrcidSource/templates/OrcidSources/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ $fields = [
'name_type_id'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['ExternalIdentitySources', 'OrcidSource.OrcidSources', 'ExternalIdentitySources@action.search'],
'action' => [
'ExternalIdentitySources' => ['edit', 'view', 'search'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ declare(strict_types = 1);

$this->Field->disableFormEditMode();

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['Authenticators', 'SshKeyAuthenticator.SshKeyAuthenticators'],
'action' => [
'Authenticators' => ['edit'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ $fields = [
't_and_c_mode'
];

$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['EnrollmentFlowSteps', 'TermsAgreer.AgreementCollectors'],
'action' => [
'EnrollmentFlowSteps' => ['edit', 'view'],
Expand Down
3 changes: 1 addition & 2 deletions app/templates/Servers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ $fields = array_merge($fields, include(ROOT . DS . 'templates' . DS . 'Standard/

// Match Servers have special subnavigation treatment (they have an extra tab for Match Server Attributes).
if($vv_obj['plugin'] == 'CoreServer.MatchServers') {
$subnav = 'local';
$subnavLocal = [
$subnav = [
'tabs' => ['Servers', 'Servers.Plugin', 'CoreServer.MatchServerAttributes'],
'action' => [
'Servers' => ['edit'],
Expand Down
29 changes: 15 additions & 14 deletions app/templates/Standard/subnavigation.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ $modelsName = $this->getName();
$tabsConfiguration = [];

/**
* Subnavigation is established by setting the $subnav array in fields.inc/columns.inc to a string that either
* matches a named set from the $subnavConfig[] array below (e.g. $subnav = 'people')
* or by setting $subnav = 'local' and then defining $subnavLocal = [the tab definition array].
* For plugins, the tab definition will always be local in the plugin fields.inc config.
*
* Subnavigation is established by setting a variable called $subnav in fields.inc/columns.inc
* either to a string that matches a named set from the $subnavConfig[] array below
* or by setting $subnav = [a local tab definition array].
*
* For core views, the tab definition will typically reference a named set below,
* e.g. $subnav = 'people', or $subnav = 'standard'.
*
* For plugins, the tab definition will typically be local in the plugin fields.inc config.
* For example (in app/availableplugins/PasswordAuthenticator/templates/PasswordAuthenticators/fields.inc):
* $subnav = 'local';
* $subnavLocal = [
* $subnav = [
* 'tabs' => ['Authenticators', 'PasswordAuthenticator.PasswordAuthenticators'],
* 'action' => [
* 'Authenticators' => ['edit'],
Expand All @@ -53,11 +55,11 @@ $tabsConfiguration = [];
*/

// Subnavigation configuration definitions for common subnavigation sets.
// These are here to avoid duplicate configuration.
// These are here to avoid duplicate configurations when handling core views.
$subnavConfig = [
// STANDARD: for any object that has a simple two-tab set of "PROPERTIES" and "PLUGIN CONFIGURATION".
// Use $subnav = 'standard' for the properties tab; each plugin tab definition will live in the
// plugin fields.inc config as $subnav = 'local' and $subnavLocal = [the tab definition array]
// plugin fields.inc config as $subnav = [the tab definition array]
// as described above.
'standard' => [
'tabs' => [$modelsName, $modelsName . '.Plugin'],
Expand Down Expand Up @@ -153,11 +155,10 @@ $subnavConfig = [
];

// Do not render subnavigation if $subnav is empty or if we have no configuration array.
if(!empty($subnav) && (!empty($subnavConfig[$subnav]) || !empty($subnavLocal))) {
if(!empty($subnavLocal)) {
// We are rendering tabs for a plugin configuration view.
// The tabs configuraton is defined as $subnavLocal in the plugin's fields.inc file.
$tabsConfiguration = $subnavLocal;
if(!empty($subnav) && (is_array($subnav) || (is_string($subnav) && !empty($subnavConfig[$subnav])))) {
if(is_array($subnav)) {
// We are rendering a locally configured tabs configuration set in fields.inc or columns.inc.
$tabsConfiguration = $subnav;
} else {
// We are rendering a standard set of tabs as defined in $subnavConfig above.
$tabsConfiguration = $subnavConfig[$subnav];
Expand Down

0 comments on commit 80ca5d9

Please sign in to comment.