gitlab-org--gitlab-foss/app/helpers/members_helper.rb
TM Lee 2cf3fc18a6 Refactor member view by using presenter
- Create MemberPresenter alongside with GroupMemberPresenter and ProjectMemberPresenter
- Make Member model Presentable
- Move action_member_permission from MembersHelper into the MemberPresenter
- Added rspec using double, separate specs for GroupMemberPresenter and ProjectMemberPresenter

Fixes #28004.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-12-11 18:30:56 +01:00

40 lines
1.2 KiB
Ruby

module MembersHelper
def remove_member_message(member, user: nil)
user = current_user if defined?(current_user)
text = 'Are you sure you want to '
action =
if member.request?
if member.user == user
'withdraw your access request for'
else
"deny #{member.user.name}'s request to join"
end
elsif member.invite?
"revoke the invitation for #{member.invite_email} to join"
else
"remove #{member.user.name} from"
end
text << action << " the #{member.source.human_name} #{member.real_source_type.humanize(capitalize: false)}?"
end
def remove_member_title(member)
text = " from #{member.real_source_type.humanize(capitalize: false)}"
text.prepend(member.request? ? 'Deny access request' : 'Remove user')
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
def filter_group_project_member_path(options = {})
options = params.slice(:search, :sort).merge(options)
path = request.path
path << "?#{options.to_param}"
path
end
end