Add Milestone information in Merge Requests
Step 1: * Add milestone_id in the model for merge_requests * Make it possible to create or update a Merge Request with an attached Milestone detail * Add the possibility to filter by Milestone and / or Assignee in the Merge Requests listing page
This commit is contained in:
parent
4f687aaa8e
commit
a7d0816933
8 changed files with 93 additions and 22 deletions
|
@ -115,4 +115,15 @@ var MergeRequest = {
|
|||
$(".merge_in_progress").hide();
|
||||
$(".automerge_widget.already_cannot_be_merged").show();
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Filter merge requests
|
||||
*/
|
||||
function merge_requestsPage() {
|
||||
$("#assignee_id").chosen();
|
||||
$("#milestone_id").chosen();
|
||||
$("#milestone_id, #assignee_id").on("change", function(){
|
||||
$(this).closest("form").submit();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -121,3 +121,20 @@ li.merge_request {
|
|||
.mr_direction_tip {
|
||||
margin-top:40px
|
||||
}
|
||||
|
||||
.merge_requests_form_box {
|
||||
@extend .main_box;
|
||||
.merge_requests_middle_box {
|
||||
@extend .middle_box_content;
|
||||
height:30px;
|
||||
.merge_requests_assignee {
|
||||
@extend .span6;
|
||||
float:left;
|
||||
}
|
||||
.merge_requests_milestone {
|
||||
@extend .span4;
|
||||
float:left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ class MergeRequestsLoadContext < BaseContext
|
|||
def execute
|
||||
type = params[:f]
|
||||
|
||||
merge_requests = project.merge_requests
|
||||
merge_requests = @project.merge_requests
|
||||
|
||||
merge_requests = case type
|
||||
when 'all' then merge_requests
|
||||
|
@ -12,5 +12,18 @@ class MergeRequestsLoadContext < BaseContext
|
|||
end.page(params[:page]).per(20)
|
||||
|
||||
merge_requests.includes(:author, :project).order("closed, created_at desc")
|
||||
|
||||
@merge_requests = merge_requests
|
||||
|
||||
# Filter by specific assignee_id (or lack thereof)?
|
||||
if params[:assignee_id].present?
|
||||
@merge_requests = merge_requests.where(assignee_id: (params[:assignee_id] == '0' ? nil : params[:assignee_id]))
|
||||
end
|
||||
|
||||
# Filter by specific milestone_id (or lack thereof)?
|
||||
if params[:milestone_id].present?
|
||||
@merge_requests = merge_requests.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id]))
|
||||
end
|
||||
@merge_requests
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,11 +4,13 @@ class MergeRequest < ActiveRecord::Base
|
|||
include IssueCommonality
|
||||
include Votes
|
||||
|
||||
attr_accessible :title, :assignee_id, :closed, :target_branch, :source_branch,
|
||||
attr_accessible :title, :assignee_id, :closed, :target_branch, :source_branch, :milestone_id,
|
||||
:author_id_of_changes
|
||||
|
||||
attr_accessor :should_remove_source_branch
|
||||
|
||||
belongs_to :milestone
|
||||
|
||||
BROKEN_DIFF = "--broken-diff"
|
||||
|
||||
UNCHECKED = 1
|
||||
|
@ -26,6 +28,10 @@ class MergeRequest < ActiveRecord::Base
|
|||
where("source_branch LIKE :branch OR target_branch LIKE :branch", branch: branch_name)
|
||||
end
|
||||
|
||||
def self.find_all_by_milestone(milestone)
|
||||
where("milestone_id = :milestone_id", milestone_id: milestone)
|
||||
end
|
||||
|
||||
def human_state
|
||||
states = {
|
||||
CAN_BE_MERGED => "can_be_merged",
|
||||
|
@ -212,5 +218,6 @@ end
|
|||
# st_diffs :text(4294967295
|
||||
# merged :boolean default(FALSE), not null
|
||||
# state :integer default(1), not null
|
||||
# milestone_id :integer
|
||||
#
|
||||
|
||||
|
|
|
@ -28,16 +28,22 @@
|
|||
%h4.cdark 2. Fill info
|
||||
|
||||
.clearfix
|
||||
.main_box
|
||||
.merge_requests_form_box
|
||||
.top_box_content
|
||||
= f.label :title do
|
||||
%strong= "Title *"
|
||||
.input= f.text_field :title, class: "input-xxlarge pad gfm-input", maxlength: 255, rows: 5
|
||||
.middle_box_content
|
||||
= f.label :assignee_id do
|
||||
%i.icon-user
|
||||
Assign to
|
||||
.input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'})
|
||||
.merge_requests_middle_box
|
||||
.merge_requests_assignee
|
||||
= f.label :assignee_id do
|
||||
%i.icon-user
|
||||
Assign to
|
||||
.input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'})
|
||||
.merge_requests_milestone
|
||||
= f.label :milestone_id do
|
||||
%i.icon-time
|
||||
Milestone
|
||||
.input= f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'})
|
||||
|
||||
.control-group
|
||||
|
||||
|
|
|
@ -9,19 +9,26 @@
|
|||
|
||||
.ui-box
|
||||
.title
|
||||
%ul.nav.nav-pills
|
||||
%li{class: ("active" if (params[:f] == 'open' || !params[:f]))}
|
||||
= link_to project_merge_requests_path(@project, f: 'open') do
|
||||
Open
|
||||
%li{class: ("active" if params[:f] == "closed")}
|
||||
= link_to project_merge_requests_path(@project, f: "closed") do
|
||||
Closed
|
||||
%li{class: ("active" if params[:f] == 'assigned-to-me')}
|
||||
= link_to project_merge_requests_path(@project, f: 'assigned-to-me') do
|
||||
To Me
|
||||
%li{class: ("active" if params[:f] == 'all')}
|
||||
= link_to project_merge_requests_path(@project, f: 'all') do
|
||||
All
|
||||
.left
|
||||
%ul.nav.nav-pills
|
||||
%li{class: ("active" if (params[:f] == 'open' || !params[:f]))}
|
||||
= link_to project_merge_requests_path(@project, f: 'open', milestone_id: params[:milestone_id]) do
|
||||
Open
|
||||
%li{class: ("active" if params[:f] == "closed")}
|
||||
= link_to project_merge_requests_path(@project, f: "closed", milestone_id: params[:milestone_id]) do
|
||||
Closed
|
||||
%li{class: ("active" if params[:f] == 'assigned-to-me')}
|
||||
= link_to project_merge_requests_path(@project, f: 'assigned-to-me', milestone_id: params[:milestone_id]) do
|
||||
To Me
|
||||
%li{class: ("active" if params[:f] == 'all')}
|
||||
= link_to project_merge_requests_path(@project, f: 'all', milestone_id: params[:milestone_id]) do
|
||||
All
|
||||
.right
|
||||
= form_tag project_merge_requests_path(@project), id: "merge_requests_search_form", method: :get, class: :right do
|
||||
= select_tag(:assignee_id, options_from_collection_for_select([unassigned_filter] + @project.users.all, "id", "name", params[:assignee_id]), prompt: "Assignee")
|
||||
= select_tag(:milestone_id, options_from_collection_for_select([unassigned_filter] + @project.milestones.order("id desc").all, "id", "title", params[:milestone_id]), prompt: "Milestone")
|
||||
= hidden_field_tag :f, params[:f]
|
||||
.clearfix
|
||||
|
||||
%ul.unstyled
|
||||
= render @merge_requests
|
||||
|
@ -35,3 +42,7 @@
|
|||
.span4.right
|
||||
%span.cgray.right #{@merge_requests.total_count} merge requests for this filter
|
||||
|
||||
:javascript
|
||||
$(function() {
|
||||
merge_requestsPage();
|
||||
})
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddMilestoneIdToMergeRequests < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :merge_requests, :milestone_id, :integer, :null => true
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20121009205010) do
|
||||
ActiveRecord::Schema.define(:version => 20121026114600) do
|
||||
|
||||
create_table "events", :force => true do |t|
|
||||
t.string "target_type"
|
||||
|
@ -73,6 +73,7 @@ ActiveRecord::Schema.define(:version => 20121009205010) do
|
|||
t.text "st_diffs", :limit => 2147483647
|
||||
t.boolean "merged", :default => false, :null => false
|
||||
t.integer "state", :default => 1, :null => false
|
||||
t.integer "milestone_id"
|
||||
end
|
||||
|
||||
add_index "merge_requests", ["project_id"], :name => "index_merge_requests_on_project_id"
|
||||
|
|
Loading…
Reference in a new issue