blob: aad99d710b653dd1a061237d922f4585b1c982c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# frozen_string_literal: true
module WorkItems
class NamespaceWorkItemsFinder < WorkItemsFinder
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?
# Only admins can see hidden issues, so for non-admins, we filter out any hidden issues
issues = model_class.without_hidden
return issues.all if params.user_can_see_all_confidential_issues?
return issues.public_only if params.user_cannot_see_confidential_issues?
issues.with_confidentiality_check(current_user)
end
private
def by_namespace(items)
if namespace.blank? || !Ability.allowed?(current_user, "read_#{namespace.to_ability_name}".to_sym, namespace)
return klass.none
end
items.in_namespaces(namespace)
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
end
end
|