Module: MembersHelper

Included in:
Emails::Members, GroupEntity
Defined in:
app/helpers/members_helper.rb

Instance Method Summary collapse

Instance Method Details

#filter_group_project_member_path(options = {}) ⇒ Object


46
47
48
49
# File 'app/helpers/members_helper.rb', line 46

def filter_group_project_member_path(options = {})
  options = params.slice(:search, :sort).merge(options).permit!
  "#{request.path}?#{options.to_param}"
end

#leave_confirmation_message(member_source) ⇒ Object


41
42
43
44
# File 'app/helpers/members_helper.rb', line 41

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

#localized_tasks_to_be_done_choicesObject


59
60
61
62
63
64
65
# File 'app/helpers/members_helper.rb', line 59

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

#member_path(member) ⇒ Object


51
52
53
54
55
56
57
# File 'app/helpers/members_helper.rb', line 51

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

#remove_member_message(member, user: nil) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/helpers/members_helper.rb', line 4

def remove_member_message(member, user: nil)
  user = current_user if defined?(current_user)
  text = 'Are you sure you want to'

  action =
    if member.invite?
      "revoke the invitation for #{member.invite_email} to join"
    elsif member.request?
      if member.user == user
        'withdraw your access request for'
      else
        "deny #{member.user.name}'s request to join"
      end
    else
      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
    end

  "#{text} #{action} the #{member.source.human_name} #{source_text(member)}?"
end

#remove_member_title(member) ⇒ Object


35
36
37
38
39
# File 'app/helpers/members_helper.rb', line 35

def remove_member_title(member)
  action = member.request? ? 'Deny access request' : 'Remove user'

  "#{action} from #{source_text(member)}"
end