diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-02 15:10:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-02 15:10:35 +0300 |
commit | 4fa04f789e6fed5f0dfeafe718eeb7f56a5086e9 (patch) | |
tree | 5ef2d1d8232d3bd359ec79bf95c9a35ce650ae0b /app/helpers/search_helper.rb | |
parent | 4b9ace6c1fead1b44f173eaee0cfaa58f46a258a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/helpers/search_helper.rb')
-rw-r--r-- | app/helpers/search_helper.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index d3a34dc38c0..61e0fe19c77 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -7,6 +7,7 @@ module SearchHelper return unless current_user resources_results = [ + recent_issues_autocomplete(term), groups_autocomplete(term), projects_autocomplete(term) ].flatten @@ -178,6 +179,20 @@ module SearchHelper } end end + + def recent_issues_autocomplete(term, limit = 5) + return [] unless current_user + + ::Gitlab::Search::RecentIssues.new(user: current_user).search(term).limit(limit).map do |i| + { + category: "Recent issues", + id: i.id, + label: search_result_sanitize(i.title), + url: issue_path(i), + avatar_url: i.project.avatar_url || '' + } + end + end # rubocop: enable CodeReuse/ActiveRecord def search_result_sanitize(str) |