2017-04-04 18:27:23 -04:00
|
|
|
# A discussion on merge request or commit diffs consisting of `DiffNote` notes.
|
2017-04-06 11:05:57 -04:00
|
|
|
#
|
|
|
|
# A discussion of this type can be resolvable.
|
2017-03-09 20:29:11 -05:00
|
|
|
class DiffDiscussion < Discussion
|
2017-03-30 20:38:21 -04:00
|
|
|
include DiscussionOnDiff
|
2017-03-09 20:29:11 -05:00
|
|
|
|
2017-04-06 11:05:57 -04:00
|
|
|
def self.note_class
|
|
|
|
DiffNote
|
|
|
|
end
|
|
|
|
|
2017-03-30 20:38:21 -04:00
|
|
|
delegate :position,
|
|
|
|
:original_position,
|
2017-03-09 20:29:11 -05:00
|
|
|
|
|
|
|
to: :first_note
|
|
|
|
|
|
|
|
def legacy_diff_discussion?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2017-04-30 16:32:09 -04:00
|
|
|
def merge_request_version_params
|
|
|
|
return unless for_merge_request?
|
|
|
|
|
|
|
|
if active?
|
|
|
|
{}
|
|
|
|
else
|
|
|
|
diff_refs = position.diff_refs
|
|
|
|
|
|
|
|
if diff = noteable.merge_request_diff_for(diff_refs)
|
|
|
|
{ diff_id: diff.id }
|
|
|
|
elsif diff = noteable.merge_request_diff_for(diff_refs.head_sha)
|
|
|
|
{
|
|
|
|
diff_id: diff.id,
|
|
|
|
start_sha: diff_refs.start_sha
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-09 20:29:11 -05:00
|
|
|
def reply_attributes
|
2017-03-30 20:38:21 -04:00
|
|
|
super.merge(
|
|
|
|
original_position: original_position.to_json,
|
|
|
|
position: position.to_json,
|
|
|
|
)
|
2017-03-09 20:29:11 -05:00
|
|
|
end
|
|
|
|
end
|