Commit d1c9a0f1 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'search-issues-by-number' into 'master'

Add search issues/MR by number

It allows user to search issues/MR by number, e.g. `#3`.

Solves this [request](http://feedback.gitlab.com/forums/176466-general/suggestions/4235923-search-issues-by-number).

See merge request !668
parents c74b49c2 241f5971
......@@ -45,7 +45,7 @@ v 7.11.0 (unreleased)
- Fix bug where Slack service channel was not saved in admin template settings. (Stan Hu)
- Protect OmniAuth request phase against CSRF.
- Don't send notifications to mentioned users that don't have access to the project in question.
-
- Add search issues/MR by number
- Move snippets UI to fluid layout
- Improve UI for sidebar. Increase separation between navigation and content
- Improve new project command options (Ben Bodenmiller)
......
......@@ -19,7 +19,15 @@ class Projects::IssuesController < Projects::ApplicationController
def index
terms = params['issue_search']
@issues = get_issues_collection
@issues = @issues.full_search(terms) if terms.present?
if terms.present?
if terms =~ /\A#(\d+)\z/
@issues = @issues.where(iid: $1)
else
@issues = @issues.full_search(terms)
end
end
@issues = @issues.page(params[:page]).per(PER_PAGE)
respond_to do |format|
......
......@@ -19,7 +19,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def index
terms = params['issue_search']
@merge_requests = get_merge_requests_collection
@merge_requests = @merge_requests.full_search(terms) if terms.present?
if terms.present?
if terms =~ /\A[#!](\d+)\z/
@merge_requests = @merge_requests.where(iid: $1)
else
@merge_requests = @merge_requests.full_search(terms)
end
end
@merge_requests = @merge_requests.page(params[:page]).per(PER_PAGE)
respond_to do |format|
......
......@@ -51,11 +51,23 @@ module Gitlab
end
def issues
Issue.where(project_id: limit_project_ids).full_search(query).order('updated_at DESC')
issues = Issue.where(project_id: limit_project_ids)
if query =~ /#(\d+)\z/
issues = issues.where(iid: $1)
else
issues = issues.full_search(query)
end
issues.order('updated_at DESC')
end
def merge_requests
MergeRequest.in_projects(limit_project_ids).full_search(query).order('updated_at DESC')
merge_requests = MergeRequest.in_projects(limit_project_ids)
if query =~ /[#!](\d+)\z/
merge_requests = merge_requests.where(iid: $1)
else
merge_requests = merge_requests.full_search(query)
end
merge_requests.order('updated_at DESC')
end
def default_scope
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment