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
path: root/lib
diff options
context:
space:
mode:
authorIgor <idrozdov@gitlab.com>2019-03-08 02:55:45 +0300
committerMike Greiling <mike@pixelcog.com>2019-03-08 02:55:45 +0300
commit9745d0de2ff605a03e7fbb95d0f71279bbd4afa5 (patch)
tree0d7f0f89b51199bf676988888539338086f419a3 /lib
parent90f4b6563d42ff7412de277682c0ecb7c25e41bb (diff)
Provide EE backports for filtering by approver feature
Adds custom validator for ArrayNoneAny param Extracts some logic in js into separate files
Diffstat (limited to 'lib')
-rw-r--r--lib/api/helpers/custom_validators.rb13
-rw-r--r--lib/api/merge_requests.rb5
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/api/helpers/custom_validators.rb b/lib/api/helpers/custom_validators.rb
index 1058f4e8a5e..c86eae6f2da 100644
--- a/lib/api/helpers/custom_validators.rb
+++ b/lib/api/helpers/custom_validators.rb
@@ -22,9 +22,22 @@ module API
message: "should be an integer, 'None' or 'Any'"
end
end
+
+ class ArrayNoneAny < Grape::Validations::Base
+ def validate_param!(attr_name, params)
+ value = params[attr_name]
+
+ return if value.is_a?(Array) ||
+ [IssuableFinder::FILTER_NONE, IssuableFinder::FILTER_ANY].include?(value.to_s.downcase)
+
+ raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)],
+ message: "should be an array, 'None' or 'Any'"
+ end
+ end
end
end
end
Grape::Validations.register_validator(:absence, ::API::Helpers::CustomValidators::Absence)
Grape::Validations.register_validator(:integer_none_any, ::API::Helpers::CustomValidators::IntegerNoneAny)
+Grape::Validations.register_validator(:array_none_any, ::API::Helpers::CustomValidators::ArrayNoneAny)
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb
index 123b7a83185..98dcc388f44 100644
--- a/lib/api/merge_requests.rb
+++ b/lib/api/merge_requests.rb
@@ -12,6 +12,9 @@ module API
helpers do
params :optional_params_ee do
end
+
+ params :optional_merge_requests_search_params do
+ end
end
def self.update_params_at_least_one_of
@@ -112,6 +115,8 @@ module API
optional :search, type: String, desc: 'Search merge requests for text present in the title, description, or any combination of these'
optional :in, type: String, desc: '`title`, `description`, or a string joining them with comma'
optional :wip, type: String, values: %w[yes no], desc: 'Search merge requests for WIP in the title'
+
+ use :optional_merge_requests_search_params
use :pagination
end
end