diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /app/helpers/groups/group_members_helper.rb | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'app/helpers/groups/group_members_helper.rb')
-rw-r--r-- | app/helpers/groups/group_members_helper.rb | 80 |
1 files changed, 1 insertions, 79 deletions
diff --git a/app/helpers/groups/group_members_helper.rb b/app/helpers/groups/group_members_helper.rb index adc9d85a384..a4159ed6b19 100644 --- a/app/helpers/groups/group_members_helper.rb +++ b/app/helpers/groups/group_members_helper.rb @@ -18,7 +18,7 @@ module Groups::GroupMembersHelper end def members_data_json(group, members) - members_data(group, members).to_json + MemberSerializer.new.represent(members, { current_user: current_user, group: group }).to_json end # Overridden in `ee/app/helpers/ee/groups/group_members_helper.rb` @@ -38,84 +38,6 @@ module Groups::GroupMembersHelper group_id: group.id } end - - private - - def members_data(group, members) - members.map do |member| - user = member.user - source = member.source - - data = { - id: member.id, - created_at: member.created_at, - expires_at: member.expires_at&.to_time, - requested_at: member.requested_at, - can_update: member.can_update?, - can_remove: member.can_remove?, - access_level: { - string_value: member.human_access, - integer_value: member.access_level - }, - source: { - id: source.id, - name: source.full_name, - web_url: Gitlab::UrlBuilder.build(source) - }, - valid_roles: member.valid_level_roles - }.merge(member_created_by_data(member.created_by)) - - if member.invite? - data[:invite] = member_invite_data(member) - elsif user.present? - data[:user] = member_user_data(user) - end - - data - end - end - - def member_created_by_data(created_by) - return {} unless created_by.present? - - { - created_by: { - name: created_by.name, - web_url: Gitlab::UrlBuilder.build(created_by) - } - } - end - - def member_user_data(user) - { - id: user.id, - name: user.name, - username: user.username, - web_url: Gitlab::UrlBuilder.build(user), - avatar_url: avatar_icon_for_user(user, AVATAR_SIZE), - blocked: user.blocked?, - two_factor_enabled: user.two_factor_enabled? - }.merge(member_user_status_data(user.status)) - end - - def member_user_status_data(status) - return {} unless status.present? - - { - status: { - emoji: status.emoji, - message_html: status.message_html - } - } - end - - def member_invite_data(member) - { - email: member.invite_email, - avatar_url: avatar_icon_for_email(member.invite_email, AVATAR_SIZE), - can_resend: member.can_resend_invite? - } - end end Groups::GroupMembersHelper.prepend_if_ee('EE::Groups::GroupMembersHelper') |