Commit 9b919939a35f9e5606f86a09eafa2a392d40d1a7
1 parent
b91d6802
Exists in
master
and in
4 other branches
Fix parameter passing and wording for per line notes
Showing
9 changed files
with
27 additions
and
12 deletions
Show diff stats
app/controllers/commit_controller.rb
@@ -17,7 +17,9 @@ class CommitController < ProjectResourceController | @@ -17,7 +17,9 @@ class CommitController < ProjectResourceController | ||
17 | @note = result[:note] | 17 | @note = result[:note] |
18 | @line_notes = result[:line_notes] | 18 | @line_notes = result[:line_notes] |
19 | @notes_count = result[:notes_count] | 19 | @notes_count = result[:notes_count] |
20 | - @comments_allowed = true | 20 | + @comments_allowed = @reply_allowed = true |
21 | + @comments_target = { noteable_type: 'Commit', | ||
22 | + noteable_id: @commit.id } | ||
21 | 23 | ||
22 | respond_to do |format| | 24 | respond_to do |format| |
23 | format.html do | 25 | format.html do |
app/controllers/merge_requests_controller.rb
@@ -34,7 +34,9 @@ class MergeRequestsController < ProjectResourceController | @@ -34,7 +34,9 @@ class MergeRequestsController < ProjectResourceController | ||
34 | @diffs = @merge_request.diffs | 34 | @diffs = @merge_request.diffs |
35 | @commit = @merge_request.last_commit | 35 | @commit = @merge_request.last_commit |
36 | 36 | ||
37 | - @comments_allowed = true | 37 | + @comments_allowed = @reply_allowed = true |
38 | + @comments_target = { noteable_type: 'MergeRequest', | ||
39 | + noteable_id: @merge_request.id } | ||
38 | @line_notes = @merge_request.notes.where("line_code is not null") | 40 | @line_notes = @merge_request.notes.where("line_code is not null") |
39 | end | 41 | end |
40 | 42 |
app/views/commits/_text_file.html.haml
@@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
17 | %td.new_line= link_to raw(type == "old" ? " " : line_new) , "##{line_code}", id: line_code | 17 | %td.new_line= link_to raw(type == "old" ? " " : line_new) , "##{line_code}", id: line_code |
18 | %td.line_content{class: "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw "#{line} " | 18 | %td.line_content{class: "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw "#{line} " |
19 | 19 | ||
20 | - - if @comments_allowed | 20 | + - if @reply_allowed |
21 | - comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at) | 21 | - comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at) |
22 | - unless comments.empty? | 22 | - unless comments.empty? |
23 | = render "notes/per_line_notes_with_reply", notes: comments | 23 | = render "notes/per_line_notes_with_reply", notes: comments |
app/views/merge_requests/_show.html.haml
@@ -7,11 +7,11 @@ | @@ -7,11 +7,11 @@ | ||
7 | - if @commits.present? | 7 | - if @commits.present? |
8 | %ul.nav.nav-tabs.mr_nav_tabs | 8 | %ul.nav.nav-tabs.mr_nav_tabs |
9 | %li | 9 | %li |
10 | - = link_to "#notes", "data-url" => project_merge_request_path(@project, @merge_request), class: "merge-notes-tab tab" do | 10 | + = link_to "#notes", title: "Comments", "data-url" => project_merge_request_path(@project, @merge_request), class: "merge-notes-tab tab" do |
11 | %i.icon-comment | 11 | %i.icon-comment |
12 | Comments | 12 | Comments |
13 | %li | 13 | %li |
14 | - = link_to "#diffs", "data-url" => diffs_project_merge_request_path(@project, @merge_request), class: "merge-diffs-tab tab" do | 14 | + = link_to "#diffs", title: "Diff", "data-url" => diffs_project_merge_request_path(@project, @merge_request), class: "merge-diffs-tab tab" do |
15 | %i.icon-list-alt | 15 | %i.icon-list-alt |
16 | Diff | 16 | Diff |
17 | 17 |
app/views/notes/_create_per_line_note.js.haml
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | // find the commented line ... | 11 | // find the commented line ... |
12 | var trEl = $(".#{note.line_code}").parent(); | 12 | var trEl = $(".#{note.line_code}").parent(); |
13 | // ... and insert the note and the reply button after it | 13 | // ... and insert the note and the reply button after it |
14 | - trEl.after("#{escape_javascript(render "notes/per_line_reply_button", line_code: note.line_code)}"); | 14 | + trEl.after("#{escape_javascript(render "notes/per_line_reply_button", note: note)}"); |
15 | trEl.after("#{escape_javascript(render "notes/per_line_note", note: note)}"); | 15 | trEl.after("#{escape_javascript(render "notes/per_line_note", note: note)}"); |
16 | } else { | 16 | } else { |
17 | // instert new note before reply button | 17 | // instert new note before reply button |
app/views/notes/_per_line_form.html.haml
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | %td{colspan: 3 } | 3 | %td{colspan: 3 } |
4 | .line-note-form-holder | 4 | .line-note-form-holder |
5 | = form_for [@project, @note], remote: "true", multipart: true do |f| | 5 | = form_for [@project, @note], remote: "true", multipart: true do |f| |
6 | - %h3.page_title Leave a note | 6 | + %h3.page_title Leave a comment |
7 | %div.span10 | 7 | %div.span10 |
8 | -if @note.errors.any? | 8 | -if @note.errors.any? |
9 | .alert-message.block-message.error | 9 | .alert-message.block-message.error |
@@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
16 | = f.text_area :note, size: 255, class: 'line-note-text js-gfm-input' | 16 | = f.text_area :note, size: 255, class: 'line-note-text js-gfm-input' |
17 | .note_actions | 17 | .note_actions |
18 | .buttons | 18 | .buttons |
19 | - = f.submit 'Add note', class: "btn save-btn submit_note submit_inline_note", id: "submit_note" | 19 | + = f.submit 'Add Comment', class: "btn save-btn submit_note submit_inline_note", id: "submit_note" |
20 | = link_to "Cancel", "#", class: "btn hide-button" | 20 | = link_to "Cancel", "#", class: "btn hide-button" |
21 | .options | 21 | .options |
22 | %h6.left Notify via email: | 22 | %h6.left Notify via email: |
app/views/notes/_per_line_note_link.html.haml
1 | -= link_to "", "#", class: "line_note_link", data: { line_code: line_code }, title: "Add note for this line" | 1 | += link_to "", |
2 | + "#", | ||
3 | + id: "line-note-#{line_code}", | ||
4 | + class: "line_note_link", | ||
5 | + data: @comments_target.merge({ line_code: line_code }), | ||
6 | + title: "Add comment on line #{line_code[/[0-9]+$/]}" |
app/views/notes/_per_line_notes_with_reply.html.haml
app/views/notes/_per_line_reply_button.html.haml
1 | %tr.line_notes_row.reply | 1 | %tr.line_notes_row.reply |
2 | %td{colspan: 3} | 2 | %td{colspan: 3} |
3 | - %i.icon-comment | ||
4 | - = link_to "Reply", "#", class: "line_note_reply_link", data: { line_code: line_code }, title: "Add note for this line" | 3 | + = link_to "#", |
4 | + class: "line_note_reply_link", | ||
5 | + data: { line_code: note.line_code, | ||
6 | + noteable_type: note.noteable_type, | ||
7 | + noteable_id: note.noteable_id }, | ||
8 | + title: "Add note for this line" do | ||
9 | + %i.icon-comment | ||
10 | + Reply |