Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-04-29 21:40:16 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-04-29 21:40:16 +0300
commit39a55bdf1a1613f362bcd7da444b291210454160 (patch)
tree306b9cf2b98d3e5f2684ba9ab1311a8dfb1d1cb8
parent5bf9f69df7f46b1c82bf3c02bf806a9f604480e5 (diff)
parent7534d0ef46debee418fa36d65670cd1e43810baa (diff)
Merge branch 'search-layout' into 'master'
Improvements to search layout Improve search layout to match new UI style and make it more mobile-firendly See merge request !585
-rw-r--r--app/assets/stylesheets/base/gl_bootstrap.scss6
-rw-r--r--app/assets/stylesheets/generic/common.scss11
-rw-r--r--app/controllers/search_controller.rb9
-rw-r--r--app/views/layouts/_head_panel.html.haml5
-rw-r--r--app/views/layouts/search.html.haml6
-rw-r--r--app/views/search/_category.html.haml77
-rw-r--r--app/views/search/_filter.html.haml4
-rw-r--r--app/views/search/_form.html.haml12
-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.haml39
-rw-r--r--app/views/search/_snippet_filter.html.haml13
-rw-r--r--app/views/search/results/_empty.html.haml6
-rw-r--r--app/views/search/show.html.haml28
-rw-r--r--db/schema.rb28
-rw-r--r--features/steps/project/source/search_code.rb2
16 files changed, 161 insertions, 133 deletions
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/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/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/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml
index 8d4c7b39b19..3a9956ed189 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 f9d8db06e10..4b526686be4 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'
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/_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..47016daf1f0
--- /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-primary"
+ - unless params[:snippets].eql? 'true'
+ .pull-right
+ = render 'filter'
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..741c780ad96 100644
--- a/app/views/search/_results.html.haml
+++ b/app/views/search/_results.html.haml
@@ -1,28 +1,21 @@
-%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}
+- 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}
-%hr
-
-.row
- .col-sm-3
- - if @project
- = render "project_filter"
- - elsif @show_snippets
- = render 'snippet_filter'
- - else
- = render "global_filter"
- .col-sm-9
+ %br
+ .results.prepend-top-10
.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'
+ = 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/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 5b4816e4c40..e9f2711be2a 100644
--- a/app/views/search/show.html.haml
+++ b/app/views/search/show.html.haml
@@ -1,22 +1,6 @@
-= 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]
-
- .results.prepend-top-10
- - if params[:search].present?
- = render 'search/results'
+= render 'search/form'
+%hr
+- if @search_term
+ = render 'search/category'
+ %hr
+ = render 'search/results'
diff --git a/db/schema.rb b/db/schema.rb
index 2530eb6fa9d..a2ed9efc933 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -349,10 +349,10 @@ ActiveRecord::Schema.define(version: 20150429002313) 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: 20150429002313) 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: 20150429002313) 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: 20150429002313) 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
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