Skip to content

Commit

Permalink
Backport the changes for #1036, #1034 and #1030 -2x (#1039)
Browse files Browse the repository at this point in the history
  • Loading branch information
shishir-intelli authored Feb 13, 2024
1 parent 374230e commit 88d208e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 19 deletions.
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 @@ -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()
]);
Expand Down Expand Up @@ -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'));

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
2 changes: 1 addition & 1 deletion modules/apigee_edge_teams/src/Job/TeamMemberSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(?string $filter) {
/**
* Executes the request itself.
*/
protected function executeRequest(){}
protected function executeRequest() {}

/**
* {@inheritdoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -184,7 +177,6 @@ public function testMultipleInvitations() {
]);

$this->assertSession()->pageTextContains($successMessage);
$inCache = TRUE;
}
}

Expand Down

0 comments on commit 88d208e

Please sign in to comment.