From d5fe1e57d5107c5ddc57feee5c3d1f7ed03941ab Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 28 Apr 2015 12:48:42 +0300 Subject: [PATCH 1/4] Draft improvements to search layout Signed-off-by: Dmitriy Zaporozhets --- app/controllers/search_controller.rb | 9 +++-- app/views/layouts/_search.html.haml | 2 +- app/views/layouts/nav/_search.html.haml | 30 ++++++++++++++++ .../layouts/nav/search/_project.html.haml | 35 ++++++++++++++++++ .../layouts/nav/search/_snippet.html.haml | 14 ++++++++ app/views/layouts/search.html.haml | 6 +--- app/views/search/_global_filter.html.haml | 16 --------- app/views/search/_project_filter.html.haml | 32 ----------------- app/views/search/_results.html.haml | 31 ++++------------ app/views/search/_snippet_filter.html.haml | 13 ------- app/views/search/show.html.haml | 36 +++++++++---------- 11 files changed, 109 insertions(+), 115 deletions(-) create mode 100644 app/views/layouts/nav/_search.html.haml create mode 100644 app/views/layouts/nav/search/_project.html.haml create mode 100644 app/views/layouts/nav/search/_snippet.html.haml delete mode 100644 app/views/search/_global_filter.html.haml delete mode 100644 app/views/search/_project_filter.html.haml delete mode 100644 app/views/search/_snippet_filter.html.haml 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 From 1ff01d26e1943a16f77e2ab08e89c92d72fcbf62 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 28 Apr 2015 22:04:19 +0300 Subject: [PATCH 2/4] Continue refactoring and restyle of search layout Signed-off-by: Dmitriy Zaporozhets --- app/assets/stylesheets/generic/common.scss | 11 +---- app/views/layouts/_head_panel.html.haml | 5 +- app/views/layouts/_search.html.haml | 2 +- app/views/layouts/nav/_search.html.haml | 56 +++++++++++----------- app/views/search/_filter.html.haml | 4 +- app/views/search/_form.html.haml | 12 +++++ app/views/search/_results.html.haml | 24 +++++++--- app/views/search/results/_empty.html.haml | 6 ++- app/views/search/show.html.haml | 20 ++------ db/schema.rb | 28 ++++++++++- 10 files changed, 98 insertions(+), 70 deletions(-) create mode 100644 app/views/search/_form.html.haml diff --git a/app/assets/stylesheets/generic/common.scss b/app/assets/stylesheets/generic/common.scss index 7c3021989a8..1e569978cc8 100644 --- a/app/assets/stylesheets/generic/common.scss +++ b/app/assets/stylesheets/generic/common.scss @@ -333,17 +333,8 @@ table { } .search_box { - position: relative; - padding: 30px; + @extend .well; text-align: center; - background-color: #F9F9F9; - border: 1px solid #DDDDDD; - border-radius: 0px; -} - -.search_glyph { - color: #555; - font-size: 42px; } .task-status { diff --git a/app/views/layouts/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml index fc4656be079..a7ec19cb692 100644 --- a/app/views/layouts/_head_panel.html.haml +++ b/app/views/layouts/_head_panel.html.haml @@ -13,8 +13,9 @@ .navbar-collapse.collapse %ul.nav.navbar-nav - %li.hidden-sm.hidden-xs - = render 'layouts/search' + - unless current_controller?(:search) + %li.hidden-sm.hidden-xs + = render 'layouts/search' %li.visible-sm.visible-xs = link_to search_path, title: 'Search', data: {toggle: 'tooltip', placement: 'bottom'} do = icon('search') diff --git a/app/views/layouts/_search.html.haml b/app/views/layouts/_search.html.haml index 58e6bd3158f..04f79846858 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", @search_term, placeholder: search_placeholder, class: "search-input" + = search_field_tag "search", nil, 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 index 35806c2d0fb..f95f6acb28d 100644 --- a/app/views/layouts/nav/_search.html.haml +++ b/app/views/layouts/nav/_search.html.haml @@ -1,30 +1,30 @@ -%ul.nav.nav-sidebar.search-filter - - if @project - = render 'layouts/nav/search/project' +- if @search_term + %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 + - 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/search/_filter.html.haml b/app/views/search/_filter.html.haml index ffc145497ab..e2d0cab9e79 100644 --- a/app/views/search/_filter.html.haml +++ b/app/views/search/_filter.html.haml @@ -1,5 +1,5 @@ .dropdown.inline - %button.dropdown-toggle.btn.btn-sm{type: 'button', 'data-toggle' => 'dropdown'} + %button.dropdown-toggle.btn.btn{type: 'button', 'data-toggle' => 'dropdown'} %i.fa.fa-tags %span.light Group: - if @group.present? @@ -17,7 +17,7 @@ = group.name .dropdown.inline.prepend-left-10.project-filter - %button.dropdown-toggle.btn.btn-sm{type: 'button', 'data-toggle' => 'dropdown'} + %button.dropdown-toggle.btn.btn{type: 'button', 'data-toggle' => 'dropdown'} %i.fa.fa-tags %span.light Project: - if @project.present? diff --git a/app/views/search/_form.html.haml b/app/views/search/_form.html.haml new file mode 100644 index 00000000000..a9ec7df2967 --- /dev/null +++ b/app/views/search/_form.html.haml @@ -0,0 +1,12 @@ += form_tag search_path, method: :get, class: 'form-inline' do |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] + .search-holder.clearfix + .form-group + = search_field_tag :search, params[:search], placeholder: "Search for projects, issues etc", class: "form-control search-text-input input-mn-300", id: "dashboard_search", autofocus: true + = button_tag 'Search', class: "btn btn-info" + - unless params[:snippets].eql? 'true' + .pull-right + = render 'filter' diff --git a/app/views/search/_results.html.haml b/app/views/search/_results.html.haml index f741a64cbab..741c780ad96 100644 --- a/app/views/search/_results.html.haml +++ b/app/views/search/_results.html.haml @@ -1,9 +1,21 @@ -.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' +- if @search_results.empty? + = render partial: "search/results/empty" +- else + .light + Search results 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} + + %br + .results.prepend-top-10 + .search-results + = 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/results/_empty.html.haml b/app/views/search/results/_empty.html.haml index 01fb8cd9b8e..05a63016c09 100644 --- a/app/views/search/results/_empty.html.haml +++ b/app/views/search/results/_empty.html.haml @@ -1,4 +1,6 @@ .search_box .search_glyph - %span.fa.fa-search - %h4 #{message} + %h4 + = icon('search') + We couldn't find any results matching + %code #{@search_term} diff --git a/app/views/search/show.html.haml b/app/views/search/show.html.haml index fcdd63a764d..8e11154279f 100644 --- a/app/views/search/show.html.haml +++ b/app/views/search/show.html.haml @@ -1,18 +1,4 @@ += render 'search/form' +%hr - 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 - = render 'search/results' -- else - wow + = render 'search/results' diff --git a/db/schema.rb b/db/schema.rb index 8683c0446fe..43faaf31682 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -349,10 +349,10 @@ ActiveRecord::Schema.define(version: 20150425173433) do t.string "import_url" t.integer "visibility_level", default: 0, null: false t.boolean "archived", default: false, null: false - t.string "avatar" t.string "import_status" t.float "repository_size", default: 0.0 t.integer "star_count", default: 0, null: false + t.string "avatar" t.string "import_type" t.string "import_source" end @@ -472,7 +472,6 @@ ActiveRecord::Schema.define(version: 20150425173433) do t.integer "notification_level", default: 1, null: false t.datetime "password_expires_at" t.integer "created_by_id" - t.datetime "last_credential_check_at" t.string "avatar" t.string "confirmation_token" t.datetime "confirmed_at" @@ -480,6 +479,7 @@ ActiveRecord::Schema.define(version: 20150425173433) do t.string "unconfirmed_email" t.boolean "hide_no_ssh_key", default: false t.string "website_url", default: "", null: false + t.datetime "last_credential_check_at" t.string "github_access_token" t.string "gitlab_access_token" t.string "notification_email" @@ -501,6 +501,30 @@ ActiveRecord::Schema.define(version: 20150425173433) do add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree add_index "users", ["username"], name: "index_users_on_username", using: :btree + create_table "users_groups", force: true do |t| + t.integer "group_access", null: false + t.integer "group_id", null: false + t.integer "user_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "notification_level", default: 3, null: false + end + + add_index "users_groups", ["user_id"], name: "index_users_groups_on_user_id", using: :btree + + create_table "users_projects", force: true do |t| + t.integer "user_id", null: false + t.integer "project_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "project_access", default: 0, null: false + t.integer "notification_level", default: 3, null: false + end + + add_index "users_projects", ["project_access"], name: "index_users_projects_on_project_access", using: :btree + add_index "users_projects", ["project_id"], name: "index_users_projects_on_project_id", using: :btree + add_index "users_projects", ["user_id"], name: "index_users_projects_on_user_id", using: :btree + create_table "users_star_projects", force: true do |t| t.integer "project_id", null: false t.integer "user_id", null: false From 24037e7e6323ff0f91d21d111bd2092f948c8255 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 29 Apr 2015 12:19:54 +0300 Subject: [PATCH 3/4] Move search categories (projects, issues etc) below search field. Instead use sidebar for dashbaord nav Signed-off-by: Dmitriy Zaporozhets --- app/assets/stylesheets/base/gl_bootstrap.scss | 6 ++ app/views/layouts/nav/_search.html.haml | 30 -------- .../layouts/nav/search/_project.html.haml | 35 --------- .../layouts/nav/search/_snippet.html.haml | 14 ---- app/views/layouts/search.html.haml | 2 +- app/views/search/_category.html.haml | 77 +++++++++++++++++++ app/views/search/_form.html.haml | 2 +- app/views/search/show.html.haml | 2 + 8 files changed, 87 insertions(+), 81 deletions(-) delete mode 100644 app/views/layouts/nav/_search.html.haml delete mode 100644 app/views/layouts/nav/search/_project.html.haml delete mode 100644 app/views/layouts/nav/search/_snippet.html.haml create mode 100644 app/views/search/_category.html.haml diff --git a/app/assets/stylesheets/base/gl_bootstrap.scss b/app/assets/stylesheets/base/gl_bootstrap.scss index 427f333423c..21acbfa5e5a 100644 --- a/app/assets/stylesheets/base/gl_bootstrap.scss +++ b/app/assets/stylesheets/base/gl_bootstrap.scss @@ -137,6 +137,12 @@ color: #666; } +.nav-pills > .active > a > span > .badge { + background-color: #fff; + color: $gl-primary; +} + + /** * fix to keep tooltips position in top navigation bar * diff --git a/app/views/layouts/nav/_search.html.haml b/app/views/layouts/nav/_search.html.haml deleted file mode 100644 index f95f6acb28d..00000000000 --- a/app/views/layouts/nav/_search.html.haml +++ /dev/null @@ -1,30 +0,0 @@ -- if @search_term - %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 deleted file mode 100644 index 344cb4b4801..00000000000 --- a/app/views/layouts/nav/search/_project.html.haml +++ /dev/null @@ -1,35 +0,0 @@ -%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 deleted file mode 100644 index e63a221fb82..00000000000 --- a/app/views/layouts/nav/search/_snippet.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -%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 c9b76e8fca4..4b526686be4 100644 --- a/app/views/layouts/search.html.haml +++ b/app/views/layouts/search.html.haml @@ -3,4 +3,4 @@ = render "layouts/head", title: "Search" %body{class: "#{app_theme} application", :'data-page' => body_data_page} = render "layouts/head_panel", title: link_to("Search", search_path) - = render 'layouts/page', sidebar: 'layouts/nav/search' + = render 'layouts/page' diff --git a/app/views/search/_category.html.haml b/app/views/search/_category.html.haml new file mode 100644 index 00000000000..154332cb9a9 --- /dev/null +++ b/app/views/search/_category.html.haml @@ -0,0 +1,77 @@ +%ul.nav.nav-pills.search-filter + - if @project + %li{class: ("active" if @scope == 'blobs')} + = link_to search_filter_path(scope: 'blobs') do + = icon('code fw') + %span + Code + %span.badge + = @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.badge + = @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.badge + = @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.badge + = @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.badge + = @search_results.wiki_blobs_count + + - elsif @show_snippets + %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.badge + = @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.badge + = @search_results.snippet_titles_count + + - else + %li{class: ("active" if @scope == 'projects')} + = link_to search_filter_path(scope: 'projects') do + = icon('bookmark fw') + %span + Projects + %span.badge + = @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.badge + = @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.badge + = @search_results.merge_requests_count + diff --git a/app/views/search/_form.html.haml b/app/views/search/_form.html.haml index a9ec7df2967..47016daf1f0 100644 --- a/app/views/search/_form.html.haml +++ b/app/views/search/_form.html.haml @@ -6,7 +6,7 @@ .search-holder.clearfix .form-group = search_field_tag :search, params[:search], placeholder: "Search for projects, issues etc", class: "form-control search-text-input input-mn-300", id: "dashboard_search", autofocus: true - = button_tag 'Search', class: "btn btn-info" + = button_tag 'Search', class: "btn btn-primary" - unless params[:snippets].eql? 'true' .pull-right = render 'filter' diff --git a/app/views/search/show.html.haml b/app/views/search/show.html.haml index 8e11154279f..e9f2711be2a 100644 --- a/app/views/search/show.html.haml +++ b/app/views/search/show.html.haml @@ -1,4 +1,6 @@ = render 'search/form' %hr - if @search_term + = render 'search/category' + %hr = render 'search/results' From 7534d0ef46debee418fa36d65670cd1e43810baa Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 29 Apr 2015 19:52:25 +0300 Subject: [PATCH 4/4] Fix tests Signed-off-by: Dmitriy Zaporozhets --- features/steps/project/source/search_code.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/steps/project/source/search_code.rb b/features/steps/project/source/search_code.rb index 9c2864cc936..b66c5a4123a 100644 --- a/features/steps/project/source/search_code.rb +++ b/features/steps/project/source/search_code.rb @@ -14,6 +14,6 @@ class Spinach::Features::ProjectSourceSearchCode < Spinach::FeatureSteps end step 'I should see empty result' do - page.should have_content "We couldn't find any matching" + page.should have_content "We couldn't find any" end end