2020-04-08 14:13:33 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ForkTargetsFinder
|
|
|
|
def initialize(project, user)
|
|
|
|
@project = project
|
|
|
|
@user = user
|
|
|
|
end
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
def execute(options = {})
|
2022-08-27 11:52:29 +05:30
|
|
|
items = fork_targets(options)
|
|
|
|
|
|
|
|
by_search(items, options)
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
attr_reader :project, :user
|
2022-08-27 11:52:29 +05:30
|
|
|
|
|
|
|
def by_search(items, options)
|
|
|
|
return items if options[:search].blank?
|
|
|
|
|
|
|
|
items.search(options[:search])
|
|
|
|
end
|
|
|
|
|
|
|
|
def fork_targets(options)
|
|
|
|
if options[:only_groups]
|
2023-06-20 00:43:36 +05:30
|
|
|
Groups::AcceptingProjectCreationsFinder.new(user).execute # rubocop: disable CodeReuse/Finder
|
2022-08-27 11:52:29 +05:30
|
|
|
else
|
|
|
|
user.forkable_namespaces.sort_by_type
|
|
|
|
end
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
ForkTargetsFinder.prepend_mod_with('ForkTargetsFinder')
|