Skip to content

Sort invite roles list by application display name - #357

Merged
kayjoosten merged 3 commits into
mainfrom
343-sort-invite-roles
Oct 22, 2026
Merged

kayjoosten merged 3 commits into
mainfrom
343-sort-invite-roles

Conversation

@kayjoosten

Copy link
Copy Markdown
Contributor

Summary

The list of invite roles shown under /invite-roles was not sorted, so every visit could show the roles in a different, unpredictable order.

Changes

  • Added InviteRoleList::sortByApplicationDisplayName(string $locale), which sorts roles alphabetically (case insensitively) by their application display name, falling back to the role name for roles without applications. This mirrors the sorting approach already used for /my-services.
  • Updated InviteRolesController to sort the list using the current locale before rendering.
  • Added unit tests covering sorting, case insensitivity, and roles without applications.

Testing

Ran the full QA suite locally (composer check): composer-validate, phplint, phpmd, phpcs, license-headers, phpunit (147 tests, 281 assertions), phpstan. All green.

Closes #343

@johanib johanib left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If point below is fixed, please merge.

# If applied, this commit will...
Sort the list of roles shown on the invite-roles page by application
display name.

# Why is this change needed?
Prior to this change, the list of invite roles shown under
/invite-roles was not sorted. Every request could return the roles in
a different order, making the menu feel unpredictable and hard to
scan.

# How does it address the issue?
This change adds a sortByApplicationDisplayName method to
InviteRoleList that orders roles alphabetically and case
insensitively by their application display name, falling back to the
role name when a role has no applications. The InviteRolesController
now sorts the list using the current locale before rendering it,
matching the approach already used for the my-services overview.

# Provide links to any relevant tickets, articles or other resources
Closes #343
If applied, this commit will make sortByApplicationDisplayName return a
new sorted InviteRoleList instead of mutating the existing one.

Why is this change needed?
Prior to this change, sortByApplicationDisplayName mutated the
InviteRoleList value object in place, which is unexpected for a value
object and made the method harder to reason about and test.

How does it address the issue?
This change makes sortByApplicationDisplayName a pure function: it
copies the roles, sorts the copy, and returns a new InviteRoleList
built through the constructor, leaving the original instance
untouched. The controller and tests are updated to use the returned
list.

Provide links to any relevant tickets, articles or other resources
Addresses review feedback on PR #357.
@kayjoosten
kayjoosten force-pushed the 343-sort-invite-roles branch from 7e08e00 to 91e281b Compare October 19, 2026 07:47
@kayjoosten
kayjoosten requested a review from johanib October 19, 2026 07:50
@kayjoosten
kayjoosten merged commit 349ca1f into main Oct 22, 2026
1 check passed
@kayjoosten
kayjoosten deleted the 343-sort-invite-roles branch October 22, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

List of roles is not sorted

2 participants