summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-10-29 15:55:37 +0100
committerRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-12-03 22:51:55 +0100
commit9b919939a35f9e5606f86a09eafa2a392d40d1a7 (patch)
tree36e33d493cd60e236fb3673927e26a0091d98b8a
parentb91d6802572eeb152bd86dd68c54ef4151180848 (diff)
downloadgitlab-ce-9b919939a35f9e5606f86a09eafa2a392d40d1a7.tar.gz
Fix parameter passing and wording for per line notes
-rw-r--r--app/controllers/commit_controller.rb4
-rw-r--r--app/controllers/merge_requests_controller.rb4
-rw-r--r--app/views/commits/_text_file.html.haml2
-rw-r--r--app/views/merge_requests/_show.html.haml4
-rw-r--r--app/views/notes/_create_per_line_note.js.haml2
-rw-r--r--app/views/notes/_per_line_form.html.haml4
-rw-r--r--app/views/notes/_per_line_note_link.html.haml7
-rw-r--r--app/views/notes/_per_line_notes_with_reply.html.haml2
-rw-r--r--app/views/notes/_per_line_reply_button.html.haml10
9 files changed, 27 insertions, 12 deletions
diff --git a/app/controllers/commit_controller.rb b/app/controllers/commit_controller.rb
index d671e9f9e9e..ebc27772f9a 100644
--- a/app/controllers/commit_controller.rb
+++ b/app/controllers/commit_controller.rb
@@ -17,7 +17,9 @@ class CommitController < ProjectResourceController
@note = result[:note]
@line_notes = result[:line_notes]
@notes_count = result[:notes_count]
- @comments_allowed = true
+ @comments_allowed = @reply_allowed = true
+ @comments_target = { noteable_type: 'Commit',
+ noteable_id: @commit.id }
respond_to do |format|
format.html do
diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb
index 362962707fd..24f4239e520 100644
--- a/app/controllers/merge_requests_controller.rb
+++ b/app/controllers/merge_requests_controller.rb
@@ -34,7 +34,9 @@ class MergeRequestsController < ProjectResourceController
@diffs = @merge_request.diffs
@commit = @merge_request.last_commit
- @comments_allowed = true
+ @comments_allowed = @reply_allowed = true
+ @comments_target = { noteable_type: 'MergeRequest',
+ noteable_id: @merge_request.id }
@line_notes = @merge_request.notes.where("line_code is not null")
end
diff --git a/app/views/commits/_text_file.html.haml b/app/views/commits/_text_file.html.haml
index 02117386d71..5e7886922b4 100644
--- a/app/views/commits/_text_file.html.haml
+++ b/app/views/commits/_text_file.html.haml
@@ -17,7 +17,7 @@
%td.new_line= link_to raw(type == "old" ? "&nbsp;" : line_new) , "##{line_code}", id: line_code
%td.line_content{class: "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw "#{line} &nbsp;"
- - if @comments_allowed
+ - if @reply_allowed
- comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at)
- unless comments.empty?
= render "notes/per_line_notes_with_reply", notes: comments
diff --git a/app/views/merge_requests/_show.html.haml b/app/views/merge_requests/_show.html.haml
index f1d0c8aaafb..d12431da70b 100644
--- a/app/views/merge_requests/_show.html.haml
+++ b/app/views/merge_requests/_show.html.haml
@@ -7,11 +7,11 @@
- if @commits.present?
%ul.nav.nav-tabs.mr_nav_tabs
%li
- = link_to "#notes", "data-url" => project_merge_request_path(@project, @merge_request), class: "merge-notes-tab tab" do
+ = link_to "#notes", title: "Comments", "data-url" => project_merge_request_path(@project, @merge_request), class: "merge-notes-tab tab" do
%i.icon-comment
Comments
%li
- = link_to "#diffs", "data-url" => diffs_project_merge_request_path(@project, @merge_request), class: "merge-diffs-tab tab" do
+ = link_to "#diffs", title: "Diff", "data-url" => diffs_project_merge_request_path(@project, @merge_request), class: "merge-diffs-tab tab" do
%i.icon-list-alt
Diff
diff --git a/app/views/notes/_create_per_line_note.js.haml b/app/views/notes/_create_per_line_note.js.haml
index 180960e38e4..eea9eb38be4 100644
--- a/app/views/notes/_create_per_line_note.js.haml
+++ b/app/views/notes/_create_per_line_note.js.haml
@@ -11,7 +11,7 @@
// find the commented line ...
var trEl = $(".#{note.line_code}").parent();
// ... and insert the note and the reply button after it
- trEl.after("#{escape_javascript(render "notes/per_line_reply_button", line_code: note.line_code)}");
+ trEl.after("#{escape_javascript(render "notes/per_line_reply_button", note: note)}");
trEl.after("#{escape_javascript(render "notes/per_line_note", note: note)}");
} else {
// instert new note before reply button
diff --git a/app/views/notes/_per_line_form.html.haml b/app/views/notes/_per_line_form.html.haml
index c8d79850162..460d49522bf 100644
--- a/app/views/notes/_per_line_form.html.haml
+++ b/app/views/notes/_per_line_form.html.haml
@@ -3,7 +3,7 @@
%td{colspan: 3 }
.line-note-form-holder
= form_for [@project, @note], remote: "true", multipart: true do |f|
- %h3.page_title Leave a note
+ %h3.page_title Leave a comment
%div.span10
-if @note.errors.any?
.alert-message.block-message.error
@@ -16,7 +16,7 @@
= f.text_area :note, size: 255, class: 'line-note-text js-gfm-input'
.note_actions
.buttons
- = f.submit 'Add note', class: "btn save-btn submit_note submit_inline_note", id: "submit_note"
+ = f.submit 'Add Comment', class: "btn save-btn submit_note submit_inline_note", id: "submit_note"
= link_to "Cancel", "#", class: "btn hide-button"
.options
%h6.left Notify via email:
diff --git a/app/views/notes/_per_line_note_link.html.haml b/app/views/notes/_per_line_note_link.html.haml
index 72b59a596a3..16db3d809cb 100644
--- a/app/views/notes/_per_line_note_link.html.haml
+++ b/app/views/notes/_per_line_note_link.html.haml
@@ -1 +1,6 @@
-= link_to "", "#", class: "line_note_link", data: { line_code: line_code }, title: "Add note for this line"
+= link_to "",
+ "#",
+ id: "line-note-#{line_code}",
+ class: "line_note_link",
+ data: @comments_target.merge({ line_code: line_code }),
+ title: "Add comment on line #{line_code[/[0-9]+$/]}"
diff --git a/app/views/notes/_per_line_notes_with_reply.html.haml b/app/views/notes/_per_line_notes_with_reply.html.haml
index 1bcfc41fe20..ebe0c5c6c47 100644
--- a/app/views/notes/_per_line_notes_with_reply.html.haml
+++ b/app/views/notes/_per_line_notes_with_reply.html.haml
@@ -1,3 +1,3 @@
- notes.each do |note|
= render "notes/per_line_note", note: note
-= render "notes/per_line_reply_button", line_code: notes.first.line_code
+= render "notes/per_line_reply_button", note: notes.first
diff --git a/app/views/notes/_per_line_reply_button.html.haml b/app/views/notes/_per_line_reply_button.html.haml
index 42c737c75ae..c9d2696675e 100644
--- a/app/views/notes/_per_line_reply_button.html.haml
+++ b/app/views/notes/_per_line_reply_button.html.haml
@@ -1,4 +1,10 @@
%tr.line_notes_row.reply
%td{colspan: 3}
- %i.icon-comment
- = link_to "Reply", "#", class: "line_note_reply_link", data: { line_code: line_code }, title: "Add note for this line"
+ = link_to "#",
+ class: "line_note_reply_link",
+ data: { line_code: note.line_code,
+ noteable_type: note.noteable_type,
+ noteable_id: note.noteable_id },
+ title: "Add note for this line" do
+ %i.icon-comment
+ Reply