summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-04-28 12:48:42 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-04-28 12:48:42 +0300
commitd5fe1e57d5107c5ddc57feee5c3d1f7ed03941ab (patch)
treef28bf0e8b04bb16699ef2952c82958ed5933dd9f /app
parent8140c6828905345ea510b23ee09e53f01a74f97d (diff)
downloadgitlab-ce-d5fe1e57d5107c5ddc57feee5c3d1f7ed03941ab.tar.gz
Draft improvements to search layout
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
-rw-r--r--app/controllers/search_controller.rb9
-rw-r--r--app/views/layouts/_search.html.haml2
-rw-r--r--app/views/layouts/nav/_search.html.haml30
-rw-r--r--app/views/layouts/nav/search/_project.html.haml35
-rw-r--r--app/views/layouts/nav/search/_snippet.html.haml14
-rw-r--r--app/views/layouts/search.html.haml6
-rw-r--r--app/views/search/_global_filter.html.haml16
-rw-r--r--app/views/search/_project_filter.html.haml32
-rw-r--r--app/views/search/_results.html.haml31
-rw-r--r--app/views/search/_snippet_filter.html.haml13
-rw-r--r--app/views/search/show.html.haml36
11 files changed, 109 insertions, 115 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index c5828d0b2df..ad9e9e8487e 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -4,20 +4,22 @@ class SearchController < ApplicationController
def show
return if params[:search].nil? || params[:search].blank?
+ @search_term = params[:search]
+
if params[:project_id].present?
@project = Project.find_by(id: params[:project_id])
@project = nil unless can?(current_user, :download_code, @project)
end
if params[:group_id].present?
- @group = Group.find_by(id: params[:group_id])
+ @group = Group.find_by(id: params[:group_id])
@group = nil unless can?(current_user, :read_group, @group)
end
-
+
@scope = params[:scope]
@show_snippets = params[:snippets].eql? 'true'
- @search_results =
+ @search_results =
if @project
unless %w(blobs notes issues merge_requests wiki_blobs).
include?(@scope)
@@ -37,6 +39,7 @@ class SearchController < ApplicationController
end
Search::GlobalService.new(current_user, params).execute
end
+
@objects = @search_results.objects(@scope, params[:page])
end
diff --git a/app/views/layouts/_search.html.haml b/app/views/layouts/_search.html.haml
index 04f79846858..58e6bd3158f 100644
--- a/app/views/layouts/_search.html.haml
+++ b/app/views/layouts/_search.html.haml
@@ -1,6 +1,6 @@
.search
= form_tag search_path, method: :get, class: 'navbar-form pull-left' do |f|
- = search_field_tag "search", nil, placeholder: search_placeholder, class: "search-input"
+ = search_field_tag "search", @search_term, placeholder: search_placeholder, class: "search-input"
= hidden_field_tag :group_id, @group.try(:id)
- if @project && @project.persisted?
= hidden_field_tag :project_id, @project.id
diff --git a/app/views/layouts/nav/_search.html.haml b/app/views/layouts/nav/_search.html.haml
new file mode 100644
index 00000000000..35806c2d0fb
--- /dev/null
+++ b/app/views/layouts/nav/_search.html.haml
@@ -0,0 +1,30 @@
+%ul.nav.nav-sidebar.search-filter
+ - if @project
+ = render 'layouts/nav/search/project'
+
+ - elsif @show_snippets
+ = render 'layouts/nav/search/snippet'
+
+ - else
+ %li{class: ("active" if @scope == 'projects')}
+ = link_to search_filter_path(scope: 'projects') do
+ = icon('bookmark fw')
+ %span
+ Projects
+ %span.count
+ = @search_results.projects_count
+ %li{class: ("active" if @scope == 'issues')}
+ = link_to search_filter_path(scope: 'issues') do
+ = icon('exclamation-circle fw')
+ %span
+ Issues
+ %span.count
+ = @search_results.issues_count
+ %li{class: ("active" if @scope == 'merge_requests')}
+ = link_to search_filter_path(scope: 'merge_requests') do
+ = icon('tasks fw')
+ %span
+ Merge requests
+ %span.count
+ = @search_results.merge_requests_count
+
diff --git a/app/views/layouts/nav/search/_project.html.haml b/app/views/layouts/nav/search/_project.html.haml
new file mode 100644
index 00000000000..344cb4b4801
--- /dev/null
+++ b/app/views/layouts/nav/search/_project.html.haml
@@ -0,0 +1,35 @@
+%li{class: ("active" if @scope == 'blobs')}
+ = link_to search_filter_path(scope: 'blobs') do
+ = icon('code fw')
+ %span
+ Code
+ %span.count
+ = @search_results.blobs_count
+%li{class: ("active" if @scope == 'issues')}
+ = link_to search_filter_path(scope: 'issues') do
+ = icon('exclamation-circle fw')
+ %span
+ Issues
+ %span.count
+ = @search_results.issues_count
+%li{class: ("active" if @scope == 'merge_requests')}
+ = link_to search_filter_path(scope: 'merge_requests') do
+ = icon('tasks fw')
+ %span
+ Merge requests
+ %span.count
+ = @search_results.merge_requests_count
+%li{class: ("active" if @scope == 'notes')}
+ = link_to search_filter_path(scope: 'notes') do
+ = icon('comments fw')
+ %span
+ Comments
+ %span.count
+ = @search_results.notes_count
+%li{class: ("active" if @scope == 'wiki_blobs')}
+ = link_to search_filter_path(scope: 'wiki_blobs') do
+ = icon('book fw')
+ %span
+ Wiki
+ %span.count
+ = @search_results.wiki_blobs_count
diff --git a/app/views/layouts/nav/search/_snippet.html.haml b/app/views/layouts/nav/search/_snippet.html.haml
new file mode 100644
index 00000000000..e63a221fb82
--- /dev/null
+++ b/app/views/layouts/nav/search/_snippet.html.haml
@@ -0,0 +1,14 @@
+%li{class: ("active" if @scope == 'snippet_blobs')}
+ = link_to search_filter_path(scope: 'snippet_blobs', snippets: true, group_id: nil, project_id: nil) do
+ = icon('code fw')
+ %span
+ Snippet Contents
+ %span.count
+ = @search_results.snippet_blobs_count
+%li{class: ("active" if @scope == 'snippet_titles')}
+ = link_to search_filter_path(scope: 'snippet_titles', snippets: true, group_id: nil, project_id: nil) do
+ = icon('book fw')
+ %span
+ Titles and Filenames
+ %span.count
+ = @search_results.snippet_titles_count
diff --git a/app/views/layouts/search.html.haml b/app/views/layouts/search.html.haml
index f9d8db06e10..c9b76e8fca4 100644
--- a/app/views/layouts/search.html.haml
+++ b/app/views/layouts/search.html.haml
@@ -2,9 +2,5 @@
%html{ lang: "en"}
= render "layouts/head", title: "Search"
%body{class: "#{app_theme} application", :'data-page' => body_data_page}
- = render "layouts/broadcast"
= render "layouts/head_panel", title: link_to("Search", search_path)
- .container.navless-container
- .content
- = render "layouts/flash"
- = yield
+ = render 'layouts/page', sidebar: 'layouts/nav/search'
diff --git a/app/views/search/_global_filter.html.haml b/app/views/search/_global_filter.html.haml
deleted file mode 100644
index 442bd84f930..00000000000
--- a/app/views/search/_global_filter.html.haml
+++ /dev/null
@@ -1,16 +0,0 @@
-%ul.nav.nav-pills.nav-stacked.search-filter
- %li{class: ("active" if @scope == 'projects')}
- = link_to search_filter_path(scope: 'projects') do
- Projects
- .pull-right
- = @search_results.projects_count
- %li{class: ("active" if @scope == 'issues')}
- = link_to search_filter_path(scope: 'issues') do
- Issues
- .pull-right
- = @search_results.issues_count
- %li{class: ("active" if @scope == 'merge_requests')}
- = link_to search_filter_path(scope: 'merge_requests') do
- Merge requests
- .pull-right
- = @search_results.merge_requests_count
diff --git a/app/views/search/_project_filter.html.haml b/app/views/search/_project_filter.html.haml
deleted file mode 100644
index ad933502a28..00000000000
--- a/app/views/search/_project_filter.html.haml
+++ /dev/null
@@ -1,32 +0,0 @@
-%ul.nav.nav-pills.nav-stacked.search-filter
- %li{class: ("active" if @scope == 'blobs')}
- = link_to search_filter_path(scope: 'blobs') do
- %i.fa.fa-code
- Code
- .pull-right
- = @search_results.blobs_count
- %li{class: ("active" if @scope == 'issues')}
- = link_to search_filter_path(scope: 'issues') do
- %i.fa.fa-exclamation-circle
- Issues
- .pull-right
- = @search_results.issues_count
- %li{class: ("active" if @scope == 'merge_requests')}
- = link_to search_filter_path(scope: 'merge_requests') do
- %i.fa.fa-code-fork
- Merge requests
- .pull-right
- = @search_results.merge_requests_count
- %li{class: ("active" if @scope == 'notes')}
- = link_to search_filter_path(scope: 'notes') do
- %i.fa.fa-comments
- Comments
- .pull-right
- = @search_results.notes_count
- %li{class: ("active" if @scope == 'wiki_blobs')}
- = link_to search_filter_path(scope: 'wiki_blobs') do
- %i.fa.fa-book
- Wiki
- .pull-right
- = @search_results.wiki_blobs_count
-
diff --git a/app/views/search/_results.html.haml b/app/views/search/_results.html.haml
index 796dd752a4c..f741a64cbab 100644
--- a/app/views/search/_results.html.haml
+++ b/app/views/search/_results.html.haml
@@ -1,28 +1,9 @@
-%h4
- #{@search_results.total_count} results found
- - unless @show_snippets
- - if @project
- for #{link_to @project.name_with_namespace, [@project.namespace.becomes(Namespace), @project]}
- - elsif @group
- for #{link_to @group.name, @group}
-
-%hr
-
-.row
- .col-sm-3
- - if @project
- = render "project_filter"
- - elsif @show_snippets
- = render 'snippet_filter'
- - else
- = render "global_filter"
- .col-sm-9
- .search-results
- - if @search_results.empty?
- = render partial: "search/results/empty", locals: { message: "We couldn't find any matching results" }
- - else
- = render partial: "search/results/#{@scope.singularize}", collection: @objects
- = paginate @objects, theme: 'gitlab'
+.search-results
+ - if @search_results.empty?
+ = render partial: "search/results/empty", locals: { message: "We couldn't find any matching results" }
+ - else
+ = render partial: "search/results/#{@scope.singularize}", collection: @objects
+ = paginate @objects, theme: 'gitlab'
:javascript
$(".search-results .term").highlight("#{escape_javascript(params[:search])}");
diff --git a/app/views/search/_snippet_filter.html.haml b/app/views/search/_snippet_filter.html.haml
deleted file mode 100644
index 95d23fa9f47..00000000000
--- a/app/views/search/_snippet_filter.html.haml
+++ /dev/null
@@ -1,13 +0,0 @@
-%ul.nav.nav-pills.nav-stacked.search-filter
- %li{class: ("active" if @scope == 'snippet_blobs')}
- = link_to search_filter_path(scope: 'snippet_blobs', snippets: true, group_id: nil, project_id: nil) do
- %i.fa.fa-code
- Snippet Contents
- .pull-right
- = @search_results.snippet_blobs_count
- %li{class: ("active" if @scope == 'snippet_titles')}
- = link_to search_filter_path(scope: 'snippet_titles', snippets: true, group_id: nil, project_id: nil) do
- %i.fa.fa-book
- Titles and Filenames
- .pull-right
- = @search_results.snippet_titles_count
diff --git a/app/views/search/show.html.haml b/app/views/search/show.html.haml
index 5b4816e4c40..fcdd63a764d 100644
--- a/app/views/search/show.html.haml
+++ b/app/views/search/show.html.haml
@@ -1,22 +1,18 @@
-= form_tag search_path, method: :get, class: 'form-horizontal' do |f|
- .search-holder.clearfix
- .form-group
- = label_tag :search, class: 'control-label' do
- %span Looking for
- .col-sm-6
- = search_field_tag :search, params[:search], placeholder: "issue 143", class: "form-control search-text-input", id: "dashboard_search"
- .col-sm-4
- = button_tag 'Search', class: "btn btn-create"
- .form-group
- .col-sm-2
- - unless params[:snippets].eql? 'true'
- .col-sm-10
- = render 'filter', f: f
- = hidden_field_tag :project_id, params[:project_id]
- = hidden_field_tag :group_id, params[:group_id]
- = hidden_field_tag :snippets, params[:snippets]
- = hidden_field_tag :scope, params[:scope]
+- if @search_term
+ .lead
+ Search for
+ %code
+ = @search_term
+ - unless @show_snippets
+ - if @project
+ in project #{link_to @project.name_with_namespace, [@project.namespace.becomes(Namespace), @project]}
+ - elsif @group
+ in group #{link_to @group.name, @group}
+ .pull-right
+ = render 'filter'
+ %hr
.results.prepend-top-10
- - if params[:search].present?
- = render 'search/results'
+ = render 'search/results'
+- else
+ wow