Skip to content

Commit 374230e

Browse files
Enhancements for adding filter with ChannelId on condition (#1001)
* Aligning 2x for issue 961 and pr 962 * Aligning 2x for issue 947 and pr 939 * solving whitespace error * Removing changes for issue 961 for pr 962 --------- Co-authored-by: Shishir <[email protected]>
1 parent c164633 commit 374230e

File tree

5 files changed

+51
-1
lines changed

5 files changed

+51
-1
lines changed

modules/apigee_edge_teams/apigee_edge_teams.install

+15
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,18 @@ function apigee_edge_teams_update_9002() {
218218
$team_settings['content']['callbackUrl'] = $new_team_settings['content']['callbackUrl'];
219219
$config_storage->write('core.entity_view_display.team_app.team_app.default', $team_settings);
220220
}
221+
222+
/**
223+
* Install Configs for TeamAlias Form for Teams Setting Page
224+
*/
225+
function apigee_edge_teams_update_9003() {
226+
// Update existing config.
227+
/** @var \Drupal\Core\Config\StorageInterface $config_storage */
228+
$config_storage = \Drupal::service('config.storage');
229+
$module_path = \Drupal::service('extension.list.module')->getPath('apigee_edge_teams');
230+
$source = new FileStorage("$module_path/config/install");
231+
$new_team_settings = $source->read('apigee_edge_teams.team_settings');
232+
$team_settings = $config_storage->read('apigee_edge_teams.team_settings');
233+
$team_settings['enablefilter'] = $new_team_settings['enablefilter'];
234+
$config_storage->write('apigee_edge_teams.team_settings', $team_settings);
235+
}

modules/apigee_edge_teams/config/install/apigee_edge_teams.team_settings.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
langcode: en
22
team_prefix: ''
33
channelid: ''
4+
enablefilter: ''
45
entity_label_singular: ''
56
entity_label_plural: ''
67
cache_expiration: 900

modules/apigee_edge_teams/config/schema/apigee_edge_teams.schema.yml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ apigee_edge_teams.team_settings:
88
channelid:
99
type: label
1010
label: 'ChannelId settings'
11+
enablefilter:
12+
type: label
13+
label: 'Filter by Channel ID'
1114
entity_label_singular:
1215
type: label
1316
label: 'How to refer to a Team on the UI (singular)'

modules/apigee_edge_teams/src/Entity/Controller/TeamController.php

+23
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Apigee\Edge\Api\Management\Controller\CompanyController as EdgeCompanyController;
2626
use Apigee\Edge\Api\Management\Controller\CompanyControllerInterface as EdgeCompanyControllerInterface;
2727
use Apigee\Edge\Entity\EntityInterface;
28+
use Apigee\Edge\Structure\PagerInterface;
2829
use Drupal\apigee_edge\Entity\Controller\Cache\AppCacheByOwnerFactoryInterface;
2930
use Drupal\apigee_edge\Entity\Controller\Cache\AppNameCacheByOwnerFactoryInterface;
3031
use Drupal\apigee_edge\Entity\Controller\Cache\EntityCacheInterface;
@@ -38,6 +39,7 @@
3839
use Drupal\apigee_edge\Entity\DeveloperCompaniesCacheInterface;
3940
use Drupal\apigee_edge\SDKConnectorInterface;
4041
use Drupal\apigee_edge_teams\CompanyMembershipObjectCacheInterface;
42+
use Drupal\apigee_edge_teams\Form\TeamAliasForm;
4143

4244
/**
4345
* Definition of the Team controller service.
@@ -233,4 +235,25 @@ public function delete(string $entity_id): EntityInterface {
233235
return $entity;
234236
}
235237

238+
/**
239+
* {@inheritdoc}
240+
*/
241+
public function getEntities(PagerInterface $pager = NULL, string $key_provider = 'id'): array {
242+
$queryparam = [];
243+
if ($this->orgController->isOrganizationApigeeX()) {
244+
// Getting the channelId & filter enable check from Config form.
245+
$channelconfig = \Drupal::config('apigee_edge_teams.team_settings');
246+
$channelid = $channelconfig->get('channelid');
247+
$channelfilter = $channelconfig->get('enablefilter');
248+
if ($channelfilter) {
249+
$channelid = $channelid ? $channelid : TeamAliasForm::originalChannelId();
250+
$queryparam = [
251+
'filter' => 'channelId=' . $channelid
252+
];
253+
}
254+
}
255+
$entities = $this->decorated()->getEntities($pager, $key_provider, $queryparam);
256+
return $entities;
257+
}
258+
236259
}

modules/apigee_edge_teams/src/Form/TeamAliasForm.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ public function buildForm(array $form, FormStateInterface $form_state) {
6868
'#default_value' => $config->get('channelid'),
6969
'#description' => $this->t('Leave empty to use the default "@channelid" as channel ID.', ['@channelid' => $this->originalChannelId()]),
7070
];
71+
72+
$form['channel_label']['enablefilter'] = [
73+
'#type' => 'checkbox',
74+
'#title' => $this->t('Filter by Channel ID'),
75+
'#default_value' => $config->get('enablefilter'),
76+
'#description' => $this->t('Enforce the filtering of AppGroups based on Channel ID specified in the field above.'),
77+
];
7178
}
7279
return parent::buildForm($form, $form_state);
7380
}
@@ -97,9 +104,10 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
97104
public function submitForm(array &$form, FormStateInterface $form_state) {
98105
$config = $this->config($this->getConfigNameWithLabels());
99106

100-
if ($config->get('team_prefix') !== $form_state->getValue('team_prefix') || $config->get('channelid') !== $form_state->getValue('channelid')) {
107+
if ($config->get('team_prefix') !== $form_state->getValue('team_prefix') || $config->get('channelid') !== $form_state->getValue('channelid') || $config->get('enablefilter') !== $form_state->getValue('enablefilter')) {
101108
$config->set('team_prefix', $form_state->getValue('team_prefix'))
102109
->set('channelid', $form_state->getValue('channelid'))
110+
->set('enablefilter', $form_state->getValue('enablefilter'))
103111
->save();
104112
}
105113

0 commit comments

Comments
 (0)