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/finders/work_items/namespace_work_items_finder.rb')
-rw-r--r--app/finders/work_items/namespace_work_items_finder.rb27
1 files changed, 20 insertions, 7 deletions
diff --git a/app/finders/work_items/namespace_work_items_finder.rb b/app/finders/work_items/namespace_work_items_finder.rb
index aad99d710b6..da6437e0907 100644
--- a/app/finders/work_items/namespace_work_items_finder.rb
+++ b/app/finders/work_items/namespace_work_items_finder.rb
@@ -2,19 +2,14 @@
module WorkItems
class NamespaceWorkItemsFinder < WorkItemsFinder
+ FilterNotAvailableError = Class.new(ArgumentError)
+
def initialize(...)
super
self.parent_param = namespace
end
- def execute
- items = init_collection
- items = by_namespace(items)
-
- sort(items)
- end
-
override :with_confidentiality_access_check
def with_confidentiality_access_check
return model_class.all if params.user_can_see_all_issuables?
@@ -31,6 +26,12 @@ module WorkItems
private
+ def filter_items(items)
+ items = super(items)
+
+ by_namespace(items)
+ end
+
def by_namespace(items)
if namespace.blank? || !Ability.allowed?(current_user, "read_#{namespace.to_ability_name}".to_sym, namespace)
return klass.none
@@ -39,11 +40,23 @@ module WorkItems
items.in_namespaces(namespace)
end
+ override :by_search
+ def by_search(items)
+ return items unless search
+
+ raise FilterNotAvailableError, 'Searching is not available for work items at the namespace level yet'
+ end
+
def namespace
return if params[:namespace_id].blank?
params[:namespace_id].is_a?(Namespace) ? params[:namespace_id] : Namespace.find_by_id(params[:namespace_id])
end
strong_memoize_attr :namespace
+
+ override :by_project
+ def by_project(items)
+ items
+ end
end
end