2018-07-25 09:30:33 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-31 03:06:09 +00:00
|
|
|
# A discussion to wrap a single `Note` note on the root of an issue, merge request,
|
2017-04-04 22:27:23 +00:00
|
|
|
# commit, or snippet, that is not displayed as a discussion.
|
2017-04-06 15:05:57 +00:00
|
|
|
#
|
|
|
|
# A discussion of this type is never resolvable.
|
2017-03-10 01:29:11 +00:00
|
|
|
class IndividualNoteDiscussion < Discussion
|
2017-04-06 15:05:57 +00:00
|
|
|
def self.note_class
|
|
|
|
Note
|
2017-03-10 01:29:11 +00:00
|
|
|
end
|
|
|
|
|
2017-03-17 19:25:52 +00:00
|
|
|
def individual_note?
|
2017-03-10 01:29:11 +00:00
|
|
|
true
|
|
|
|
end
|
2017-04-24 17:24:34 +00:00
|
|
|
|
2019-02-06 10:31:46 +00:00
|
|
|
def can_convert_to_discussion?
|
2019-04-03 02:00:18 +00:00
|
|
|
noteable.supports_replying_to_individual_notes?
|
2019-02-06 10:31:46 +00:00
|
|
|
end
|
|
|
|
|
2019-02-06 06:11:33 +00:00
|
|
|
def convert_to_discussion!(save: false)
|
|
|
|
first_note.becomes!(Discussion.note_class).to_discussion.tap do
|
|
|
|
# Save needs to be called on first_note instead of the transformed note
|
2019-09-18 14:02:45 +00:00
|
|
|
# because of https://gitlab.com/gitlab-org/gitlab-foss/issues/57324
|
2019-02-06 06:11:33 +00:00
|
|
|
first_note.save if save
|
|
|
|
end
|
2019-02-06 10:31:46 +00:00
|
|
|
end
|
|
|
|
|
2017-04-24 17:24:34 +00:00
|
|
|
def reply_attributes
|
|
|
|
super.tap { |attrs| attrs.delete(:discussion_id) }
|
|
|
|
end
|
2017-03-10 01:29:11 +00:00
|
|
|
end
|