Commit 81ee69381d9e01997a204b89cdeabf9854138967
1 parent
fb0279f3
Exists in
master
and in
4 other branches
Add links to the note source if the note is mixed in
Showing
3 changed files
with
17 additions
and
1 deletions
Show diff stats
app/helpers/notes_helper.rb
... | ... | @@ -12,5 +12,15 @@ module NotesHelper |
12 | 12 | !@mixed_targets || @main_target_type == note.noteable_type |
13 | 13 | end |
14 | 14 | |
15 | + def link_to_commit_diff_line_note(note) | |
16 | + return unless note.line_note? | |
17 | + | |
18 | + commit = note.target | |
19 | + diff_index, diff_old_line, diff_new_line = note.line_code.split('_') | |
20 | + | |
21 | + link_file = commit.diffs[diff_index.to_i].new_path | |
22 | + link_line = diff_new_line | |
23 | + | |
24 | + link_to "#{link_file}:L#{link_line}", project_commit_path(@project, commit, anchor: note.line_code) | |
15 | 25 | end |
16 | 26 | end | ... | ... |
app/views/commits/_text_file.html.haml
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | |
5 | 5 | %table{class: "#{'hide' if too_big}"} |
6 | 6 | - each_diff_line(diff.diff.lines.to_a, index) do |line, type, line_code, line_new, line_old| |
7 | - %tr.line_holder | |
7 | + %tr.line_holder{ id: line_code } | |
8 | 8 | - if type == "match" |
9 | 9 | %td.old_line= "..." |
10 | 10 | %td.new_line= "..." | ... | ... |
app/views/notes/_note.html.haml
... | ... | @@ -7,6 +7,12 @@ |
7 | 7 | = time_ago_in_words(note.updated_at) |
8 | 8 | ago |
9 | 9 | |
10 | + - unless note_for_main_target?(note) | |
11 | + - if note.commit? | |
12 | + %span.cgray | |
13 | + on #{link_to note.target.short_id, project_commit_path(@project, note.target)} | |
14 | + = link_to_commit_diff_line_note(note) if note.line_note? | |
15 | + | |
10 | 16 | -# only show vote if it's a note for the main target |
11 | 17 | - if note_for_main_target?(note) |
12 | 18 | - if note.upvote? | ... | ... |