Skip to content

Commit

Permalink
Merge branch '3.x' into vpa24-acceptance-link-problem-with-mixed-case…
Browse files Browse the repository at this point in the history
…-email-addresss
  • Loading branch information
kedarkhaire committed Mar 6, 2024
2 parents 51a9b1b + 0f0e59a commit 5eb0f8c
Show file tree
Hide file tree
Showing 9 changed files with 755 additions and 22 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"require": {
"php": "~8.1.0 || ~8.2.0",
"ext-json": "*",
"apigee/apigee-client-php": "~3.0.4",
"apigee/apigee-client-php": "~3.0.5",
"drupal/core": "^10.1",
"drupal/entity": "^1.0",
"drupal/key": "^1.8",
Expand Down
2 changes: 1 addition & 1 deletion modules/apigee_edge_teams/apigee_edge_teams.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ services:

apigee_edge_teams.team_invitation_query_access_subscriber:
class: Drupal\apigee_edge_teams\EventSubscriber\TeamInvitationQueryAccessSubscriber
arguments: ['@entity_type.manager']
arguments: ['@apigee_edge.controller.organization', '@entity_type.manager']
tags:
- { name: event_subscriber }

Expand Down
14 changes: 7 additions & 7 deletions modules/apigee_edge_teams/src/Entity/Form/TeamForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,7 @@ public function save(array $form, FormStateInterface $form_state) {

if ($was_new) {
try {
if ($this->orgController->isOrganizationApigeeX()) {
// For ApigeeX adding the member as admin.
$this->teamMembershipManager->addMembers($team->id(), [
$this->currentUser->getEmail() => ['admin']
]);
}
else {
if (!$this->orgController->isOrganizationApigeeX()) {
$this->teamMembershipManager->addMembers($team->id(), [
$this->currentUser->getEmail()
]);
Expand Down Expand Up @@ -312,6 +306,12 @@ public function save(array $form, FormStateInterface $form_state) {
}

}
$options = [];
$query = $this->getRequest()->query;
if ($query->has('destination')) {
$options['query']['destination'] = $query->get('destination');
$query->remove('destination');
}
// Redirecting user to team view page to manage the team members and apps.
$form_state->setRedirectUrl($team->toUrl('canonical'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ protected function buildInfoRow(AppInterface $app, array &$rows) {
/** @var \Drupal\apigee_edge_teams\Entity\TeamInterface[] $teams */
$teams = $this->entityTypeManager->getStorage('team')->loadMultiple();
$css_id = $this->getCssIdForInfoRow($app);
$rows[$css_id]['data']['team']['data'] = $teams[$app->getCompanyName()]->access('view') ? $teams[$app->getCompanyName()]->toLink()->toRenderable() : $teams[$app->getCompanyName()]->label();
$team_name = $app->isApigeeX() ? $app->getAppGroup() : $app->getCompanyName();
$rows[$css_id]['data']['team']['data'] = $teams[$team_name]->access('view') ? $teams[$team_name]->toLink()->toRenderable() : $teams[$team_name]->label();
parent::buildInfoRow($app, $rows);
}

Expand Down
13 changes: 12 additions & 1 deletion modules/apigee_edge_teams/src/Entity/TeamApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@
#[\AllowDynamicProperties]
class TeamApp extends App implements TeamAppInterface {

/**
* True if organization is Apigee X.
*
* @var bool
*/
public static $apigeex = FALSE;

/**
* The decorated company app entity from the SDK.
*
Expand Down Expand Up @@ -156,7 +163,11 @@ public function getAppGroup(): ?string {
*/
public static function isApigeeX(): bool {
$orgController = \Drupal::service('apigee_edge.controller.organization');
return $orgController->isOrganizationApigeeX();
if ($orgController->isOrganizationApigeeX()) {
TeamApp::$apigeex = $orgController->isOrganizationApigeeX();
}

return TeamApp::$apigeex;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace Drupal\apigee_edge_teams\EventSubscriber;

use Drupal\apigee_edge\Entity\Controller\OrganizationControllerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\entity\QueryAccess\QueryAccessEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand All @@ -29,6 +30,13 @@
*/
class TeamInvitationQueryAccessSubscriber implements EventSubscriberInterface {

/**
* The organization controller service.
*
* @var \Drupal\apigee_edge\Entity\Controller\OrganizationControllerInterface
*/
private $orgController;

/**
* The entity type manager service.
*
Expand All @@ -39,10 +47,13 @@ class TeamInvitationQueryAccessSubscriber implements EventSubscriberInterface {
/**
* TeamInvitationQueryAccessSubscriber constructor.
*
* @param \Drupal\apigee_edge\Entity\Controller\OrganizationControllerInterface $org_controller
* The organization controller service.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
public function __construct(OrganizationControllerInterface $org_controller, EntityTypeManagerInterface $entity_type_manager) {
$this->orgController = $org_controller;
$this->entityTypeManager = $entity_type_manager;
}

Expand All @@ -62,6 +73,10 @@ public static function getSubscribedEvents() {
* The event.
*/
public function onQueryAccess(QueryAccessEvent $event) {
// AppGroup members information is stored in Database tables.
if ($this->orgController->isOrganizationApigeeX()) {
return;
}
// Add a condition to check for a valid team.
// We query team from storage instead of check for a null team field because
// the team might have been deleted on the remote server.
Expand Down
Loading

0 comments on commit 5eb0f8c

Please sign in to comment.