Commit 2a7da96a authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'toggle_diff_comments' of...

Merge branch 'toggle_diff_comments' of https://github.com/jacob-carlborg/gitlabhq into jacob-carlborg-toggle_diff_comments
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

Conflicts:
	app/assets/stylesheets/sections/commits.scss
	app/assets/stylesheets/sections/notes.scss
	app/views/projects/commits/_diffs.html.haml
	features/steps/project/merge_requests.rb
parents c8e1c53f 2d554f42
...@@ -189,7 +189,6 @@ ul.notes { ...@@ -189,7 +189,6 @@ ul.notes {
} }
/** /**
* Line note button on the side of diffs * Line note button on the side of diffs
*/ */
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
- file = project.repository.blob_at(@commit.id, diff.new_path) - file = project.repository.blob_at(@commit.id, diff.new_path)
- file = project.repository.blob_at(@commit.parent_id, diff.old_path) unless file - file = project.repository.blob_at(@commit.parent_id, diff.old_path) unless file
- next unless file - next unless file
.diff-file{id: "diff-#{i}"} .diff-file.js-toggle-container{id: "diff-#{i}"}
.diff-header{id: "file-path-#{hexdigest(diff.new_path || diff.old_path)}"} .diff-header{id: "file-path-#{hexdigest(diff.new_path || diff.old_path)}"}
- if diff.deleted_file - if diff.deleted_file
%span= diff.old_path %span= diff.old_path
...@@ -60,6 +60,11 @@ ...@@ -60,6 +60,11 @@
%span.file-mode= "#{diff.a_mode}#{diff.b_mode}" %span.file-mode= "#{diff.a_mode}#{diff.b_mode}"
.diff-btn-group .diff-btn-group
= link_to "#", class: "js-toggle-button btn btn-small" do
%i.icon-chevron-down
Diff comments
&nbsp;
- if @merge_request && @merge_request.source_project - if @merge_request && @merge_request.source_project
= link_to project_edit_tree_path(@merge_request.source_project, tree_join(@merge_request.source_branch, diff.new_path), from_merge_request_id: @merge_request.id), { class: 'btn btn-small' } do = link_to project_edit_tree_path(@merge_request.source_project, tree_join(@merge_request.source_branch, diff.new_path), from_merge_request_id: @merge_request.id), { class: 'btn btn-small' } do
Edit Edit
......
- note = notes.first # example note - note = notes.first # example note
-# Check if line want not changed since comment was left -# Check if line want not changed since comment was left
- if !defined?(line) || line == note.diff_line - if !defined?(line) || line == note.diff_line
%tr.notes_holder %tr.notes_holder.js-toggle-content
%td.notes_line{ colspan: 2 } %td.notes_line{ colspan: 2 }
%span.btn.disabled %span.btn.disabled
%i.icon-comment %i.icon-comment
......
- note1 = notes1.first # example note - note1 = notes1.first # example note
- note2 = notes2.first # example note - note2 = notes2.first # example note
%tr.notes_holder %tr.notes_holder.js-toggle-content
-# Check if line want not changed since comment was left -# Check if line want not changed since comment was left
/- if !defined?(line1) || line1 == note1.diff_line /- if !defined?(line1) || line1 == note1.diff_line
- if note1 - if note1
......
...@@ -95,3 +95,47 @@ Feature: Project Merge Requests ...@@ -95,3 +95,47 @@ Feature: Project Merge Requests
Given I visit merge request page "Bug NS-04" Given I visit merge request page "Bug NS-04"
And I leave a comment with a header containing "Comment with a header" And I leave a comment with a header containing "Comment with a header"
Then The comment with the header should not have an ID Then The comment with the header should not have an ID
# Toggling inline comments
@javascript
Scenario: I hide comments on a merge request diff with comments in a single file
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
And I visit merge request page "Bug NS-05"
And I switch to the diff tab
And I leave a comment like "Line is wrong" on line 39 of the second file
And I click link "Hide inline discussion" of the second file
Then I should not see a comment like "Line is wrong" in the second file
@javascript
Scenario: I show comments on a merge request diff with comments in a single file
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
And I visit merge request page "Bug NS-05"
And I switch to the diff tab
And I leave a comment like "Line is wrong" on line 39 of the second file
And I click link "Hide inline discussion" of the second file
And I click link "Show inline discussion" of the second file
Then I should see a comment like "Line is wrong" in the second file
@javascript
Scenario: I hide comments on a merge request diff with comments in multiple files
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
And I visit merge request page "Bug NS-05"
And I switch to the diff tab
And I leave a comment like "Line is correct" on line 12 of the first file
And I leave a comment like "Line is wrong" on line 39 of the second file
And I click link "Hide inline discussion" of the second file
Then I should not see a comment like "Line is wrong" in the second file
And I should still see a comment like "Line is correct" in the first file
@javascript
Scenario: I show comments on a merge request diff with comments in multiple files
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
And I visit merge request page "Bug NS-05"
And I switch to the diff tab
And I leave a comment like "Line is correct" on line 12 of the first file
And I leave a comment like "Line is wrong" on line 39 of the second file
And I click link "Hide inline discussion" of the second file
And I click link "Show inline discussion" of the second file
Then I should see a comment like "Line is wrong" in the second file
And I should still see a comment like "Line is correct" in the first file
...@@ -182,6 +182,62 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -182,6 +182,62 @@ class ProjectMergeRequests < Spinach::FeatureSteps
end end
end end
step 'I click link "Hide inline discussion" of the second file' do
within '.files [id^=diff]:nth-child(2)' do
click_link "Diff comments"
end
end
step 'I click link "Show inline discussion" of the second file' do
within '.files [id^=diff]:nth-child(2)' do
click_link "Diff comments"
end
end
step 'I should not see a comment like "Line is wrong" in the second file' do
within '.files [id^=diff]:nth-child(2)' do
page.should_not have_visible_content "Line is wrong"
end
end
step 'I should see a comment like "Line is wrong" in the second file' do
within '.files [id^=diff]:nth-child(2) .note-text' do
page.should have_visible_content "Line is wrong"
end
end
step 'I leave a comment like "Line is correct" on line 12 of the first file' do
init_diff_note_first_file
within(".js-discussion-note-form") do
fill_in "note_note", with: "Line is correct"
click_button "Add Comment"
end
within ".files [id^=diff]:nth-child(1) .note-text" do
page.should have_content "Line is correct"
end
end
step 'I leave a comment like "Line is wrong" on line 39 of the second file' do
init_diff_note_second_file
within(".js-discussion-note-form") do
fill_in "note_note", with: "Line is wrong"
click_button "Add Comment"
end
within ".files [id^=diff]:nth-child(2) .note-text" do
page.should have_content "Line is wrong"
end
end
step 'I should still see a comment like "Line is correct" in the first file' do
within '.files [id^=diff]:nth-child(1) .note-text' do
page.should have_visible_content "Line is correct"
end
end
def project def project
@project ||= Project.find_by!(name: "Shop") @project ||= Project.find_by!(name: "Shop")
end end
...@@ -204,4 +260,16 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -204,4 +260,16 @@ class ProjectMergeRequests < Spinach::FeatureSteps
page.should have_content message page.should have_content message
end end
end end
def init_diff_note_first_file
find('a[data-line-code="a5cc2925ca8258af241be7e5b0381edf30266302_12_12"]').click
end
def init_diff_note_second_file
find('a[data-line-code="8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_28_39"]').click
end
def have_visible_content (text)
have_css("*", text: text, visible: true)
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment