Commit 07956981 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'new-mr-disable-change-target-branch' into 'master'

Disable changing of target branch in new merge request page when a branch has already been specified

### What does this MR do?

This MR prevents a user from changing the target branch inside a new merge request page if the target branch has already been specified (e.g. from the shortcut in the activity feed). A link to "Change branches" is provided to allow the user to do this properly.

### Why was this MR needed?

If a user attempted to create a merge request from a shortcut with a pre-specified target branch (e.g. `master`), the dropdown would suggest that the user could change the branch. However, this did not actually work due to duplicate data elements (see #1830 for more details), and the target branch would always be set to the original, default branch. This would lead to confusion, potentially causing an improper merge request to be created.

### What are the relevant issue numbers?

Closes #1830

### Screenshot

![image](https://gitlab.com/stanhu/gitlab-ce/uploads/eeec4f5d4b66625a14be41e5ecbdc016/image.png)

See merge request !846
parents b2eef41d c8d4a408
...@@ -11,6 +11,7 @@ v 7.13.0 (unreleased) ...@@ -11,6 +11,7 @@ v 7.13.0 (unreleased)
v 7.12.0 (unreleased) v 7.12.0 (unreleased)
- Fix Error 500 when one user attempts to access a personal, internal snippet (Stan Hu) - Fix Error 500 when one user attempts to access a personal, internal snippet (Stan Hu)
- Disable changing of target branch in new merge request page when a branch has already been specified (Stan Hu)
- Fix post-receive errors on a push when an external issue tracker is configured (Stan Hu) - Fix post-receive errors on a push when an external issue tracker is configured (Stan Hu)
- Update oauth button logos for Twitter and Google to recommended assets - Update oauth button logos for Twitter and Google to recommended assets
- Fix hooks for web based events with external issue references (Daniel Gerhardt) - Fix hooks for web based events with external issue references (Daniel Gerhardt)
......
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
- if issuable.is_a?(MergeRequest) - if issuable.is_a?(MergeRequest)
%p.help-block %p.help-block
- if issuable.work_in_progress? - if issuable.work_in_progress?
Remove the <code>WIP</code> prefix from the title to allow this Remove the <code>WIP</code> prefix from the title to allow this
<strong>Work In Progress</strong> merge request to be accepted when it's ready. <strong>Work In Progress</strong> merge request to be accepted when it's ready.
- else - else
Start the title with <code>[WIP]</code> or <code>WIP:</code> to prevent a Start the title with <code>[WIP]</code> or <code>WIP:</code> to prevent a
<strong>Work In Progress</strong> merge request from being accepted before it's ready. <strong>Work In Progress</strong> merge request from being accepted before it's ready.
.form-group.issuable-description .form-group.issuable-description
= f.label :description, 'Description', class: 'control-label' = f.label :description, 'Description', class: 'control-label'
...@@ -81,21 +81,22 @@ ...@@ -81,21 +81,22 @@
- if issuable.is_a?(MergeRequest) - if issuable.is_a?(MergeRequest)
%hr %hr
- unless @merge_request.persisted? - if @merge_request.new_record?
.form-group .form-group
= f.label :source_branch, class: 'control-label' do = f.label :source_branch, class: 'control-label' do
%i.fa.fa-code-fork %i.fa.fa-code-fork
Source Branch Source Branch
.col-sm-10 .col-sm-10
= f.select(:source_branch, [@merge_request.source_branch], { }, { class: 'source_branch select2 span2', disabled: true }) = f.select(:source_branch, [@merge_request.source_branch], { }, { class: 'source_branch select2 span2', disabled: true })
%p.help-block
= link_to 'Change source branch', mr_change_branches_path(@merge_request)
.form-group .form-group
= f.label :target_branch, class: 'control-label' do = f.label :target_branch, class: 'control-label' do
%i.fa.fa-code-fork %i.fa.fa-code-fork
Target Branch Target Branch
.col-sm-10 .col-sm-10
= f.select(:target_branch, @merge_request.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', disabled: @merge_request.new_record? })
- if @merge_request.new_record?
%p.help-block
= link_to 'Change branches', mr_change_branches_path(@merge_request)
.form-actions .form-actions
- if !issuable.project.empty_repo? && (guide_url = contribution_guide_url(issuable.project)) && !issuable.persisted? - if !issuable.project.empty_repo? && (guide_url = contribution_guide_url(issuable.project)) && !issuable.persisted?
......
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