user_group_pill: Hardcode Everyone in display name.

For system groups, the directive is that we should use the description
as the display name. But in case of `role:everyone`, the description is
`Admins, moderators, members and guests`, while for the
`user_group_pill`, we want to display a simpler and succinct message:
`Everyone`. We've only hardcoded this for user_group_pill since we don't
want to display the name as `Everyone` anywhere else yet.

We've also exposed a method called `get_display_group_name` which will
be used in later commits to get the group display name.
This commit is contained in:
Shubham Padia
2024-07-08 16:32:25 +00:00
committed by Tim Abbott
parent 458038b384
commit be5e0d4648
4 changed files with 35 additions and 2 deletions

View File

@@ -325,3 +325,15 @@ export function get_realm_user_groups_for_dropdown_list_widget(
return [...system_user_groups, ...user_groups_excluding_system_groups];
}
// Group name for user-facing display. For settings, we already use
// description strings for system groups. But those description strings
// might not be suitable for every case, e.g. we want the name for
// `role:everyone` to be `Everyone` instead of
// `Admins, moderators, members and guests` from `settings_config`.
// Right now, we only change the name for `role:everyone`, that's why
// we don't store the values in a structured way like
// `settings_config` yet.
export function get_display_group_name(user_group: UserGroup): string {
return user_group.name === "role:everyone" ? $t({defaultMessage: "Everyone"}) : user_group.name;
}