Skip to content

Commit

Permalink
[#421] Show member role on team page (#435)
Browse files Browse the repository at this point in the history
* [#421] Show member role on team page

* [#421] Load default role from storage

* [#421] Set defaultRoles array
  • Loading branch information
shadcn authored Jul 7, 2020
1 parent 72160f0 commit 8866595
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions modules/apigee_edge_teams/src/Controller/TeamMembersList.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class TeamMembersList extends ControllerBase {
*/
private $teamMembershipManager;

/**
* Default member roles.
*
* @var array
*/
protected $defaultRoles = [];

/**
* TeamMembersList constructor.
*
Expand All @@ -54,6 +61,10 @@ class TeamMembersList extends ControllerBase {
public function __construct(TeamMembershipManagerInterface $team_membership_manager, EntityTypeManagerInterface $entity_type_manager) {
$this->teamMembershipManager = $team_membership_manager;
$this->entityTypeManager = $entity_type_manager;

if ($role = $this->entityTypeManager()->getStorage('team_role')->load(TeamRoleInterface::TEAM_MEMBER_ROLE)) {
$this->defaultRoles = [$role->id() => $role->label()];
}
}

/**
Expand Down Expand Up @@ -164,7 +175,7 @@ protected function buildRow(string $member, array $users_by_mail, array $team_me
$roles = array_reduce($team_member_roles_by_mail[$member]->getTeamRoles(), function ($carry, TeamRoleInterface $role) {
$carry[$role->id()] = $role->label();
return $carry;
}, []);
}, $this->defaultRoles);
$row['data']['roles']['data'] = [
'#theme' => 'item_list',
'#items' => $roles,
Expand All @@ -175,7 +186,10 @@ protected function buildRow(string $member, array $users_by_mail, array $team_me
];
}
else {
$row['data']['roles']['data'] = NULL;
$row['data']['roles']['data'] = [
'#theme' => 'item_list',
'#items' => $this->defaultRoles,
];
}

$row['data']['operations']['data'] = $this->buildOperations($member, $team);
Expand Down

0 comments on commit 8866595

Please sign in to comment.