Commit 1817f877 authored by Douwe Maan's avatar Douwe Maan

Some code tweaks

parent a8339fe1
...@@ -576,13 +576,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -576,13 +576,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@comparable_diffs = @merge_request_diffs.select { |diff| diff.id < @merge_request_diff.id } @comparable_diffs = @merge_request_diffs.select { |diff| diff.id < @merge_request_diff.id }
if params[:start_sha].present? if params[:start_sha].present?
@start_sha = params[:start_sha] start_sha = params[:start_sha]
@start_version = @comparable_diffs.find { |diff| diff.head_commit_sha == @start_sha } @start_version = @comparable_diffs.find { |diff| diff.head_commit_sha == start_sha }
unless @start_version @start_sha = start_sha if @start_version
@start_sha = @merge_request_diff.head_commit_sha
@start_version = @merge_request_diff
end
end end
@diffs = @diffs =
......
...@@ -5,8 +5,6 @@ module DiscussionOnDiff ...@@ -5,8 +5,6 @@ module DiscussionOnDiff
included do included do
NUMBER_OF_TRUNCATED_DIFF_LINES = 16 NUMBER_OF_TRUNCATED_DIFF_LINES = 16
memoized_values << :active
delegate :line_code, delegate :line_code,
:original_line_code, :original_line_code,
:diff_file, :diff_file,
...@@ -29,12 +27,6 @@ module DiscussionOnDiff ...@@ -29,12 +27,6 @@ module DiscussionOnDiff
true true
end end
def active?
return @active if @active.present?
@active = first_note.active?
end
# Returns an array of at most 16 highlighted lines above a diff note # Returns an array of at most 16 highlighted lines above a diff note
def truncated_diff_lines(highlight: true) def truncated_diff_lines(highlight: true)
lines = highlight ? highlighted_diff_lines : diff_lines lines = highlight ? highlighted_diff_lines : diff_lines
......
...@@ -26,6 +26,10 @@ module NoteOnDiff ...@@ -26,6 +26,10 @@ module NoteOnDiff
raise NotImplementedError raise NotImplementedError
end end
def active?(diff_refs = nil)
raise NotImplementedError
end
private private
def noteable_diff_refs def noteable_diff_refs
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
class LegacyDiffDiscussion < Discussion class LegacyDiffDiscussion < Discussion
include DiscussionOnDiff include DiscussionOnDiff
memoized_values << :active
def legacy_diff_discussion? def legacy_diff_discussion?
true true
end end
...@@ -15,6 +17,12 @@ class LegacyDiffDiscussion < Discussion ...@@ -15,6 +17,12 @@ class LegacyDiffDiscussion < Discussion
LegacyDiffNote LegacyDiffNote
end end
def active?(*args)
return @active if @active.present?
@active = first_note.active?(*args)
end
def collapsed? def collapsed?
!active? !active?
end end
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
- else - else
a deleted commit a deleted commit
- elsif discussion.diff_discussion? - elsif discussion.diff_discussion?
on
= conditional_link_to url.present?, url do = conditional_link_to url.present?, url do
- if discussion.active? - if discussion.active?
the diff the diff
......
...@@ -72,13 +72,14 @@ ...@@ -72,13 +72,14 @@
= link_to namespace_project_compare_path(@project.namespace, @project, from: @start_version.base_commit_sha, to: @merge_request_diff.base_commit_sha) do = link_to namespace_project_compare_path(@project.namespace, @project, from: @start_version.base_commit_sha, to: @merge_request_diff.base_commit_sha) do
new commits new commits
from from
= succeed '.' do
%code= @merge_request.target_branch %code= @merge_request.target_branch
- if @diff_notes_disabled - if @diff_notes_disabled
.comments-disabled-notif.content-block .comments-disabled-notif.content-block
= icon('info-circle') = icon('info-circle')
- if @start_sha - if @start_sha
Comment creation is disabled because you're comparing two versions of this merge request. Comments are disabled because you're comparing two versions of this merge request.
- else - else
Discussions on this old version of the merge request are displayed but comment creation is disabled. Discussions on this old version of the merge request are displayed but comment creation is disabled.
......
...@@ -66,7 +66,7 @@ feature 'Merge Request versions', js: true, feature: true do ...@@ -66,7 +66,7 @@ feature 'Merge Request versions', js: true, feature: true do
end end
it 'show the message about disabled comments' do it 'show the message about disabled comments' do
expect(page).to have_content 'Comment creation is disabled' expect(page).to have_content 'Comments are disabled'
end end
it 'show diff between new and old version' do it 'show diff between new and old version' do
......
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