debian-mirror-gitlab/app/helpers/projects/project_members_helper.rb

41 lines
1.5 KiB
Ruby
Raw Normal View History

2021-03-08 18:12:59 +05:30
# frozen_string_literal: true
module Projects::ProjectMembersHelper
2021-09-04 01:27:46 +05:30
def project_members_app_data_json(project, members:, group_links:, invited:, access_requests:)
{
user: project_members_list_data(project, members, { param_name: :page, params: { search_groups: nil } }),
group: project_group_links_list_data(project, group_links),
invite: project_members_list_data(project, invited.nil? ? [] : invited),
access_request: project_members_list_data(project, access_requests.nil? ? [] : access_requests),
source_id: project.id,
2021-10-27 15:23:28 +05:30
can_manage_members: Ability.allowed?(current_user, :admin_project_member, project)
2021-09-04 01:27:46 +05:30
}.to_json
2021-03-11 19:13:27 +05:30
end
2021-06-08 01:23:25 +05:30
private
def project_members_serialized(project, members)
MemberSerializer.new.represent(members, { current_user: current_user, group: project.group, source: project })
end
def project_group_links_serialized(group_links)
GroupLink::ProjectGroupLinkSerializer.new.represent(group_links, { current_user: current_user })
end
2021-09-04 01:27:46 +05:30
def project_members_list_data(project, members, pagination = {})
2021-03-11 19:13:27 +05:30
{
2021-06-08 01:23:25 +05:30
members: project_members_serialized(project, members),
pagination: members_pagination_data(members, pagination),
2021-09-04 01:27:46 +05:30
member_path: project_project_member_path(project, ':id')
2021-03-11 19:13:27 +05:30
}
end
2021-06-08 01:23:25 +05:30
def project_group_links_list_data(project, group_links)
2021-03-11 19:13:27 +05:30
{
2021-06-08 01:23:25 +05:30
members: project_group_links_serialized(group_links),
pagination: members_pagination_data(group_links),
2021-09-04 01:27:46 +05:30
member_path: project_group_link_path(project, ':id')
2021-03-11 19:13:27 +05:30
}
end
2021-03-08 18:12:59 +05:30
end