2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
# A discussion on merge request or commit diffs consisting of `DiffNote` notes.
|
|
|
|
#
|
|
|
|
# A discussion of this type can be resolvable.
|
|
|
|
class DiffDiscussion < Discussion
|
|
|
|
include DiscussionOnDiff
|
|
|
|
|
|
|
|
def self.note_class
|
|
|
|
DiffNote
|
|
|
|
end
|
|
|
|
|
|
|
|
delegate :position,
|
|
|
|
:original_position,
|
2017-09-10 17:25:29 +05:30
|
|
|
:change_position,
|
2020-04-22 19:07:51 +05:30
|
|
|
:diff_note_positions,
|
2018-03-17 18:26:18 +05:30
|
|
|
:on_text?,
|
|
|
|
:on_image?,
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
to: :first_note
|
|
|
|
|
|
|
|
def legacy_diff_discussion?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def merge_request_version_params
|
|
|
|
return unless for_merge_request?
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
version_params = get_params
|
|
|
|
|
|
|
|
return version_params unless on_merge_request_commit? && commit_id
|
|
|
|
|
|
|
|
version_params ||= {}
|
|
|
|
version_params.tap do |params|
|
|
|
|
params[:commit_id] = commit_id
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def reply_attributes
|
|
|
|
super.merge(
|
|
|
|
original_position: original_position.to_json,
|
2017-09-10 17:25:29 +05:30
|
|
|
position: position.to_json
|
2017-08-17 22:00:37 +05:30
|
|
|
)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def get_params
|
|
|
|
return {} if active?
|
|
|
|
|
|
|
|
noteable.version_params_for(position.diff_refs)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|