summaryrefslogtreecommitdiff
path: root/app/views/search
diff options
context:
space:
mode:
authorminghuan lei <leiminghuan@126.com>2019-08-09 16:32:17 +0000
committerPaul Slaughter <pslaughter@gitlab.com>2019-08-09 16:32:17 +0000
commitaa137fd39f1e750ff4d02371b7cdf1322e84a343 (patch)
tree512763c294b4a7408f65efbf83af26e2c878f84f /app/views/search
parente0e6e9e7dbcff3ce9ea12fb0421704d7ef48ad15 (diff)
downloadgitlab-ce-aa137fd39f1e750ff4d02371b7cdf1322e84a343.tar.gz
Add repo-refs control for search page
- only in blobs result
Diffstat (limited to 'app/views/search')
-rw-r--r--app/views/search/_form.html.haml1
-rw-r--r--app/views/search/_results.html.haml16
2 files changed, 13 insertions, 4 deletions
diff --git a/app/views/search/_form.html.haml b/app/views/search/_form.html.haml
index 4c4f3e0298b..464db94b7f4 100644
--- a/app/views/search/_form.html.haml
+++ b/app/views/search/_form.html.haml
@@ -1,6 +1,7 @@
= form_tag search_path, method: :get, class: 'search-page-form js-search-form' do |f|
= hidden_field_tag :snippets, params[:snippets]
= hidden_field_tag :scope, params[:scope]
+ = hidden_field_tag :repository_ref, params[:repository_ref]
.d-lg-flex.align-items-end
.search-field-holder.form-group.mr-lg-1.mb-lg-0
diff --git a/app/views/search/_results.html.haml b/app/views/search/_results.html.haml
index cb8a8a24be8..de9947528cf 100644
--- a/app/views/search/_results.html.haml
+++ b/app/views/search/_results.html.haml
@@ -2,17 +2,25 @@
= render partial: "search/results/empty"
= render_if_exists 'shared/promotions/promote_advanced_search'
- else
- .row-content-block
+ .row-content-block.d-md-flex.text-left.align-items-center
- unless @search_objects.is_a?(Kaminari::PaginatableWithoutCount)
= search_entries_info(@search_objects, @scope, @search_term)
- unless @show_snippets
- if @project
- - link_to_project = link_to(@project.full_name, [@project.namespace.becomes(Namespace), @project])
- = _("in project %{link_to_project}").html_safe % { link_to_project: link_to_project }
+ - link_to_project = link_to(@project.full_name, [@project.namespace.becomes(Namespace), @project], class: 'ml-md-1')
+ - if @scope == 'blobs'
+ - repository_ref = params[:repository_ref].to_s.presence || @project.default_branch
+ = s_("SearchCodeResults|in")
+ .mx-md-1
+ = render partial: "shared/ref_switcher", locals: { ref: repository_ref, form_path: request.fullpath, field_name: 'repository_ref' }
+ = s_('SearchCodeResults|of %{link_to_project}').html_safe % { link_to_project: link_to_project }
+ - else
+ = _("in project %{link_to_project}").html_safe % { link_to_project: link_to_project }
- elsif @group
- - link_to_group = link_to(@group.name, @group)
+ - link_to_group = link_to(@group.name, @group, class: 'ml-md-1')
= _("in group %{link_to_group}").html_safe % { link_to_group: link_to_group }
= render_if_exists 'shared/promotions/promote_advanced_search'
+
.results.prepend-top-10
- if @scope == 'commits'
%ul.content-list.commit-list