From a7932fe2fd63da4864afb01bff859f4e1fbe9576 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Fri, 5 Jun 2015 15:24:05 -0700 Subject: Support commenting on a diff in side-by-side view Closes https://github.com/gitlabhq/gitlabhq/issues/9283 --- app/views/projects/commit/show.html.haml | 2 +- app/views/projects/diffs/_parallel_view.html.haml | 6 +++- .../_diff_notes_with_reply_parallel.html.haml | 32 +++++++++++----------- app/views/projects/notes/_form.html.haml | 2 ++ .../projects/notes/_notes_with_form.html.haml | 4 +-- 5 files changed, 26 insertions(+), 20 deletions(-) (limited to 'app/views') diff --git a/app/views/projects/commit/show.html.haml b/app/views/projects/commit/show.html.haml index fc91f71e8d2..60b112e67d4 100644 --- a/app/views/projects/commit/show.html.haml +++ b/app/views/projects/commit/show.html.haml @@ -1,4 +1,4 @@ - page_title "#{@commit.title} (#{@commit.short_id})", "Commits" = render "commit_box" = render "projects/diffs/diffs", diffs: @diffs, project: @project -= render "projects/notes/notes_with_form" += render "projects/notes/notes_with_form", view: params[:view] diff --git a/app/views/projects/diffs/_parallel_view.html.haml b/app/views/projects/diffs/_parallel_view.html.haml index 75f3a80f0d7..cb41dd852d3 100644 --- a/app/views/projects/diffs/_parallel_view.html.haml +++ b/app/views/projects/diffs/_parallel_view.html.haml @@ -18,6 +18,8 @@ - elsif type_left == 'old' || type_left.nil? %td.old_line{id: line_code_left, class: "#{type_left}"} = link_to raw(line_number_left), "##{line_code_left}", id: line_code_left + - if @comments_allowed && can?(current_user, :write_note, @project) + = link_to_new_diff_note(line_code_left, 'old') %td.line_content{class: "parallel noteable_line #{type_left} #{line_code_left}", "line_code" => line_code_left }= raw line_content_left - if type_right == 'new' @@ -29,12 +31,14 @@ %td.new_line{id: new_line_code, class: "#{new_line_class}", data: { linenumber: line_number_right }} = link_to raw(line_number_right), "##{new_line_code}", id: new_line_code + - if @comments_allowed && can?(current_user, :write_note, @project) + = link_to_new_diff_note(line_code_right, 'new') %td.line_content.parallel{class: "noteable_line #{new_line_class} #{new_line_code}", "line_code" => new_line_code}= raw line_content_right - if @reply_allowed - comments_left, comments_right = organize_comments(type_left, type_right, line_code_left, line_code_right) - if comments_left.present? || comments_right.present? - = render "projects/notes/diff_notes_with_reply_parallel", notes1: comments_left, notes2: comments_right + = render "projects/notes/diff_notes_with_reply_parallel", notes_left: comments_left, notes_right: comments_right - if diff_file.diff.diff.blank? && diff_file.mode_changed? .file-mode-changed diff --git a/app/views/projects/notes/_diff_notes_with_reply_parallel.html.haml b/app/views/projects/notes/_diff_notes_with_reply_parallel.html.haml index 789f3e19fd2..c6726cbafa3 100644 --- a/app/views/projects/notes/_diff_notes_with_reply_parallel.html.haml +++ b/app/views/projects/notes/_diff_notes_with_reply_parallel.html.haml @@ -1,34 +1,34 @@ -- note1 = notes1.present? ? notes1.first : nil -- note2 = notes2.present? ? notes2.first : nil +- note1 = notes_left.present? ? notes_left.first : nil +- note2 = notes_right.present? ? notes_right.first : nil %tr.notes_holder - if note1 - %td.notes_line + %td.notes_line.old %span.btn.disabled %i.fa.fa-comment - = notes1.count - %td.notes_content.parallel + = notes_left.count + %td.notes_content.parallel.old %ul.notes{ rel: note1.discussion_id } - = render notes1 + = render notes_left .discussion-reply-holder - = link_to_reply_diff(note1) + = link_to_reply_diff(note1, 'old') - else - %td= "" - %td= "" + %td.notes_line.old= "" + %td.notes_content.parallel.old= "" - if note2 - %td.notes_line + %td.notes_line.new %span.btn.disabled %i.fa.fa-comment - = notes2.count - %td.notes_content.parallel + = notes_right.count + %td.notes_content.parallel.new %ul.notes{ rel: note2.discussion_id } - = render notes2 + = render notes_right .discussion-reply-holder - = link_to_reply_diff(note2) + = link_to_reply_diff(note2, 'new') - else - %td= "" - %td= "" + %td.notes_line.new= "" + %td.notes_content.parallel.new= "" diff --git a/app/views/projects/notes/_form.html.haml b/app/views/projects/notes/_form.html.haml index f28b3e9b508..3fb044d736e 100644 --- a/app/views/projects/notes/_form.html.haml +++ b/app/views/projects/notes/_form.html.haml @@ -1,4 +1,6 @@ = form_for [@project.namespace.becomes(Namespace), @project, @note], remote: true, html: { :'data-type' => 'json', multipart: true, id: nil, class: "new_note js-new-note-form common-note-form gfm-form" }, authenticity_token: true do |f| + = hidden_field_tag :view, params[:view] + = hidden_field_tag :line_type = note_target_fields(@note) = f.hidden_field :commit_id = f.hidden_field :line_code diff --git a/app/views/projects/notes/_notes_with_form.html.haml b/app/views/projects/notes/_notes_with_form.html.haml index 813e37276bd..a202e74a892 100644 --- a/app/views/projects/notes/_notes_with_form.html.haml +++ b/app/views/projects/notes/_notes_with_form.html.haml @@ -4,7 +4,7 @@ .js-main-target-form - if can? current_user, :write_note, @project - = render "projects/notes/form" + = render "projects/notes/form", view: params[:view] :javascript - new Notes("#{namespace_project_notes_path(namespace_id: @project.namespace, target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, #{Time.now.to_i}) + new Notes("#{namespace_project_notes_path(namespace_id: @project.namespace, target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, #{Time.now.to_i}, "#{params[:view]}") -- cgit v1.2.1