Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/work_item.rb')
-rw-r--r--app/models/work_item.rb37
1 files changed, 35 insertions, 2 deletions
diff --git a/app/models/work_item.rb b/app/models/work_item.rb
index f94e831437a..5ae3fb6cf78 100644
--- a/app/models/work_item.rb
+++ b/app/models/work_item.rb
@@ -3,6 +3,10 @@
class WorkItem < Issue
include Gitlab::Utils::StrongMemoize
+ COMMON_QUICK_ACTIONS_COMMANDS = [
+ :title, :reopen, :close, :cc, :tableflip, :shrug
+ ].freeze
+
self.table_name = 'issues'
self.inheritance_column = :_type_disabled
@@ -13,11 +17,14 @@ class WorkItem < Issue
has_many :child_links, class_name: '::WorkItems::ParentLink', foreign_key: :work_item_parent_id
has_many :work_item_children, through: :child_links, class_name: 'WorkItem',
foreign_key: :work_item_id, source: :work_item
- has_many :work_item_children_by_created_at, -> { order(:created_at) }, through: :child_links, class_name: 'WorkItem',
- foreign_key: :work_item_id, source: :work_item
+ has_many :work_item_children_by_relative_position, -> { work_item_children_keyset_order },
+ through: :child_links, class_name: 'WorkItem',
+ foreign_key: :work_item_id, source: :work_item
scope :inc_relations_for_permission_check, -> { includes(:author, project: :project_feature) }
+ delegate :supports_assignee?, to: :work_item_type
+
class << self
def assignee_association_name
'issue'
@@ -26,6 +33,26 @@ class WorkItem < Issue
def test_reports_join_column
'issues.id'
end
+
+ def work_item_children_keyset_order
+ keyset_order = Gitlab::Pagination::Keyset::Order.build([
+ Gitlab::Pagination::Keyset::ColumnOrderDefinition.new(
+ attribute_name: :relative_position,
+ column_expression: WorkItems::ParentLink.arel_table[:relative_position],
+ order_expression: WorkItems::ParentLink.arel_table[:relative_position].asc.nulls_last,
+ nullable: :nulls_last,
+ distinct: false
+ ),
+ Gitlab::Pagination::Keyset::ColumnOrderDefinition.new(
+ attribute_name: :created_at,
+ order_expression: WorkItem.arel_table[:created_at].asc,
+ nullable: :not_nullable,
+ distinct: false
+ )
+ ])
+
+ includes(:child_links).order(keyset_order)
+ end
end
def noteable_target_type_name
@@ -52,6 +79,12 @@ class WorkItem < Issue
hierarchy(same_type: true).max_descendants_depth.to_i
end
+ def supported_quick_action_commands
+ commands_for_widgets = work_item_type.widgets.flat_map(&:quick_action_commands).uniq
+
+ COMMON_QUICK_ACTIONS_COMMANDS + commands_for_widgets
+ end
+
private
override :parent_link_confidentiality