diff options
author | Luke Bennett <lbennett@gitlab.com> | 2019-02-15 17:08:03 +0300 |
---|---|---|
committer | Luke Bennett <lbennett@gitlab.com> | 2019-02-18 19:58:28 +0300 |
commit | aa464800b80b86b79a43b3b8a7398c5e631d40f2 (patch) | |
tree | ccc1103d35732d9677637a5910435367861614bc /app | |
parent | 1cd080c71afb4bb04cf786821b864278098bad03 (diff) |
Add type property to project autocomplete members
Diffstat (limited to 'app')
-rw-r--r-- | app/services/concerns/users/participable_service.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/app/services/concerns/users/participable_service.rb b/app/services/concerns/users/participable_service.rb index 5b408bd96c7..6713b6617ae 100644 --- a/app/services/concerns/users/participable_service.rb +++ b/app/services/concerns/users/participable_service.rb @@ -11,7 +11,7 @@ module Users def noteable_owner return [] unless noteable && noteable.author.present? - [as_hash(noteable.author)] + [user_as_hash(noteable.author)] end def participants_in_noteable @@ -23,21 +23,24 @@ module Users def sorted(users) users.uniq.to_a.compact.sort_by(&:username).map do |user| - as_hash(user) + user_as_hash(user) end end def groups current_user.authorized_groups.sort_by(&:path).map do |group| - count = group.users.count - { username: group.full_path, name: group.full_name, count: count, avatar_url: group.avatar_url } + group_as_hash(group) end end private - def as_hash(user) - { username: user.username, name: user.name, avatar_url: user.avatar_url } + def user_as_hash(user) + { type: user.class.name, username: user.username, name: user.name, avatar_url: user.avatar_url } + end + + def group_as_hash(group) + { type: group.class.name, username: group.full_path, name: group.full_name, avatar_url: group.avatar_url, count: group.users.count } end end end |