Merge branch 'milestone_search' into 'master'
Ability to search milestones https://dev.gitlab.org/gitlab/gitlabhq/issues/2473 See merge request !1158
This commit is contained in:
commit
add099b024
8 changed files with 73 additions and 4 deletions
|
@ -11,6 +11,7 @@ v 8.0.0 (unreleased)
|
|||
- Allow configuration of import sources for new projects (Artem Sidorenko)
|
||||
- Search for comments should be case insensetive
|
||||
- Create cross-reference for closing references on commits pushed to non-default branches (Maël Valais)
|
||||
- Ability to search milestones
|
||||
|
||||
v 7.14.0
|
||||
- Fix bug where non-project members of the target project could set labels on new merge requests.
|
||||
|
|
|
@ -23,7 +23,7 @@ class SearchController < ApplicationController
|
|||
|
||||
@search_results =
|
||||
if @project
|
||||
unless %w(blobs notes issues merge_requests wiki_blobs).
|
||||
unless %w(blobs notes issues merge_requests milestones wiki_blobs).
|
||||
include?(@scope)
|
||||
@scope = 'blobs'
|
||||
end
|
||||
|
@ -36,7 +36,7 @@ class SearchController < ApplicationController
|
|||
|
||||
Search::SnippetService.new(current_user, params).execute
|
||||
else
|
||||
unless %w(projects issues merge_requests).include?(@scope)
|
||||
unless %w(projects issues merge_requests milestones).include?(@scope)
|
||||
@scope = 'projects'
|
||||
end
|
||||
Search::GlobalService.new(current_user, params).execute
|
||||
|
|
|
@ -47,6 +47,13 @@ class Milestone < ActiveRecord::Base
|
|||
state :active
|
||||
end
|
||||
|
||||
class << self
|
||||
def search(query)
|
||||
query = "%#{query}%"
|
||||
where("title like ? or description like ?", query, query)
|
||||
end
|
||||
end
|
||||
|
||||
def expired?
|
||||
if due_date
|
||||
due_date.past?
|
||||
|
|
|
@ -21,6 +21,13 @@
|
|||
Merge requests
|
||||
%span.badge
|
||||
= @search_results.merge_requests_count
|
||||
%li{class: ("active" if @scope == 'milestones')}
|
||||
= link_to search_filter_path(scope: 'milestones') do
|
||||
= icon('clock-o fw')
|
||||
%span
|
||||
Milestones
|
||||
%span.badge
|
||||
= @search_results.milestones_count
|
||||
%li{class: ("active" if @scope == 'notes')}
|
||||
= link_to search_filter_path(scope: 'notes') do
|
||||
= icon('comments fw')
|
||||
|
@ -74,4 +81,11 @@
|
|||
Merge requests
|
||||
%span.badge
|
||||
= @search_results.merge_requests_count
|
||||
%li{class: ("active" if @scope == 'milestones')}
|
||||
= link_to search_filter_path(scope: 'milestones') do
|
||||
= icon('clock-o fw')
|
||||
%span
|
||||
Milestones
|
||||
%span.badge
|
||||
= @search_results.milestones_count
|
||||
|
||||
|
|
9
app/views/search/results/_milestone.html.haml
Normal file
9
app/views/search/results/_milestone.html.haml
Normal file
|
@ -0,0 +1,9 @@
|
|||
.search-result-row
|
||||
%h4
|
||||
= link_to [milestone.project.namespace.becomes(Namespace), milestone.project, milestone] do
|
||||
%span.term.str-truncated= milestone.title
|
||||
|
||||
- if milestone.description.present?
|
||||
.description.term
|
||||
= preserve do
|
||||
= search_md_sanitize(markdown(milestone.description))
|
|
@ -23,6 +23,13 @@ Feature: Search
|
|||
Then I should see "Foo" link in the search results
|
||||
And I should not see "Bar" link in the search results
|
||||
|
||||
Scenario: I should see milestones I am looking for
|
||||
And project has milestones
|
||||
When I search for "Foo"
|
||||
When I click "Milestones" link
|
||||
Then I should see "Foo" link in the search results
|
||||
And I should not see "Bar" link in the search results
|
||||
|
||||
Scenario: I should see project code I am looking for
|
||||
When I click project "Shop" link
|
||||
And I search for "rspec"
|
||||
|
@ -44,6 +51,14 @@ Feature: Search
|
|||
Then I should see "Foo" link in the search results
|
||||
And I should not see "Bar" link in the search results
|
||||
|
||||
Scenario: I should see project milestones
|
||||
And project has milestones
|
||||
When I click project "Shop" link
|
||||
And I search for "Foo"
|
||||
And I click "Milestones" link
|
||||
Then I should see "Foo" link in the search results
|
||||
And I should not see "Bar" link in the search results
|
||||
|
||||
Scenario: I should see Wiki blobs
|
||||
And project has Wiki content
|
||||
When I click project "Shop" link
|
||||
|
|
|
@ -41,6 +41,12 @@ class Spinach::Features::Search < Spinach::FeatureSteps
|
|||
end
|
||||
end
|
||||
|
||||
step 'I click "Milestones" link' do
|
||||
page.within '.search-filter' do
|
||||
click_link 'Milestones'
|
||||
end
|
||||
end
|
||||
|
||||
step 'I click "Wiki" link' do
|
||||
page.within '.search-filter' do
|
||||
click_link 'Wiki'
|
||||
|
@ -72,6 +78,11 @@ class Spinach::Features::Search < Spinach::FeatureSteps
|
|||
create(:merge_request, :simple, title: "Bar", source_project: project, target_project: project)
|
||||
end
|
||||
|
||||
step 'project has milestones' do
|
||||
create(:milestone, title: "Foo", project: project)
|
||||
create(:milestone, title: "Bar", project: project)
|
||||
end
|
||||
|
||||
step 'I should see "Foo" link in the search results' do
|
||||
page.within('.results') do
|
||||
find(:css, '.search-results').should have_link 'Foo'
|
||||
|
|
|
@ -19,13 +19,15 @@ module Gitlab
|
|||
issues.page(page).per(per_page)
|
||||
when 'merge_requests'
|
||||
merge_requests.page(page).per(per_page)
|
||||
when 'milestones'
|
||||
milestones.page(page).per(per_page)
|
||||
else
|
||||
Kaminari.paginate_array([]).page(page).per(per_page)
|
||||
end
|
||||
end
|
||||
|
||||
def total_count
|
||||
@total_count ||= projects_count + issues_count + merge_requests_count
|
||||
@total_count ||= projects_count + issues_count + merge_requests_count + milestones_count
|
||||
end
|
||||
|
||||
def projects_count
|
||||
|
@ -40,6 +42,10 @@ module Gitlab
|
|||
@merge_requests_count ||= merge_requests.count
|
||||
end
|
||||
|
||||
def milestones_count
|
||||
@milestones_count ||= milestones.count
|
||||
end
|
||||
|
||||
def empty?
|
||||
total_count.zero?
|
||||
end
|
||||
|
@ -60,6 +66,12 @@ module Gitlab
|
|||
issues.order('updated_at DESC')
|
||||
end
|
||||
|
||||
def milestones
|
||||
milestones = Milestone.where(project_id: limit_project_ids)
|
||||
milestones = milestones.search(query)
|
||||
milestones.order('updated_at DESC')
|
||||
end
|
||||
|
||||
def merge_requests
|
||||
merge_requests = MergeRequest.in_projects(limit_project_ids)
|
||||
if query =~ /[#!](\d+)\z/
|
||||
|
|
Loading…
Reference in a new issue