gitlab-org--gitlab-foss/app/models/system_note_metadata.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
1.5 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
class SystemNoteMetadata < ApplicationRecord
include Importable
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
closed duplicate
2019-08-12 12:07:15 +00:00
moved merge
label milestone
relate unrelate
cloned
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[
commit description merge confidential visible label assignee cross_reference
designs_added designs_modified designs_removed designs_discussion_added
title time_tracking branch milestone discussion task moved cloned
opened closed merged duplicate locked unlocked outdated reviewer
tag due_date start_date_or_due_date pinned_embed cherry_pick health_status approved unapproved
status alert_issue_added relate unrelate new_alert_added severity
attention_requested attention_request_removed contact timeline_event
issue_type relate_to_child unrelate_from_child relate_to_parent unrelate_from_parent
2017-03-15 13:18:44 +00:00
].freeze
validates :note, presence: true, unless: :importing?
validates :action, inclusion: { in: :icon_types }, allow_nil: true
2017-03-15 13:18:44 +00:00
belongs_to :note
belongs_to :description_version
def icon_types
ICON_TYPES
end
def cross_reference_types
TYPES_WITH_CROSS_REFERENCES
end
2017-03-15 13:18:44 +00:00
end
SystemNoteMetadata.prepend_mod_with('SystemNoteMetadata')