Commit 47c5a2ab authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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
parents 42387b73 a672b468
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment