Only trigger actual search if a search string is present
This commit is contained in:
parent
6c1074e302
commit
9487c37037
1 changed files with 20 additions and 20 deletions
|
@ -2,34 +2,34 @@ class SearchController < ApplicationController
|
||||||
include SearchHelper
|
include SearchHelper
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
return if params[:search].nil? || params[:search].blank?
|
||||||
@project = Project.find_by(id: params[:project_id]) if params[:project_id].present?
|
@project = Project.find_by(id: params[:project_id]) if params[:project_id].present?
|
||||||
@group = Group.find_by(id: params[:group_id]) if params[:group_id].present?
|
@group = Group.find_by(id: params[:group_id]) if params[:group_id].present?
|
||||||
@scope = params[:scope]
|
@scope = params[:scope]
|
||||||
@show_snippets = params[:snippets].eql? 'true'
|
@show_snippets = params[:snippets].eql? 'true'
|
||||||
|
|
||||||
@search_results = if @project
|
@search_results =
|
||||||
return access_denied! unless can?(current_user, :download_code, @project)
|
if @project
|
||||||
|
return access_denied! unless can?(current_user, :download_code, @project)
|
||||||
|
|
||||||
unless %w(blobs notes issues merge_requests wiki_blobs).
|
unless %w(blobs notes issues merge_requests wiki_blobs).
|
||||||
include?(@scope)
|
include?(@scope)
|
||||||
@scope = 'blobs'
|
@scope = 'blobs'
|
||||||
end
|
end
|
||||||
|
|
||||||
Search::ProjectService.new(@project, current_user, params).execute
|
Search::ProjectService.new(@project, current_user, params).execute
|
||||||
elsif @show_snippets
|
elsif @show_snippets
|
||||||
unless %w(snippet_blobs snippet_titles).include?(@scope)
|
unless %w(snippet_blobs snippet_titles).include?(@scope)
|
||||||
@scope = 'snippet_blobs'
|
@scope = 'snippet_blobs'
|
||||||
end
|
end
|
||||||
|
|
||||||
Search::SnippetService.new(current_user, params).execute
|
|
||||||
else
|
|
||||||
unless %w(projects issues merge_requests).include?(@scope)
|
|
||||||
@scope = 'projects'
|
|
||||||
end
|
|
||||||
|
|
||||||
Search::GlobalService.new(current_user, params).execute
|
|
||||||
end
|
|
||||||
|
|
||||||
|
Search::SnippetService.new(current_user, params).execute
|
||||||
|
else
|
||||||
|
unless %w(projects issues merge_requests).include?(@scope)
|
||||||
|
@scope = 'projects'
|
||||||
|
end
|
||||||
|
Search::GlobalService.new(current_user, params).execute
|
||||||
|
end
|
||||||
@objects = @search_results.objects(@scope, params[:page])
|
@objects = @search_results.objects(@scope, params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue