debian-mirror-gitlab/app/models/individual_note_discussion.rb

32 lines
835 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
# A discussion to wrap a single `Note` note on the root of an issue, merge request,
# commit, or snippet, that is not displayed as a discussion.
#
# A discussion of this type is never resolvable.
class IndividualNoteDiscussion < Discussion
def self.note_class
Note
end
def individual_note?
true
end
2019-03-02 22:35:43 +05:30
def can_convert_to_discussion?
2019-07-07 11:18:12 +05:30
noteable.supports_replying_to_individual_notes?
2019-03-02 22:35:43 +05:30
end
2019-07-07 11:18:12 +05:30
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-12-04 20:38:33 +05:30
# because of https://gitlab.com/gitlab-org/gitlab-foss/issues/57324
2019-07-07 11:18:12 +05:30
first_note.save if save
end
2019-03-02 22:35:43 +05:30
end
2017-08-17 22:00:37 +05:30
def reply_attributes
super.tap { |attrs| attrs.delete(:discussion_id) }
end
end