diff options
author | Alex Groleau <agroleau@gitlab.com> | 2019-08-27 12:41:39 -0400 |
---|---|---|
committer | Alex Groleau <agroleau@gitlab.com> | 2019-08-27 12:41:39 -0400 |
commit | aa01f092829facd1044ad02f334422b7dbdc8b0e (patch) | |
tree | a754bf2497820432df7da0f2108bb7527a8dd7b8 /app/helpers/search_helper.rb | |
parent | a1d9c9994a9a4d79b824c3fd9322688303ac8b03 (diff) | |
parent | 6b10779053ff4233c7a64c5ab57754fce63f6710 (diff) | |
download | gitlab-ce-runner-metrics-extractor.tar.gz |
Merge branch 'master' of gitlab_gitlab:gitlab-org/gitlab-cerunner-metrics-extractor
Diffstat (limited to 'app/helpers/search_helper.rb')
-rw-r--r-- | app/helpers/search_helper.rb | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index f5c4686a3bf..91c83380b62 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -145,17 +145,27 @@ module SearchHelper Sanitize.clean(str) end - def search_filter_path(options = {}) - exist_opts = { - search: params[:search], - project_id: params[:project_id], - group_id: params[:group_id], - scope: params[:scope], - repository_ref: params[:repository_ref] - } + def search_filter_link(scope, label, data: {}, search: {}) + search_params = params + .merge(search) + .merge({ scope: scope }) + .permit(:search, :scope, :project_id, :group_id, :repository_ref, :snippets) + + if @scope == scope + li_class = 'active' + count = @search_results.formatted_count(scope) + else + badge_class = 'js-search-count hidden' + badge_data = { url: search_count_path(search_params) } + end - options = exist_opts.merge(options) - search_path(options) + content_tag :li, class: li_class, data: data do + link_to search_path(search_params) do + concat label + concat ' ' + concat content_tag(:span, count, class: ['badge badge-pill', badge_class], data: badge_data) + end + end end def search_filter_input_options(type) @@ -212,10 +222,6 @@ module SearchHelper sanitize(html, tags: %w(a p ol ul li pre code)) end - def limited_count(count, limit = 1000) - count > limit ? "#{limit}+" : count - end - def search_tabs?(tab) return false if Feature.disabled?(:users_search, default_enabled: true) |