2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
module MembersHelper
|
|
|
|
def remove_member_message(member, user: nil)
|
|
|
|
user = current_user if defined?(current_user)
|
2018-12-05 23:21:45 +05:30
|
|
|
text = 'Are you sure you want to'
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
action =
|
2021-01-29 00:20:46 +05:30
|
|
|
if member.invite?
|
|
|
|
"revoke the invitation for #{member.invite_email} to join"
|
|
|
|
elsif member.request?
|
2016-06-16 23:09:34 +05:30
|
|
|
if member.user == user
|
|
|
|
'withdraw your access request for'
|
|
|
|
else
|
|
|
|
"deny #{member.user.name}'s request to join"
|
|
|
|
end
|
2023-03-04 22:38:38 +05:30
|
|
|
elsif member.user
|
|
|
|
"remove #{member.user.name} from"
|
2016-06-16 23:09:34 +05:30
|
|
|
else
|
2023-03-04 22:38:38 +05:30
|
|
|
e = RuntimeError.new("Data integrity error: no associated user for member ID #{member.id}")
|
|
|
|
Gitlab::ErrorTracking.track_exception(e,
|
|
|
|
member_id: member.id,
|
|
|
|
invite_email: member.invite_email,
|
|
|
|
invite_accepted_at: member.invite_accepted_at,
|
|
|
|
source_id: member.source_id,
|
|
|
|
source_type: member.source_type)
|
|
|
|
"remove this orphaned member from"
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
2019-01-03 12:48:30 +05:30
|
|
|
"#{text} #{action} the #{member.source.human_name} #{source_text(member)}?"
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def remove_member_title(member)
|
2018-12-05 23:21:45 +05:30
|
|
|
action = member.request? ? 'Deny access request' : 'Remove user'
|
2019-01-03 12:48:30 +05:30
|
|
|
|
|
|
|
"#{action} from #{source_text(member)}"
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def leave_confirmation_message(member_source)
|
|
|
|
"Are you sure you want to leave the " \
|
|
|
|
"\"#{member_source.human_name}\" #{member_source.class.to_s.humanize(capitalize: false)}?"
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
def filter_group_project_member_path(options = {})
|
2019-03-02 22:35:43 +05:30
|
|
|
options = params.slice(:search, :sort).merge(options).permit!
|
2018-12-05 23:21:45 +05:30
|
|
|
"#{request.path}?#{options.to_param}"
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2019-01-03 12:48:30 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
def member_path(member)
|
|
|
|
if member.is_a?(GroupMember)
|
|
|
|
group_group_member_path(member.source, member)
|
|
|
|
else
|
|
|
|
project_project_member_path(member.source, member)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
def localized_tasks_to_be_done_choices
|
|
|
|
{
|
|
|
|
code: s_('TasksToBeDone|Create/import code into a project (repository)'),
|
|
|
|
ci: s_('TasksToBeDone|Set up CI/CD pipelines to build, test, deploy, and monitor code'),
|
|
|
|
issues: s_('TasksToBeDone|Create/import issues (tickets) to collaborate on ideas and plan work')
|
|
|
|
}.freeze
|
|
|
|
end
|
|
|
|
|
2019-01-03 12:48:30 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def source_text(member)
|
|
|
|
type = member.real_source_type.humanize(capitalize: false)
|
|
|
|
|
|
|
|
return type if member.request? || member.invite? || type != 'group'
|
|
|
|
|
|
|
|
'group and any subresources'
|
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
def members_pagination_data(members, pagination = {})
|
|
|
|
{
|
|
|
|
current_page: members.respond_to?(:current_page) ? members.current_page : nil,
|
|
|
|
per_page: members.respond_to?(:limit_value) ? members.limit_value : nil,
|
|
|
|
total_items: members.respond_to?(:total_count) ? members.total_count : members.count,
|
|
|
|
param_name: pagination[:param_name] || nil,
|
|
|
|
params: pagination[:params] || {}
|
|
|
|
}
|
|
|
|
end
|
2022-08-27 11:52:29 +05:30
|
|
|
|
|
|
|
def member_request_access_link(member)
|
|
|
|
user = member.user
|
|
|
|
member_source = member.source
|
|
|
|
|
|
|
|
member_link = link_to user.name, user, class: :highlight
|
|
|
|
member_role = content_tag :span, member.human_access, class: :highlight
|
|
|
|
target_source_link = link_to member_source.human_name, polymorphic_url([member_source, :members]), class: :highlight
|
|
|
|
target_type = member_source.model_name.singular
|
|
|
|
|
|
|
|
s_('Notify|%{member_link} requested %{member_role} access to the %{target_source_link} %{target_type}.')
|
|
|
|
.html_safe % {
|
|
|
|
member_link: member_link,
|
|
|
|
member_role: member_role,
|
|
|
|
target_source_link: target_source_link,
|
|
|
|
target_type: target_type
|
|
|
|
}
|
|
|
|
end
|
2016-06-16 23:09:34 +05:30
|
|
|
end
|
2022-07-23 23:45:48 +05:30
|
|
|
|
|
|
|
MembersHelper.prepend_mod_with('MembersHelper')
|