diff options
author | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-02-27 07:08:23 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-02-27 07:08:23 +0000 |
commit | 47c5a2ab22b0fbc9c20b996ec24c27608e99bc43 (patch) | |
tree | 5abb8eb89cf26f1ab03b8c4dd36cafe4f7409a4c /app/services | |
parent | 42387b733b76dfc1f72585015910a50f094e264f (diff) | |
parent | a672b4688309dc356922bd3f9c61b8ae9de018f8 (diff) | |
download | gitlab-ce-47c5a2ab22b0fbc9c20b996ec24c27608e99bc43.tar.gz |
Merge branch 'autocomplete-mention-count' into 'master'
Include number of affected people in all/group mention autocomplete item.
As mentioned in #2054.
To minimize misuse of all/group mentions, the autocomplete title includes the number of members this mention will notify, so users will be more considerate what groups they mention.
Example:
at-all "**all** All Project and Group Members (12)"
at-gitlab "**gitlab** GitLab (12)"
See merge request !1596
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/projects/participants_service.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/services/projects/participants_service.rb b/app/services/projects/participants_service.rb index 0be50fed7cc..f6f9aceef95 100644 --- a/app/services/projects/participants_service.rb +++ b/app/services/projects/participants_service.rb @@ -35,15 +35,21 @@ module Projects end def sorted(users) - users.uniq.to_a.compact.sort_by(&:username).map { |user| { username: user.username, name: user.name } } + users.uniq.to_a.compact.sort_by(&:username).map do |user| + { username: user.username, name: user.name } + end end def groups - @user.authorized_groups.sort_by(&:path).map { |group| { username: group.path, name: group.name } } + @user.authorized_groups.sort_by(&:path).map do |group| + count = group.users.count + { username: group.path, name: "#{group.name} (#{count})" } + end end def all_members - [{ username: "all", name: "Project and Group Members" }] + count = @project.team.members.flatten.count + [{ username: "all", name: "All Project and Group Members (#{count})" }] end end end |