Commit 53de19c5 authored by Yorick Peterse's avatar Yorick Peterse

Backport API::Issues parameters from EE

This backports the parameters that EE adds to API::Issues, and wraps
them in conditionals so they are only used in EE.
parent d7ac448a
# frozen_string_literal: true
module EE
module API
module Helpers
module IssuesHelpers
extend ActiveSupport::Concern
class_methods do
extend ::Gitlab::Utils::Override
override :update_params_at_least_one_of
def update_params_at_least_one_of
[*super, :weight]
end
end
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Issues
extend ActiveSupport::Concern
prepended do
helpers do
params :issues_params_ee do
optional :weight, types: [Integer, String], integer_none_any: true, desc: 'The weight of the issue'
end
params :issue_params_ee do
optional :weight, type: Integer, desc: 'The weight of the issue'
end
end
end
end
end
end
# frozen_string_literal: true
module API
module Helpers
module IssuesHelpers
def self.update_params_at_least_one_of
[
:assignee_id,
:assignee_ids,
:confidential,
:created_at,
:description,
:discussion_locked,
:due_date,
:labels,
:milestone_id,
:state_event,
:title
]
end
end
end
end
API::Helpers::IssuesHelpers.prepend(EE::API::Helpers::IssuesHelpers)
......@@ -8,17 +8,6 @@ module API
helpers ::Gitlab::IssuableMetadata
# EE::API::Issues would override the following helpers
helpers do
params :issues_params_ee do
end
params :issue_params_ee do
end
end
prepend EE::API::Issues # rubocop: disable Cop/InjectEnterpriseEditionModule
helpers do
# rubocop: disable CodeReuse/ActiveRecord
def find_issues(args = {})
......@@ -35,6 +24,16 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
if Gitlab.ee?
params :issues_params_ee do
optional :weight, types: [Integer, String], integer_none_any: true, desc: 'The weight of the issue'
end
params :issue_params_ee do
optional :weight, type: Integer, desc: 'The weight of the issue'
end
end
params :issues_params do
optional :labels, type: Array[String], coerce_with: Validations::Types::LabelsList.coerce, desc: 'Comma-separated list of label names'
optional :milestone, type: String, desc: 'Milestone title'
......@@ -59,7 +58,7 @@ module API
optional :confidential, type: Boolean, desc: 'Filter confidential or public issues'
use :pagination
use :issues_params_ee
use :issues_params_ee if Gitlab.ee?
end
params :issue_params do
......@@ -72,7 +71,7 @@ module API
optional :confidential, type: Boolean, desc: 'Boolean parameter if the issue should be confidential'
optional :discussion_locked, type: Boolean, desc: " Boolean parameter indicating if the issue's discussion is locked"
use :issue_params_ee
use :issue_params_ee if Gitlab.ee?
end
end
......@@ -221,9 +220,8 @@ module API
desc: 'Date time when the issue was updated. Available only for admins and project owners.'
optional :state_event, type: String, values: %w[reopen close], desc: 'State of the issue'
use :issue_params
at_least_one_of :title, :description, :assignee_ids, :assignee_id, :milestone_id,
:labels, :created_at, :due_date, :confidential, :state_event,
:weight, :discussion_locked
at_least_one_of(*Helpers::IssuesHelpers.update_params_at_least_one_of)
end
# rubocop: disable CodeReuse/ActiveRecord
put ':id/issues/:issue_iid' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment