Read about our upcoming Code of Conduct on this issue

merge_requests_helper.rb 1.06 KB
Newer Older
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
1
module MergeRequestsHelper
2
3
4
5
6
  def link_to_merge_request_assignee(merge_request)
    project = merge_request.project

    tm = project.team_member_by_id(merge_request.assignee_id)
    if tm
7
      link_to merge_request.assignee_name, project_team_member_path(project, tm), class: "author_link"
8
9
10
11
12
13
14
15
16
17
    else
      merge_request.assignee_name
    end
  end

  def link_to_merge_request_author(merge_request)
    project = merge_request.project

    tm = project.team_member_by_id(merge_request.author_id)
    if tm
18
      link_to merge_request.author_name, project_team_member_path(project, tm), class: "author_link"
19
20
21
22
    else
      merge_request.author_name
    end
  end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
23
24
25
26

  def new_mr_path_from_push_event(event)
    new_project_merge_request_path(
      event.project,
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
27
      merge_request: {
28
29
30
        source_branch: event.branch_name,
        target_branch: event.project.root_ref,
        title: event.branch_name.titleize
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
31
32
33
      }
    )
  end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
34
35
36
37
38
39
40

  def mr_css_classes mr
    classes = "merge_request"
    classes << " closed" if mr.closed
    classes << " merged" if mr.merged?
    classes
  end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
41
end