summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-04-26 09:02:28 +0100
committerPhil Hughes <me@iamphill.com>2016-04-26 09:04:35 +0100
commit97c1a1ef64cdce75afa24075ea77333e76c9ccbf (patch)
tree54e960093847aee8af2d865b461941b0c8b482e7
parent7ee5de19804842033c3cfdc2bf1209c27adcd7b7 (diff)
downloadgitlab-ce-search-ui-update.tar.gz
Updated based on feedbacksearch-ui-update
Changed some variable names Fixed CHANGELOG entry
-rw-r--r--CHANGELOG2
-rw-r--r--app/controllers/search_controller.rb5
-rw-r--r--app/helpers/search_helper.rb12
-rw-r--r--app/views/search/_results.html.haml10
4 files changed, 15 insertions, 14 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 083b5893696..e66f8a61b95 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ v 8.8.0 (unreleased)
- Remove future dates from contribution calendar graph.
- Fix error when visiting commit builds page before build was updated
- Add 'l' shortcut to open Label dropdown on issuables and 'i' to create new issue on a project
+ - Updated search UI
v 8.7.1 (unreleased)
- Fix .gitlab-ci.yml parsing issue when hidde job is a template without script definition. !3849
@@ -133,7 +134,6 @@ v 8.6.7
- Fix persistent XSS vulnerability in `commit_person_link` helper
- Fix persistent XSS vulnerability in Label and Milestone dropdowns
- Fix vulnerability that made it possible to enumerate private projects belonging to group
- - Updated search UI
v 8.6.6
- Expire the exists cache before deletion to ensure project dir actually exists (Stan Hu). !3413
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index 8263bb5b0ac..69c92d2bed2 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -6,6 +6,8 @@ class SearchController < ApplicationController
layout 'search'
def show
+ return if params[:search].nil? || params[:search].blank?
+
if params[:project_id].present?
@project = Project.find_by(id: params[:project_id])
@project = nil unless can?(current_user, :download_code, @project)
@@ -16,7 +18,6 @@ class SearchController < ApplicationController
@group = nil unless can?(current_user, :read_group, @group)
end
- return if params[:search].nil? || params[:search].blank?
@search_term = params[:search]
@scope = params[:scope]
@@ -43,7 +44,7 @@ class SearchController < ApplicationController
Search::GlobalService.new(current_user, params).execute
end
- @objects = @search_results.objects(@scope, params[:page])
+ @search_objects = @search_results.objects(@scope, params[:page])
end
def autocomplete
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index 7f585cd5dd9..24c4c098c65 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -20,13 +20,13 @@ module SearchHelper
end
def search_entries_info(collection, scope, term)
- if collection.count > 0
- from = collection.offset_value + 1
- to = collection.offset_value + collection.length
- count = collection.total_count
+ return unless collection.count > 0
- "Showing #{from} - #{to} of #{count} #{scope.humanize(capitalize: false)} for \"#{term}\""
- end
+ from = collection.offset_value + 1
+ to = collection.offset_value + collection.length
+ count = collection.total_count
+
+ "Showing #{from} - #{to} of #{count} #{scope.humanize(capitalize: false)} for \"#{term}\""
end
private
diff --git a/app/views/search/_results.html.haml b/app/views/search/_results.html.haml
index 204f5a36f85..711337f308e 100644
--- a/app/views/search/_results.html.haml
+++ b/app/views/search/_results.html.haml
@@ -1,8 +1,8 @@
-- if @objects.empty?
+- if @search_objects.empty?
= render partial: "search/results/empty"
- else
.gray-content-block
- = search_entries_info @objects, @scope, @search_term
+ = search_entries_info(@search_objects, @scope, @search_term)
- unless @show_snippets
- if @project
in project #{link_to @project.name_with_namespace, [@project.namespace.becomes(Namespace), @project]}
@@ -13,9 +13,9 @@
.search-results
- if @scope == 'projects'
.term
- = render 'shared/projects/list', projects: @objects
+ = render 'shared/projects/list', projects: @search_objects
- else
- = render partial: "search/results/#{@scope.singularize}", collection: @objects
+ = render partial: "search/results/#{@scope.singularize}", collection: @search_objects
- if @scope != 'projects'
- = paginate @objects, theme: 'gitlab'
+ = paginate(@search_objects, theme: 'gitlab')