diff --git a/modules/apigee_edge_teams/apigee_edge_teams.services.yml b/modules/apigee_edge_teams/apigee_edge_teams.services.yml index 6e772912..638c8540 100644 --- a/modules/apigee_edge_teams/apigee_edge_teams.services.yml +++ b/modules/apigee_edge_teams/apigee_edge_teams.services.yml @@ -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 } diff --git a/modules/apigee_edge_teams/src/Entity/Form/TeamForm.php b/modules/apigee_edge_teams/src/Entity/Form/TeamForm.php index d03ce107..5c6ac1ad 100644 --- a/modules/apigee_edge_teams/src/Entity/Form/TeamForm.php +++ b/modules/apigee_edge_teams/src/Entity/Form/TeamForm.php @@ -263,13 +263,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() ]); @@ -308,6 +302,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')); diff --git a/modules/apigee_edge_teams/src/EventSubscriber/TeamInvitationQueryAccessSubscriber.php b/modules/apigee_edge_teams/src/EventSubscriber/TeamInvitationQueryAccessSubscriber.php index 2739ee05..c66f168c 100644 --- a/modules/apigee_edge_teams/src/EventSubscriber/TeamInvitationQueryAccessSubscriber.php +++ b/modules/apigee_edge_teams/src/EventSubscriber/TeamInvitationQueryAccessSubscriber.php @@ -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; @@ -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. * @@ -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; } @@ -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. diff --git a/modules/apigee_edge_teams/src/Job/TeamMemberSync.php b/modules/apigee_edge_teams/src/Job/TeamMemberSync.php index 24bab27f..7f35d62a 100644 --- a/modules/apigee_edge_teams/src/Job/TeamMemberSync.php +++ b/modules/apigee_edge_teams/src/Job/TeamMemberSync.php @@ -50,7 +50,7 @@ public function __construct(?string $filter) { /** * Executes the request itself. */ - protected function executeRequest(){} + protected function executeRequest() {} /** * {@inheritdoc} diff --git a/modules/apigee_edge_teams/tests/src/Functional/ApigeeX/TeamInvitationsTest.php b/modules/apigee_edge_teams/tests/src/Functional/ApigeeX/TeamInvitationsTest.php index 42f3d05d..aa7c0a55 100644 --- a/modules/apigee_edge_teams/tests/src/Functional/ApigeeX/TeamInvitationsTest.php +++ b/modules/apigee_edge_teams/tests/src/Functional/ApigeeX/TeamInvitationsTest.php @@ -159,20 +159,13 @@ public function testMultipleInvitations() { $this->teamB->decorated(), ]; - $inCache = FALSE; foreach ($teams as $team) { - if (!$inCache) { - $this->queueAppGroupResponse($team->decorated()); - } + $this->queueAppGroupResponse($team->decorated()); $this->drupalGet(Url::fromRoute('entity.team.add_members', [ 'team' => $team->id(), ])); $this->assertSession()->pageTextContains('Invite members'); - - $this->queueAppGroupsResponse($appgroups); - $this->queueAppGroupsResponse($appgroups); - $this->queueDevsInCompanyResponse([]); $this->submitForm([ 'developers' => $this->accountUser->getEmail(), ], 'Invite members'); @@ -184,7 +177,6 @@ public function testMultipleInvitations() { ]); $this->assertSession()->pageTextContains($successMessage); - $inCache = TRUE; } }