2014-01-09 05:36:55 -05:00
|
|
|
module Search
|
2014-01-16 12:03:42 -05:00
|
|
|
class GlobalService
|
2014-01-09 05:36:55 -05:00
|
|
|
attr_accessor :current_user, :params
|
2017-12-15 05:21:12 -05:00
|
|
|
attr_reader :default_project_filter
|
2014-01-09 05:36:55 -05:00
|
|
|
|
|
|
|
def initialize(user, params)
|
|
|
|
@current_user, @params = user, params.dup
|
2017-12-15 05:21:12 -05:00
|
|
|
@default_project_filter = true
|
2014-01-09 05:36:55 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2017-12-15 05:21:12 -05:00
|
|
|
Gitlab::SearchResults.new(current_user, projects, params[:search],
|
|
|
|
default_project_filter: default_project_filter)
|
2014-01-09 05:36:55 -05:00
|
|
|
end
|
2017-03-31 09:03:55 -04:00
|
|
|
|
2017-04-13 11:20:04 -04:00
|
|
|
def projects
|
|
|
|
@projects ||= ProjectsFinder.new(current_user: current_user).execute
|
|
|
|
end
|
|
|
|
|
2017-03-31 09:03:55 -04:00
|
|
|
def scope
|
2017-04-04 07:57:16 -04:00
|
|
|
@scope ||= begin
|
|
|
|
allowed_scopes = %w[issues merge_requests milestones]
|
|
|
|
|
|
|
|
allowed_scopes.delete(params[:scope]) { 'projects' }
|
|
|
|
end
|
2017-03-31 09:03:55 -04:00
|
|
|
end
|
2014-01-09 05:36:55 -05:00
|
|
|
end
|
|
|
|
end
|