Skip to content

Commit

Permalink
[ManagedUser] add delegated indicator to role (#11398)
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano authored Jan 30, 2025
1 parent beb7290 commit 556a552
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
40 changes: 20 additions & 20 deletions features/api/adherents.feature
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Feature:
"tags": [
{
"type": "role",
"label": "Président assemblée départementale",
"label": "Président assemblée départementale délégué",
"tooltip": "Responsable communication"
}
],
Expand Down Expand Up @@ -197,47 +197,47 @@ Feature:
},
{
"type": "role",
"label": "Délégué de circonscription",
"label": "Délégué de circonscription délégué",
"tooltip": "Collaborateur parlementaire"
},
{
"type": "role",
"label": "Sénateur",
"label": "Sénateur délégué",
"tooltip": "Collaborateur parlementaire"
},
{
"type": "role",
"label": "Délégué de circonscription",
"label": "Délégué de circonscription délégué",
"tooltip": "Collaborateur parlementaire"
},
{
"type": "role",
"label": "Candidat",
"label": "Candidat délégué",
"tooltip": "Candidat délégué"
},
{
"type": "role",
"label": "Candidat Sénatoriales 2020",
"label": "Candidat Sénatoriales 2020 délégué",
"tooltip": "Candidat Sénateur délégué"
},
{
"type": "role",
"label": "Président assemblée départementale",
"label": "Président assemblée départementale délégué",
"tooltip": "Responsable élus délégué #1"
},
{
"type": "role",
"label": "Président assemblée départementale",
"label": "Président assemblée départementale délégué",
"tooltip": "Responsable communication"
},
{
"type": "role",
"label": "Responsable local",
"label": "Responsable local délégué",
"tooltip": "Responsable logistique"
},
{
"type": "role",
"label": "Candidat aux législatives",
"label": "Candidat aux législatives délégué",
"tooltip": "Responsable communication"
},
{
Expand Down Expand Up @@ -374,47 +374,47 @@ Feature:
},
{
"type": "role",
"label": "Délégué de circonscription",
"label": "Délégué de circonscription délégué",
"tooltip": "Collaborateur parlementaire"
},
{
"type": "role",
"label": "Sénateur",
"label": "Sénateur délégué",
"tooltip": "Collaborateur parlementaire"
},
{
"type": "role",
"label": "Délégué de circonscription",
"label": "Délégué de circonscription délégué",
"tooltip": "Collaborateur parlementaire"
},
{
"type": "role",
"label": "Candidat",
"label": "Candidat délégué",
"tooltip": "Candidat délégué"
},
{
"type": "role",
"label": "Candidat Sénatoriales 2020",
"label": "Candidat Sénatoriales 2020 délégué",
"tooltip": "Candidat Sénateur délégué"
},
{
"type": "role",
"label": "Président assemblée départementale",
"label": "Président assemblée départementale délégué",
"tooltip": "Responsable élus délégué #1"
},
{
"type": "role",
"label": "Président assemblée départementale",
"label": "Président assemblée départementale délégué",
"tooltip": "Responsable communication"
},
{
"type": "role",
"label": "Responsable local",
"label": "Responsable local délégué",
"tooltip": "Responsable logistique"
},
{
"type": "role",
"label": "Candidat aux législatives",
"label": "Candidat aux législatives délégué",
"tooltip": "Responsable communication"
},
{
Expand Down Expand Up @@ -477,7 +477,7 @@ Feature:
"tags": [
{
"type": "role",
"label": "Président assemblée départementale",
"label": "Président assemblée départementale délégué",
"tooltip": "Responsable communication"
}
],
Expand Down
2 changes: 1 addition & 1 deletion features/api/profile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,7 @@ Feature:

Scenario: As a logged-in user with new app version I can not unregister with empty body
Given I am logged with "[email protected]" via OAuth client "JeMengage Mobile"
And I add "X-App-Version" header equal to "v5.11.0"
And I add "X-App-Version" header equal to "v5.18.0#0"
When I send a "POST" request to "/api/v3/profile/unregister"
Then the response status code should be 400

Expand Down
1 change: 1 addition & 0 deletions src/Entity/Projection/ManagedUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ public function getRolesAsArray(): array
$rolePart = explode('|', $role);

$roleData['role'] = $rolePart[0];
$roleData['is_delegated'] = true;
$roleData['function'] = $rolePart[1];
}
$roles[] = $roleData;
Expand Down
6 changes: 5 additions & 1 deletion src/Normalizer/ManagedUserNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ public function normalize($object, $format = null, array $context = []): array|s
function (array $role) {
return [
'type' => 'role',
'label' => ($label = $this->translator->trans($key = 'role.'.$role['role'])) === $key ? $role['role'] : $label,
'label' => \sprintf(
'%s%s',
($label = $this->translator->trans($key = 'role.'.$role['role'])) === $key ? $role['role'] : $label,
!empty($role['is_delegated']) ? ' délégué' : ''
),
'tooltip' => $role['function'] ?? null,
];
},
Expand Down

0 comments on commit 556a552

Please sign in to comment.