2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-18 12:53:32 -04:00
|
|
|
module MembersHelper
|
2016-06-02 12:05:06 -04:00
|
|
|
def remove_member_message(member, user: nil)
|
|
|
|
user = current_user if defined?(current_user)
|
2018-08-18 07:19:57 -04:00
|
|
|
text = 'Are you sure you want to'
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
action =
|
2020-12-08 04:09:41 -05:00
|
|
|
if member.invite?
|
|
|
|
"revoke the invitation for #{member.invite_email} to join"
|
|
|
|
elsif member.request?
|
2016-11-16 16:35:33 -05:00
|
|
|
if member.user == user
|
|
|
|
'withdraw your access request for'
|
2016-06-02 12:05:06 -04:00
|
|
|
else
|
2016-11-16 16:35:33 -05:00
|
|
|
"deny #{member.user.name}'s request to join"
|
2016-06-02 12:05:06 -04:00
|
|
|
end
|
2016-11-16 16:35:33 -05:00
|
|
|
else
|
2020-04-27 02:09:51 -04:00
|
|
|
if member.user
|
|
|
|
"remove #{member.user.name} from"
|
|
|
|
else
|
|
|
|
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"
|
|
|
|
end
|
2016-11-16 16:35:33 -05:00
|
|
|
end
|
2016-04-18 12:53:32 -04:00
|
|
|
|
2018-11-16 10:09:32 -05:00
|
|
|
"#{text} #{action} the #{member.source.human_name} #{source_text(member)}?"
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def remove_member_title(member)
|
2018-08-18 07:19:57 -04:00
|
|
|
action = member.request? ? 'Deny access request' : 'Remove user'
|
2018-11-16 10:09:32 -05:00
|
|
|
|
|
|
|
"#{action} from #{source_text(member)}"
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
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)}?"
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|
2016-10-18 08:22:18 -04:00
|
|
|
|
|
|
|
def filter_group_project_member_path(options = {})
|
2019-01-15 16:05:36 -05:00
|
|
|
options = params.slice(:search, :sort).merge(options).permit!
|
2018-08-18 07:19:57 -04:00
|
|
|
"#{request.path}?#{options.to_param}"
|
2016-10-18 08:22:18 -04:00
|
|
|
end
|
2018-11-16 10:09:32 -05:00
|
|
|
|
2020-07-09 11:08:59 -04:00
|
|
|
def member_path(member)
|
2020-06-23 11:08:41 -04:00
|
|
|
if member.is_a?(GroupMember)
|
2020-07-09 11:08:59 -04:00
|
|
|
group_group_member_path(member.source, member)
|
2020-06-23 11:08:41 -04:00
|
|
|
else
|
2020-07-09 11:08:59 -04:00
|
|
|
project_project_member_path(member.source, member)
|
2020-06-23 11:08:41 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-10-25 08:10:19 -04:00
|
|
|
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
|
|
|
|
|
2018-11-16 10:09:32 -05:00
|
|
|
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-04-22 08:09:49 -04:00
|
|
|
|
2021-05-11 14:10:36 -04:00
|
|
|
def members_pagination_data(members, pagination = {})
|
2021-04-22 08:09:49 -04:00
|
|
|
{
|
|
|
|
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] || {}
|
2021-05-11 14:10:36 -04:00
|
|
|
}
|
2021-04-22 08:09:49 -04:00
|
|
|
end
|
2016-04-18 12:53:32 -04:00
|
|
|
end
|