Skip to content
Snippets Groups Projects
Commit d1c9a0f1 authored by Douwe Maan's avatar Douwe Maan
Browse files

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
No related branches found
No related tags found
No related merge requests found
Loading
@@ -45,7 +45,7 @@ v 7.11.0 (unreleased)
Loading
@@ -45,7 +45,7 @@ v 7.11.0 (unreleased)
- Fix bug where Slack service channel was not saved in admin template settings. (Stan Hu) - Fix bug where Slack service channel was not saved in admin template settings. (Stan Hu)
- Protect OmniAuth request phase against CSRF. - Protect OmniAuth request phase against CSRF.
- Don't send notifications to mentioned users that don't have access to the project in question. - 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 - Move snippets UI to fluid layout
- Improve UI for sidebar. Increase separation between navigation and content - Improve UI for sidebar. Increase separation between navigation and content
- Improve new project command options (Ben Bodenmiller) - Improve new project command options (Ben Bodenmiller)
Loading
Loading
Loading
@@ -19,7 +19,15 @@ class Projects::IssuesController < Projects::ApplicationController
Loading
@@ -19,7 +19,15 @@ class Projects::IssuesController < Projects::ApplicationController
def index def index
terms = params['issue_search'] terms = params['issue_search']
@issues = get_issues_collection @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) @issues = @issues.page(params[:page]).per(PER_PAGE)
   
respond_to do |format| respond_to do |format|
Loading
Loading
Loading
@@ -19,7 +19,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
Loading
@@ -19,7 +19,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def index def index
terms = params['issue_search'] terms = params['issue_search']
@merge_requests = get_merge_requests_collection @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) @merge_requests = @merge_requests.page(params[:page]).per(PER_PAGE)
   
respond_to do |format| respond_to do |format|
Loading
Loading
Loading
@@ -51,11 +51,23 @@ module Gitlab
Loading
@@ -51,11 +51,23 @@ module Gitlab
end end
   
def issues 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 end
   
def merge_requests 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 end
   
def default_scope def default_scope
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment