MergeRequest#new 2 step process
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
23de3551ab
commit
05e63fe09c
3 changed files with 133 additions and 3 deletions
69
app/views/projects/merge_requests/_new_compare.html.haml
Normal file
69
app/views/projects/merge_requests/_new_compare.html.haml
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
%h3.page-title Compare changes for new merge request
|
||||||
|
%hr
|
||||||
|
|
||||||
|
= form_for [@project, @merge_request], url: new_project_merge_request_path(@project), method: :get, html: { class: "merge-request-form form-inline" } do |f|
|
||||||
|
.merge-request-branches.row
|
||||||
|
.col-md-6
|
||||||
|
.panel.panel-default
|
||||||
|
.panel-heading
|
||||||
|
From
|
||||||
|
.panel-body
|
||||||
|
= 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_branch, @merge_request.source_branches, { include_blank: "Select branch" }, {class: 'source_branch select2 span2'})
|
||||||
|
.panel-footer
|
||||||
|
.mr_source_commit
|
||||||
|
|
||||||
|
.col-md-6
|
||||||
|
.panel.panel-default
|
||||||
|
.panel-heading
|
||||||
|
To
|
||||||
|
.panel-body
|
||||||
|
- projects = @project.forked_from_project.nil? ? [@project] : [@project, @project.forked_from_project]
|
||||||
|
= f.select(:target_project_id, options_from_collection_for_select(projects, 'id', 'path_with_namespace', f.object.target_project_id), {}, { class: 'target_project select2 span3', disabled: @merge_request.persisted? })
|
||||||
|
|
||||||
|
= f.select(:target_branch, @merge_request.target_branches, { include_blank: "Select branch" }, {class: 'target_branch select2 span2'})
|
||||||
|
.panel-footer
|
||||||
|
.mr_target_commit
|
||||||
|
|
||||||
|
-if @merge_request.errors.any?
|
||||||
|
.alert.alert-danger
|
||||||
|
- @merge_request.errors.full_messages.each do |msg|
|
||||||
|
%div= msg
|
||||||
|
|
||||||
|
- if @merge_request.source_branch.present? && @merge_request.target_branch.present?
|
||||||
|
.light-well
|
||||||
|
%center
|
||||||
|
%h4
|
||||||
|
There isn't anything to merge.
|
||||||
|
%p.slead
|
||||||
|
- if @merge_request.source_branch == @merge_request.target_branch
|
||||||
|
You'll need to use different branch names to get a valid comparison.
|
||||||
|
- else
|
||||||
|
%span.label-branch #{@merge_request.source_branch}
|
||||||
|
and
|
||||||
|
%span.label-branch #{@merge_request.target_branch}
|
||||||
|
are the same.
|
||||||
|
|
||||||
|
.form-actions
|
||||||
|
= f.submit 'Compare branches', class: "btn btn-primary"
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
var source_branch = $("#merge_request_source_branch")
|
||||||
|
, target_branch = $("#merge_request_target_branch")
|
||||||
|
, target_project = $("#merge_request_target_project_id");
|
||||||
|
|
||||||
|
$.get("#{branch_from_project_merge_requests_path(@source_project)}", {ref: source_branch.val() });
|
||||||
|
$.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: target_branch.val() });
|
||||||
|
|
||||||
|
target_project.on("change", function() {
|
||||||
|
$.get("#{update_branches_project_merge_requests_path(@source_project)}", {target_project_id: $(this).val() });
|
||||||
|
});
|
||||||
|
source_branch.on("change", function() {
|
||||||
|
$.get("#{branch_from_project_merge_requests_path(@source_project)}", {ref: $(this).val() });
|
||||||
|
});
|
||||||
|
target_branch.on("change", function() {
|
||||||
|
$.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: $(this).val() });
|
||||||
|
});
|
||||||
|
|
||||||
|
|
60
app/views/projects/merge_requests/_new_submit.html.haml
Normal file
60
app/views/projects/merge_requests/_new_submit.html.haml
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
%h3.page-title
|
||||||
|
New merge request
|
||||||
|
%p.slead
|
||||||
|
From
|
||||||
|
%strong.monospace
|
||||||
|
#{@merge_request.source_project_namespace}:#{@merge_request.source_branch}
|
||||||
|
into
|
||||||
|
%strong.monospace
|
||||||
|
#{@merge_request.target_project_namespace}:#{@merge_request.target_branch}
|
||||||
|
|
||||||
|
%span.pull-right
|
||||||
|
= link_to 'Change branches', new_project_merge_request_path(@project)
|
||||||
|
|
||||||
|
= form_for [@project, @merge_request], html: { class: "merge-request-form" } do |f|
|
||||||
|
.panel.panel-default
|
||||||
|
|
||||||
|
.panel-body
|
||||||
|
.form-group
|
||||||
|
.light
|
||||||
|
= f.label :title do
|
||||||
|
= "Title *"
|
||||||
|
= f.text_field :title, class: "form-control input-lg js-gfm-input", maxlength: 255, rows: 5, required: true
|
||||||
|
.form-group
|
||||||
|
.light
|
||||||
|
= f.label :description, "Description"
|
||||||
|
= f.text_area :description, class: "form-control js-gfm-input", rows: 10
|
||||||
|
%p.hint Description is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}.
|
||||||
|
.panel-footer
|
||||||
|
- if @target_repo.contribution_guide
|
||||||
|
- contribution_guide_url = project_blob_path(@target_project, tree_join(@target_repo.root_ref, @target_repo.contribution_guide.name))
|
||||||
|
%p
|
||||||
|
Please review the
|
||||||
|
%strong #{link_to "guidelines for contribution", contribution_guide_url}
|
||||||
|
to this repository.
|
||||||
|
= f.hidden_field :source_project_id
|
||||||
|
= f.hidden_field :target_project_id
|
||||||
|
= f.hidden_field :target_branch
|
||||||
|
= f.hidden_field :source_branch
|
||||||
|
= f.submit 'Submit a merge request', class: "btn btn-create"
|
||||||
|
|
||||||
|
.mr-compare
|
||||||
|
%div.ui-box
|
||||||
|
.title
|
||||||
|
Commits (#{@commits.count})
|
||||||
|
- if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE
|
||||||
|
%ul.well-list
|
||||||
|
- Commit.decorate(@commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE)).each do |commit|
|
||||||
|
= render "projects/commits/inline_commit", commit: commit, project: @project
|
||||||
|
%li.warning-row.unstyled
|
||||||
|
other #{@commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE} commits hidden to prevent performance issues.
|
||||||
|
- else
|
||||||
|
%ul.well-list= render Commit.decorate(@commits), project: @project
|
||||||
|
|
||||||
|
%h4 Changes
|
||||||
|
- if @diffs.present?
|
||||||
|
= render "projects/commits/diffs", diffs: @diffs, project: @project
|
||||||
|
- elsif @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE
|
||||||
|
.bs-callout.bs-callout-danger
|
||||||
|
%h4 This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits.
|
||||||
|
%p To preserve performance the line changes are not shown.
|
|
@ -1,3 +1,4 @@
|
||||||
%h3.page-title New Merge Request
|
- if @commits.present?
|
||||||
%hr
|
= render 'new_submit'
|
||||||
= render 'form'
|
- else
|
||||||
|
= render 'new_compare'
|
||||||
|
|
Loading…
Reference in a new issue