summaryrefslogtreecommitdiff
path: root/app/views/projects/diffs/_line.html.haml
blob: 4d40071e07c6bc1754c6353337877cb4b29272b4 (plain)
1
2
3
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
34
35
36
37
38
- email = local_assigns.fetch(:email, false)
- plain = local_assigns.fetch(:plain, false)
- discussions = local_assigns.fetch(:discussions, nil)
- type = line.type
- line_code = diff_file.line_code(line)
- if discussions && line.discussable?
  - line_discussions = discussions[line_code]
%tr.line_holder{ class: type, id: (line_code unless plain) }
  - case type
  - when 'match'
    = diff_match_line line.old_pos, line.new_pos, text: line.text
  - when 'old-nonewline', 'new-nonewline'
    %td.old_line.diff-line-num
    %td.new_line.diff-line-num
    %td.line_content.match= line.text
  - else
    %td.old_line.diff-line-num{ class: [type, ("js-avatar-container" if !plain)], data: { linenumber: line.old_pos } }
      - link_text = type == "new" ? " " : line.old_pos
      - if plain
        = link_text
      - else
        = add_diff_note_button(line_code, diff_file.position(line), type)
        %a{ href: "##{line_code}", data: { linenumber: link_text } }
    %td.new_line.diff-line-num{ class: type, data: { linenumber: line.new_pos } }
      - link_text = type == "old" ? " " : line.new_pos
      - if plain
        = link_text
      - else
        %a{ href: "##{line_code}", data: { linenumber: link_text } }
    %td.line_content{ class: type }<
      - if email
        %pre= line.rich_text
      - else
        = diff_line_content(line.rich_text)

- if line_discussions&.any?
  - discussion_expanded = local_assigns.fetch(:discussion_expanded, line_discussions.any?(&:expanded?))
  = render "discussions/diff_discussion", discussions: line_discussions, expanded: discussion_expanded