From 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 18 Jun 2020 11:18:50 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-1-stable-ee --- app/models/note.rb | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'app/models/note.rb') diff --git a/app/models/note.rb b/app/models/note.rb index d174ba8fe83..6b6a7c50b00 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -72,6 +72,7 @@ class Note < ApplicationRecord belongs_to :author, class_name: "User" belongs_to :updated_by, class_name: "User" belongs_to :last_edited_by, class_name: 'User' + belongs_to :review, inverse_of: :notes has_many :todos @@ -273,6 +274,10 @@ class Note < ApplicationRecord noteable_type == "Snippet" end + def for_alert_mangement_alert? + noteable_type == 'AlertManagement::Alert' + end + def for_personal_snippet? noteable.is_a?(PersonalSnippet) end @@ -350,8 +355,10 @@ class Note < ApplicationRecord self.special_role = Note::SpecialRole::FIRST_TIME_CONTRIBUTOR end - def confidential? - confidential || noteable.try(:confidential?) + def confidential?(include_noteable: false) + return true if confidential + + include_noteable && noteable.try(:confidential?) end def editable? @@ -393,7 +400,13 @@ class Note < ApplicationRecord end def noteable_ability_name - for_snippet? ? 'snippet' : noteable_type.demodulize.underscore + if for_snippet? + 'snippet' + elsif for_alert_mangement_alert? + 'alert_management_alert' + else + noteable_type.demodulize.underscore + end end def can_be_discussion_note? @@ -520,7 +533,7 @@ class Note < ApplicationRecord end def banzai_render_context(field) - super.merge(noteable: noteable, system_note: system?) + super.merge(noteable: noteable, system_note: system?, label_url_method: noteable_label_url_method) end def retrieve_upload(_identifier, paths) @@ -603,6 +616,10 @@ class Note < ApplicationRecord errors.add(:base, _('Maximum number of comments exceeded')) if noteable.notes.count >= Noteable::MAX_NOTES_LIMIT end + + def noteable_label_url_method + for_merge_request? ? :project_merge_requests_url : :project_issues_url + end end Note.prepend_if_ee('EE::Note') -- cgit v1.2.3