Commit 05e63fe09c8a44ed14d4282db81d18927ce1a5ad
1 parent
23de3551
Exists in
spb-stable
and in
2 other branches
MergeRequest#new 2 step process
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
3 changed files
with
133 additions
and
3 deletions
Show diff stats
app/views/projects/merge_requests/_new_compare.html.haml
0 → 100644
... | ... | @@ -0,0 +1,69 @@ |
1 | +%h3.page-title Compare changes for new merge request | |
2 | +%hr | |
3 | + | |
4 | += form_for [@project, @merge_request], url: new_project_merge_request_path(@project), method: :get, html: { class: "merge-request-form form-inline" } do |f| | |
5 | + .merge-request-branches.row | |
6 | + .col-md-6 | |
7 | + .panel.panel-default | |
8 | + .panel-heading | |
9 | + From | |
10 | + .panel-body | |
11 | + = f.select(:source_project_id, [[@merge_request.source_project_path,@merge_request.source_project.id]] , {}, { class: 'source_project select2 span3', disabled: @merge_request.persisted? }) | |
12 | + | |
13 | + = f.select(:source_branch, @merge_request.source_branches, { include_blank: "Select branch" }, {class: 'source_branch select2 span2'}) | |
14 | + .panel-footer | |
15 | + .mr_source_commit | |
16 | + | |
17 | + .col-md-6 | |
18 | + .panel.panel-default | |
19 | + .panel-heading | |
20 | + To | |
21 | + .panel-body | |
22 | + - projects = @project.forked_from_project.nil? ? [@project] : [@project, @project.forked_from_project] | |
23 | + = 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? }) | |
24 | + | |
25 | + = f.select(:target_branch, @merge_request.target_branches, { include_blank: "Select branch" }, {class: 'target_branch select2 span2'}) | |
26 | + .panel-footer | |
27 | + .mr_target_commit | |
28 | + | |
29 | + -if @merge_request.errors.any? | |
30 | + .alert.alert-danger | |
31 | + - @merge_request.errors.full_messages.each do |msg| | |
32 | + %div= msg | |
33 | + | |
34 | + - if @merge_request.source_branch.present? && @merge_request.target_branch.present? | |
35 | + .light-well | |
36 | + %center | |
37 | + %h4 | |
38 | + There isn't anything to merge. | |
39 | + %p.slead | |
40 | + - if @merge_request.source_branch == @merge_request.target_branch | |
41 | + You'll need to use different branch names to get a valid comparison. | |
42 | + - else | |
43 | + %span.label-branch #{@merge_request.source_branch} | |
44 | + and | |
45 | + %span.label-branch #{@merge_request.target_branch} | |
46 | + are the same. | |
47 | + | |
48 | + .form-actions | |
49 | + = f.submit 'Compare branches', class: "btn btn-primary" | |
50 | + | |
51 | +:javascript | |
52 | + var source_branch = $("#merge_request_source_branch") | |
53 | + , target_branch = $("#merge_request_target_branch") | |
54 | + , target_project = $("#merge_request_target_project_id"); | |
55 | + | |
56 | + $.get("#{branch_from_project_merge_requests_path(@source_project)}", {ref: source_branch.val() }); | |
57 | + $.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: target_branch.val() }); | |
58 | + | |
59 | + target_project.on("change", function() { | |
60 | + $.get("#{update_branches_project_merge_requests_path(@source_project)}", {target_project_id: $(this).val() }); | |
61 | + }); | |
62 | + source_branch.on("change", function() { | |
63 | + $.get("#{branch_from_project_merge_requests_path(@source_project)}", {ref: $(this).val() }); | |
64 | + }); | |
65 | + target_branch.on("change", function() { | |
66 | + $.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: $(this).val() }); | |
67 | + }); | |
68 | + | |
69 | + | ... | ... |
... | ... | @@ -0,0 +1,60 @@ |
1 | +%h3.page-title | |
2 | + New merge request | |
3 | +%p.slead | |
4 | + From | |
5 | + %strong.monospace | |
6 | + #{@merge_request.source_project_namespace}:#{@merge_request.source_branch} | |
7 | + into | |
8 | + %strong.monospace | |
9 | + #{@merge_request.target_project_namespace}:#{@merge_request.target_branch} | |
10 | + | |
11 | + %span.pull-right | |
12 | + = link_to 'Change branches', new_project_merge_request_path(@project) | |
13 | + | |
14 | += form_for [@project, @merge_request], html: { class: "merge-request-form" } do |f| | |
15 | + .panel.panel-default | |
16 | + | |
17 | + .panel-body | |
18 | + .form-group | |
19 | + .light | |
20 | + = f.label :title do | |
21 | + = "Title *" | |
22 | + = f.text_field :title, class: "form-control input-lg js-gfm-input", maxlength: 255, rows: 5, required: true | |
23 | + .form-group | |
24 | + .light | |
25 | + = f.label :description, "Description" | |
26 | + = f.text_area :description, class: "form-control js-gfm-input", rows: 10 | |
27 | + %p.hint Description is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. | |
28 | + .panel-footer | |
29 | + - if @target_repo.contribution_guide | |
30 | + - contribution_guide_url = project_blob_path(@target_project, tree_join(@target_repo.root_ref, @target_repo.contribution_guide.name)) | |
31 | + %p | |
32 | + Please review the | |
33 | + %strong #{link_to "guidelines for contribution", contribution_guide_url} | |
34 | + to this repository. | |
35 | + = f.hidden_field :source_project_id | |
36 | + = f.hidden_field :target_project_id | |
37 | + = f.hidden_field :target_branch | |
38 | + = f.hidden_field :source_branch | |
39 | + = f.submit 'Submit a merge request', class: "btn btn-create" | |
40 | + | |
41 | +.mr-compare | |
42 | + %div.ui-box | |
43 | + .title | |
44 | + Commits (#{@commits.count}) | |
45 | + - if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE | |
46 | + %ul.well-list | |
47 | + - Commit.decorate(@commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE)).each do |commit| | |
48 | + = render "projects/commits/inline_commit", commit: commit, project: @project | |
49 | + %li.warning-row.unstyled | |
50 | + other #{@commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE} commits hidden to prevent performance issues. | |
51 | + - else | |
52 | + %ul.well-list= render Commit.decorate(@commits), project: @project | |
53 | + | |
54 | + %h4 Changes | |
55 | + - if @diffs.present? | |
56 | + = render "projects/commits/diffs", diffs: @diffs, project: @project | |
57 | + - elsif @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE | |
58 | + .bs-callout.bs-callout-danger | |
59 | + %h4 This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits. | |
60 | + %p To preserve performance the line changes are not shown. | ... | ... |
app/views/projects/merge_requests/new.html.haml