diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-08 15:08:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-08 15:08:46 +0300 |
commit | cdda3d117c99cadf295f26abc92cb2456033b762 (patch) | |
tree | 30315b1ea79ee4639f44a407978ed719c62a1653 /app/finders | |
parent | f4ea1f8998fd64bcd02280514b91f103f830d5ce (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/issuable_finder/params.rb | 4 | ||||
-rw-r--r-- | app/finders/issuables/label_filter.rb | 6 | ||||
-rw-r--r-- | app/finders/issues_finder.rb | 14 | ||||
-rw-r--r-- | app/finders/work_items/work_items_finder.rb | 19 |
4 files changed, 33 insertions, 10 deletions
diff --git a/app/finders/issuable_finder/params.rb b/app/finders/issuable_finder/params.rb index b0b5301f021..32d50802537 100644 --- a/app/finders/issuable_finder/params.rb +++ b/app/finders/issuable_finder/params.rb @@ -142,7 +142,7 @@ class IssuableFinder projects_public_or_visible_to_user end - projects.with_feature_available_for_user(klass, current_user).reorder(nil) # rubocop: disable CodeReuse/ActiveRecord + projects.with_feature_available_for_user(klass.base_class, current_user).reorder(nil) # rubocop: disable CodeReuse/ActiveRecord end end @@ -215,7 +215,7 @@ class IssuableFinder end def min_access_level - ProjectFeature.required_minimum_access_level(klass) + ProjectFeature.required_minimum_access_level(klass.base_class) end def method_missing(method_name, *args, &block) diff --git a/app/finders/issuables/label_filter.rb b/app/finders/issuables/label_filter.rb index 9a6ca107b19..4e9c964e51c 100644 --- a/app/finders/issuables/label_filter.rb +++ b/app/finders/issuables/label_filter.rb @@ -27,7 +27,7 @@ module Issuables def by_label(issuables) return issuables unless label_names_from_params.present? - target_model = issuables.model + target_model = issuables.base_class if filter_by_no_label? issuables.where(label_link_query(target_model).arel.exists.not) @@ -55,7 +55,7 @@ module Issuables # rubocop: disable CodeReuse/ActiveRecord def issuables_with_selected_labels(issuables, label_names) - target_model = issuables.model + target_model = issuables.base_class if root_namespace all_label_ids = find_label_ids(label_names) @@ -77,7 +77,7 @@ module Issuables # rubocop: disable CodeReuse/ActiveRecord def issuables_without_selected_labels(issuables, label_names) - target_model = issuables.model + target_model = issuables.base_class if root_namespace label_ids = find_label_ids(label_names).flatten(1) diff --git a/app/finders/issues_finder.rb b/app/finders/issues_finder.rb index 7929c36906d..663dda73a6a 100644 --- a/app/finders/issues_finder.rb +++ b/app/finders/issues_finder.rb @@ -37,7 +37,7 @@ class IssuesFinder < IssuableFinder # rubocop: disable CodeReuse/ActiveRecord def klass - Issue.includes(:author) + model_class.includes(:author) end # rubocop: enable CodeReuse/ActiveRecord @@ -47,10 +47,10 @@ class IssuesFinder < IssuableFinder # rubocop: disable CodeReuse/ActiveRecord def with_confidentiality_access_check - return Issue.all if params.user_can_see_all_issues? + return model_class.all if params.user_can_see_all_issues? # Only admins can see hidden issues, so for non-admins, we filter out any hidden issues - issues = Issue.without_hidden + issues = model_class.without_hidden return issues.all if params.user_can_see_all_confidential_issues? @@ -77,7 +77,7 @@ class IssuesFinder < IssuableFinder def init_collection if params.public_only? - Issue.public_only + model_class.public_only else with_confidentiality_access_check end @@ -129,7 +129,7 @@ class IssuesFinder < IssuableFinder def by_issue_types(items) issue_type_params = Array(params[:issue_types]).map(&:to_s) return items if issue_type_params.blank? - return Issue.none unless (WorkItems::Type.base_types.keys & issue_type_params).sort == issue_type_params.sort + return model_class.none unless (WorkItems::Type.base_types.keys & issue_type_params).sort == issue_type_params.sort items.with_issue_type(params[:issue_types]) end @@ -140,6 +140,10 @@ class IssuesFinder < IssuableFinder items.without_issue_type(issue_type_params) end + + def model_class + Issue + end end IssuesFinder.prepend_mod_with('IssuesFinder') diff --git a/app/finders/work_items/work_items_finder.rb b/app/finders/work_items/work_items_finder.rb new file mode 100644 index 00000000000..960272fe47e --- /dev/null +++ b/app/finders/work_items/work_items_finder.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +# WorkItem model inherits from Issue model. It's planned to be its extension +# with widgets support. Because WorkItems are internally Issues, WorkItemsFinder +# can be almost identical to IssuesFinder, except it should return instances of +# WorkItems instead of Issues +module WorkItems + class WorkItemsFinder < IssuesFinder + def params_class + ::IssuesFinder::Params + end + + private + + def model_class + WorkItem + end + end +end |