2018-07-25 09:30:33 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-28 13:17:42 +00:00
|
|
|
class SystemNoteMetadata < ApplicationRecord
|
2017-11-16 14:23:32 +00:00
|
|
|
# These notes's action text might contain a reference that is external.
|
|
|
|
# We should always force a deep validation upon references that are found
|
|
|
|
# in this note type.
|
|
|
|
# Other notes can always be safely shown as all its references are
|
|
|
|
# in the same project (i.e. with the same permissions)
|
|
|
|
TYPES_WITH_CROSS_REFERENCES = %w[
|
2017-11-20 18:00:35 +00:00
|
|
|
commit cross_reference
|
|
|
|
close duplicate
|
2019-08-12 12:07:15 +00:00
|
|
|
moved merge
|
2019-09-20 13:23:21 +00:00
|
|
|
label milestone
|
2020-08-21 00:10:44 +00:00
|
|
|
relate unrelate
|
2017-11-16 16:03:15 +00:00
|
|
|
].freeze
|
2017-11-16 14:23:32 +00:00
|
|
|
|
2017-03-15 13:18:44 +00:00
|
|
|
ICON_TYPES = %w[
|
2017-04-28 23:54:37 +00:00
|
|
|
commit description merge confidential visible label assignee cross_reference
|
2020-05-07 12:09:46 +00:00
|
|
|
designs_added designs_modified designs_removed designs_discussion_added
|
2017-04-05 02:31:48 +00:00
|
|
|
title time_tracking branch milestone discussion task moved
|
2020-04-01 00:08:09 +00:00
|
|
|
opened closed merged duplicate locked unlocked outdated
|
2020-07-07 12:09:16 +00:00
|
|
|
tag due_date pinned_embed cherry_pick health_status approved unapproved
|
2020-08-27 18:10:29 +00:00
|
|
|
status alert_issue_added relate unrelate new_alert_added
|
2017-03-15 13:18:44 +00:00
|
|
|
].freeze
|
|
|
|
|
|
|
|
validates :note, presence: true
|
2018-05-02 21:34:05 +00:00
|
|
|
validates :action, inclusion: { in: :icon_types }, allow_nil: true
|
2017-03-15 13:18:44 +00:00
|
|
|
|
|
|
|
belongs_to :note
|
2019-10-18 11:11:44 +00:00
|
|
|
belongs_to :description_version
|
2018-05-02 21:34:05 +00:00
|
|
|
|
|
|
|
def icon_types
|
|
|
|
ICON_TYPES
|
|
|
|
end
|
2018-09-27 18:58:23 +00:00
|
|
|
|
|
|
|
def cross_reference_types
|
|
|
|
TYPES_WITH_CROSS_REFERENCES
|
|
|
|
end
|
2017-03-15 13:18:44 +00:00
|
|
|
end
|
2019-09-13 13:26:31 +00:00
|
|
|
|
|
|
|
SystemNoteMetadata.prepend_if_ee('EE::SystemNoteMetadata')
|