Class: WorkItems::Type
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- WorkItems::Type
- Includes:
- CacheMarkdownField
- Defined in:
- app/models/work_items/type.rb
Constant Summary collapse
- TYPE_NAMES =
type name is used in restrictions DB seeder to assure restrictions for default types are pre-filled
{ issue: 'Issue', incident: 'Incident', test_case: 'Test Case', requirement: 'Requirement', task: 'Task', objective: 'Objective', key_result: 'Key Result', epic: 'Epic', ticket: 'Ticket' }.freeze
- BASE_TYPES =
Base types need to exist on the DB on app startup This constant is used by the DB seeder TODO - where to add new icon names created?
{ issue: { name: TYPE_NAMES[:issue], icon_name: 'issue-type-issue', enum_value: 0 }, incident: { name: TYPE_NAMES[:incident], icon_name: 'issue-type-incident', enum_value: 1 }, test_case: { name: TYPE_NAMES[:test_case], icon_name: 'issue-type-test-case', enum_value: 2 }, ## EE-only requirement: { name: TYPE_NAMES[:requirement], icon_name: 'issue-type-requirements', enum_value: 3 }, ## EE-only task: { name: TYPE_NAMES[:task], icon_name: 'issue-type-task', enum_value: 4 }, objective: { name: TYPE_NAMES[:objective], icon_name: 'issue-type-objective', enum_value: 5 }, ## EE-only key_result: { name: TYPE_NAMES[:key_result], icon_name: 'issue-type-keyresult', enum_value: 6 }, ## EE-only epic: { name: TYPE_NAMES[:epic], icon_name: 'issue-type-epic', enum_value: 7 }, ## EE-only ticket: { name: TYPE_NAMES[:ticket], icon_name: 'issue-type-issue', enum_value: 8 } }.freeze
- CHANGEABLE_BASE_TYPES =
A list of types user can change between - both original and new type must be included in this list. This is needed for legacy issues where it’s possible to switch between issue and incident.
%w[issue incident test_case].freeze
Constants included from CacheMarkdownField
CacheMarkdownField::INVALIDATED_BY
Constants inherited from ApplicationRecord
Constants included from ResetOnUnionError
ResetOnUnionError::MAX_RESET_PERIOD
Instance Attribute Summary
Attributes included from CacheMarkdownField
#skip_markdown_cache_validation
Class Method Summary collapse
Instance Method Summary collapse
Methods included from CacheMarkdownField
#attribute_invalidated?, #banzai_render_context, #cached_html_for, #cached_html_up_to_date?, #can_cache_field?, #invalidated_markdown_cache?, #latest_cached_markdown_version, #local_version, #mentionable_attributes_changed?, #mentioned_filtered_user_ids_for, #parent_user, #refresh_markdown_cache, #refresh_markdown_cache!, #rendered_field_content, #skip_project_check?, #store_mentions!, #updated_cached_html_for
Methods inherited from ApplicationRecord
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
Methods included from SensitiveSerializableHash
Class Method Details
.allowed_types_for_issues ⇒ Object
83 84 85 |
# File 'app/models/work_items/type.rb', line 83 def self.allowed_types_for_issues base_types.keys.excluding('task', 'objective', 'key_result', 'epic', 'ticket') end |
.default_by_type(type) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'app/models/work_items/type.rb', line 70 def self.default_by_type(type) found_type = find_by(namespace_id: nil, base_type: type) return found_type if found_type Gitlab::DatabaseImporters::WorkItems::BaseTypeImporter.upsert_types Gitlab::DatabaseImporters::WorkItems::HierarchyRestrictionsImporter.upsert_restrictions find_by(namespace_id: nil, base_type: type) end |
.default_issue_type ⇒ Object
79 80 81 |
# File 'app/models/work_items/type.rb', line 79 def self.default_issue_type default_by_type(:issue) end |
Instance Method Details
#default? ⇒ Boolean
87 88 89 |
# File 'app/models/work_items/type.rb', line 87 def default? namespace.blank? end |
#default_issue? ⇒ Boolean
99 100 101 |
# File 'app/models/work_items/type.rb', line 99 def default_issue? name == WorkItems::Type::TYPE_NAMES[:issue] end |
#supports_assignee? ⇒ Boolean
95 96 97 |
# File 'app/models/work_items/type.rb', line 95 def supports_assignee? .include? ::WorkItems::Widgets::Assignees end |
#widgets ⇒ Object
91 92 93 |
# File 'app/models/work_items/type.rb', line 91 def .filter_map(&:widget_class) end |