Commit 5e004719 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'bug/broken_mr_select' into 'master'

Fix broken merge request select

Fixes #991
parents 9e181d36 f416b2f5
...@@ -60,7 +60,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -60,7 +60,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request = MergeRequest.new(params[:merge_request]) @merge_request = MergeRequest.new(params[:merge_request])
@merge_request.source_project = @project unless @merge_request.source_project @merge_request.source_project = @project unless @merge_request.source_project
@merge_request.target_project = @project unless @merge_request.target_project @merge_request.target_project = @project unless @merge_request.target_project
@target_branches = @merge_request.target_project.nil? ? [] : @merge_request.target_project.repository.branch_names
@source_project = @merge_request.source_project @source_project = @merge_request.source_project
@merge_request @merge_request
end end
...@@ -167,7 +166,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -167,7 +166,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
protected protected
def selected_target_project def selected_target_project
((@project.id.to_s == params[:target_project_id]) || @project.forked_project_link.nil?) ? @project : @project.forked_project_link.forked_from_project if @project.id.to_s == params[:target_project_id] || @project.forked_project_link.nil?
@project
else
@project.forked_project_link.forked_from_project
end
end end
def merge_request def merge_request
......
...@@ -253,4 +253,24 @@ class MergeRequest < ActiveRecord::Base ...@@ -253,4 +253,24 @@ class MergeRequest < ActiveRecord::Base
message << description.to_s message << description.to_s
message message
end end
# Return array of possible target branches
# dependes on target project of MR
def target_branches
if target_project.nil?
[]
else
target_project.repository.branch_names
end
end
# Return array of possible source branches
# dependes on source project of MR
def source_branches
if source_project.nil?
[]
else
source_project.repository.branch_names
end
end
end end
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
= f.select(:source_project_id, [[@merge_request.source_project_path,@merge_request.source_project.id]] , {}, { class: 'source_project select2 span3', disabled: @merge_request.persisted? }) = f.select(:source_project_id, [[@merge_request.source_project_path,@merge_request.source_project.id]] , {}, { class: 'source_project select2 span3', disabled: @merge_request.persisted? })
.pull-left .pull-left
&nbsp; &nbsp;
= f.select(:source_branch, @merge_request.source_project.repository.branch_names, { include_blank: "Select branch" }, {class: 'source_branch select2 span2'}) = f.select(:source_branch, @merge_request.source_branches, { include_blank: "Select branch" }, {class: 'source_branch select2 span2'})
.mr_source_commit.prepend-top-10 .mr_source_commit.prepend-top-10
.col-md-2 .col-md-2
.merge-request-angle .merge-request-angle
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
= f.select(:target_project_id, options_from_collection_for_select(projects, 'id', 'path_with_namespace'), {}, { class: 'target_project select2 span3', disabled: @merge_request.persisted? }) = f.select(:target_project_id, options_from_collection_for_select(projects, 'id', 'path_with_namespace'), {}, { class: 'target_project select2 span3', disabled: @merge_request.persisted? })
.pull-left .pull-left
&nbsp; &nbsp;
= f.select(:target_branch, @target_branches, { include_blank: "Select branch" }, {class: 'target_branch select2 span2'}) = f.select(:target_branch, @merge_request.target_branches, { include_blank: "Select branch" }, {class: 'target_branch select2 span2'})
.mr_target_commit.prepend-top-10 .mr_target_commit.prepend-top-10
%hr %hr
......
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