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/feature_flags_user_lists_finder.rb')
-rw-r--r--app/finders/feature_flags_user_lists_finder.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/finders/feature_flags_user_lists_finder.rb b/app/finders/feature_flags_user_lists_finder.rb
new file mode 100644
index 00000000000..ebe60acd711
--- /dev/null
+++ b/app/finders/feature_flags_user_lists_finder.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class FeatureFlagsUserListsFinder
+ attr_reader :project, :current_user, :params
+
+ def initialize(project, current_user, params = {})
+ @project = project
+ @current_user = current_user
+ @params = params
+ end
+
+ def execute
+ unless Ability.allowed?(current_user, :read_feature_flag, project)
+ return Operations::FeatureFlagsUserList.none
+ end
+
+ items = feature_flags_user_lists
+ by_search(items)
+ end
+
+ private
+
+ def feature_flags_user_lists
+ project.operations_feature_flags_user_lists
+ end
+
+ def by_search(items)
+ if params[:search].present?
+ items.for_name_like(params[:search])
+ else
+ items
+ end
+ end
+end