diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-16 06:11:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-16 06:11:31 +0300 |
commit | 473d6b24349755c8ade489fdb93d5a5463ccc13f (patch) | |
tree | 3e3df2559bf96012ee540eec57ebd5d2a79c6fe8 /app/finders | |
parent | 5074a6923ee1572d5e0590191206e0e4a4849287 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/fork_targets_finder.rb | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/app/finders/fork_targets_finder.rb b/app/finders/fork_targets_finder.rb index 0b5dfb16572..e129fde3748 100644 --- a/app/finders/fork_targets_finder.rb +++ b/app/finders/fork_targets_finder.rb @@ -6,17 +6,39 @@ class ForkTargetsFinder @user = user end - # rubocop: disable CodeReuse/ActiveRecord def execute(options = {}) - return ::Namespace.where(id: user.forkable_namespaces).sort_by_type unless options[:only_groups] + return previous_execute(options) unless Feature.enabled?(:searchable_fork_targets) - ::Group.where(id: user.manageable_groups(include_groups_with_developer_maintainer_access: true)) + items = fork_targets(options) + + by_search(items, options) end - # rubocop: enable CodeReuse/ActiveRecord private attr_reader :project, :user + + def by_search(items, options) + return items if options[:search].blank? + + items.search(options[:search]) + end + + def fork_targets(options) + if options[:only_groups] + user.manageable_groups(include_groups_with_developer_maintainer_access: true) + else + user.forkable_namespaces.sort_by_type + end + end + + # rubocop: disable CodeReuse/ActiveRecord + def previous_execute(options = {}) + return ::Namespace.where(id: user.forkable_namespaces).sort_by_type unless options[:only_groups] + + ::Group.where(id: user.manageable_groups(include_groups_with_developer_maintainer_access: true)) + end + # rubocop: enable CodeReuse/ActiveRecord end ForkTargetsFinder.prepend_mod_with('ForkTargetsFinder') |