Commit d41d8ffb02fa74fd4571603548bd7e401ec99e0c
1 parent
215a01f6
Exists in
master
and in
4 other branches
Reply button, Comments for Merge Request diff
Showing
13 changed files
with
53 additions
and
15 deletions
Show diff stats
app/assets/stylesheets/common.scss
app/assets/stylesheets/notes.css.scss
| ... | ... | @@ -30,7 +30,10 @@ |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | -.note .delete-note { display:none; } | |
| 33 | +.note .delete-note { | |
| 34 | + display:none; | |
| 35 | + float:right; | |
| 36 | +} | |
| 34 | 37 | .note:hover .delete-note { display:block; } |
| 35 | 38 | .note {padding: 10px 0; border-bottom: 1px solid #eee; overflow: hidden; display: block;} |
| 36 | 39 | .note img{float: left; margin-right: 10px;} |
| ... | ... | @@ -53,6 +56,20 @@ p.notify_controls span{ |
| 53 | 56 | |
| 54 | 57 | tr.line_notes_row { |
| 55 | 58 | border-bottom:1px solid #DDD; |
| 59 | + &.reply { | |
| 60 | + background:#eee; | |
| 61 | + | |
| 62 | + td { | |
| 63 | + padding:7px 10px; | |
| 64 | + } | |
| 65 | + a.line_note_reply_link { | |
| 66 | + @include round-borders-all(4px); | |
| 67 | + border-color:#aaa; | |
| 68 | + background: #bbb; | |
| 69 | + padding: 3px 20px; | |
| 70 | + color: white; | |
| 71 | + } | |
| 72 | + } | |
| 56 | 73 | ul { |
| 57 | 74 | margin:0; |
| 58 | 75 | li { | ... | ... |
app/controllers/merge_requests_controller.rb
| ... | ... | @@ -58,7 +58,9 @@ class MergeRequestsController < ApplicationController |
| 58 | 58 | def diffs |
| 59 | 59 | @diffs = @merge_request.diffs |
| 60 | 60 | @commit = @merge_request.last_commit |
| 61 | - @line_notes = [] | |
| 61 | + | |
| 62 | + @comments_allowed = true | |
| 63 | + @line_notes = @merge_request.notes.where("line_code is not null") | |
| 62 | 64 | end |
| 63 | 65 | |
| 64 | 66 | def new | ... | ... |
app/views/commits/_text_file.html.haml
| ... | ... | @@ -16,6 +16,7 @@ |
| 16 | 16 | - if @comments_allowed |
| 17 | 17 | - comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at).reverse |
| 18 | 18 | - unless comments.empty? |
| 19 | - - comments.each do |note| | |
| 19 | + - comments.each_with_index do |note, i| | |
| 20 | + = render "notes/reply_button", :line_code => line_code if i.zero? | |
| 20 | 21 | = render "notes/per_line_show", :note => note |
| 21 | 22 | - @line_notes.reject!{ |n| n == note } | ... | ... |
app/views/commits/show.html.haml
| ... | ... | @@ -27,7 +27,7 @@ |
| 27 | 27 | |
| 28 | 28 | :javascript |
| 29 | 29 | $(document).ready(function(){ |
| 30 | - $(".line_note_link").live("click", function(e) { | |
| 30 | + $(".line_note_link, .line_note_reply_link").live("click", function(e) { | |
| 31 | 31 | var form = $(".per_line_form"); |
| 32 | 32 | $(this).parent().parent().after(form); |
| 33 | 33 | form.find("#note_line_code").val($(this).attr("line_code")); | ... | ... |
app/views/commits/show.js.haml
| ... | ... | @@ -1 +0,0 @@ |
| 1 | -= render "notes/load" |
app/views/issues/show.html.haml
app/views/merge_requests/show.html.haml
| ... | ... | @@ -64,9 +64,6 @@ |
| 64 | 64 | |
| 65 | 65 | .merge-request-notes |
| 66 | 66 | .merge_request_notes= render "notes/notes", :tid => @merge_request.id, :tt => "merge_request" |
| 67 | - .loading{ :style => "display:none;"} | |
| 68 | - %center= image_tag "ajax-loader.gif" | |
| 69 | - .clear | |
| 70 | 67 | |
| 71 | 68 | .merge-request-diffs |
| 72 | 69 | |
| ... | ... | @@ -75,3 +72,15 @@ |
| 75 | 72 | $(function(){ |
| 76 | 73 | MergeRequest.init(); |
| 77 | 74 | }) |
| 75 | + | |
| 76 | += render "notes/per_line_form" | |
| 77 | +:javascript | |
| 78 | + $(document).ready(function(){ | |
| 79 | + $(".line_note_link, .line_note_reply_link").live("click", function(e) { | |
| 80 | + var form = $(".per_line_form"); | |
| 81 | + $(this).parent().parent().after(form); | |
| 82 | + form.find("#note_line_code").val($(this).attr("line_code")); | |
| 83 | + form.show(); | |
| 84 | + return false; | |
| 85 | + }); | |
| 86 | + }); | ... | ... |
app/views/notes/_notes.html.haml
app/views/notes/_show.html.haml
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | = time_ago_in_words(note.updated_at) |
| 7 | 7 | ago |
| 8 | 8 | - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) |
| 9 | - = link_to "Remove", [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-note right" | |
| 9 | + %strong= link_to "Remove", [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-note btn small" | |
| 10 | 10 | |
| 11 | 11 | %div.note-title |
| 12 | 12 | = markdown(note.note) | ... | ... |
app/views/notes/create.js.haml
| ... | ... | @@ -3,7 +3,10 @@ |
| 3 | 3 | :plain |
| 4 | 4 | $(".per_line_form").hide(); |
| 5 | 5 | $('#new_note textarea').val(""); |
| 6 | - $(".#{@note.line_code}").parent().after("#{escape_javascript(render :partial => "notes/per_line_show", :locals => {:note => @note})}"); | |
| 6 | + $("a.line_note_reply_link[line_code='#{@note.line_code}']").closest("tr").remove(); | |
| 7 | + var trEl = $(".#{@note.line_code}").parent(); | |
| 8 | + trEl.after("#{escape_javascript(render :partial => "notes/per_line_show", :locals => {:note => @note})}"); | |
| 9 | + trEl.after("#{escape_javascript(render :partial => "notes/reply_button", :locals => {:line_code => @note.line_code})}"); | |
| 7 | 10 | - else |
| 8 | 11 | :plain |
| 9 | 12 | $("#new_note .errors").remove(); | ... | ... |
app/views/projects/wall.html.haml