BigW Consortium Gitlab

_new_compare.html.haml 4.32 KB
Newer Older
1 2
%h3.page-title
  New Merge Request
3

4
= form_for [@project.namespace.becomes(Namespace), @project, @merge_request], url: new_namespace_project_merge_request_path(@project.namespace, @project), method: :get, html: { class: "merge-request-form form-inline js-requires-input" } do |f|
5
  .hide.alert.alert-danger.mr-compare-errors
6 7
  .merge-request-branches.row
    .col-md-6
8
      .panel.panel-default.panel-new-merge-request
9
        .panel-heading
10 11
          Source branch
        .panel-body.clearfix
12 13 14
          .merge-request-select.dropdown
            = f.hidden_field :source_project_id
            = dropdown_toggle @merge_request.source_project_path, { toggle: "dropdown", field_name: "#{f.object_name}[source_project_id]", disabled: @merge_request.persisted? }, { toggle_class: "js-compare-dropdown js-source-project" }
Phil Hughes committed
15
            .dropdown-menu.dropdown-menu-selectable.dropdown-source-project
16 17 18
              = dropdown_title("Select source project")
              = dropdown_filter("Search projects")
              = dropdown_content do
Phil Hughes committed
19
                = render 'projects/merge_requests/dropdowns/project',
Phil Hughes committed
20 21
                  projects: [@merge_request.source_project],
                  selected: f.object.source_project_id
22 23
          .merge-request-select.dropdown
            = f.hidden_field :source_branch
24
            = dropdown_toggle local_assigns.fetch(f.object.source_branch, "Select source branch"), { toggle: "dropdown", field_name: "#{f.object_name}[source_branch]" }, { toggle_class: "js-compare-dropdown js-source-branch" }
Phil Hughes committed
25
            .dropdown-menu.dropdown-menu-selectable.dropdown-source-branch
26 27 28
              = dropdown_title("Select source branch")
              = dropdown_filter("Search branches")
              = dropdown_content do
Phil Hughes committed
29
                = render 'projects/merge_requests/dropdowns/branch',
Phil Hughes committed
30 31
                  branches: @merge_request.source_branches,
                  selected: f.object.source_branch
32
        .panel-footer
33
          .text-center= icon('spinner spin', class: 'js-source-loading')
34
          %ul.list-unstyled.mr_source_commit
35 36

    .col-md-6
37
      .panel.panel-default.panel-new-merge-request
38
        .panel-heading
39 40
          Target branch
        .panel-body.clearfix
41
          - projects =  @project.forked_from_project.nil? ? [@project] : [@project, @project.forked_from_project]
42 43
          .merge-request-select.dropdown
            = f.hidden_field :target_project_id
44
            = dropdown_toggle f.object.target_project.path_with_namespace, { toggle: "dropdown", field_name: "#{f.object_name}[target_project_id]", disabled: @merge_request.persisted? }, { toggle_class: "js-compare-dropdown js-target-project" }
Phil Hughes committed
45
            .dropdown-menu.dropdown-menu-selectable.dropdown-target-project
46 47 48
              = dropdown_title("Select target project")
              = dropdown_filter("Search projects")
              = dropdown_content do
Phil Hughes committed
49
                = render 'projects/merge_requests/dropdowns/project',
Phil Hughes committed
50 51
                  projects: projects,
                  selected: f.object.target_project_id
52 53
          .merge-request-select.dropdown
            = f.hidden_field :target_branch
54
            = dropdown_toggle f.object.target_branch, { toggle: "dropdown", field_name: "#{f.object_name}[target_branch]" }, { toggle_class: "js-compare-dropdown js-target-branch" }
Phil Hughes committed
55
            .dropdown-menu.dropdown-menu-selectable.dropdown-target-branch.js-target-branch-dropdown
56 57 58
              = dropdown_title("Select target branch")
              = dropdown_filter("Search branches")
              = dropdown_content do
Phil Hughes committed
59
                = render 'projects/merge_requests/dropdowns/branch',
Phil Hughes committed
60 61
                  branches: @merge_request.target_branches,
                  selected: f.object.target_branch
62
        .panel-footer
63
          .text-center= icon('spinner spin', class: "js-target-loading")
64
          %ul.list-unstyled.mr_target_commit
65

66
  - if @merge_request.errors.any?
67
    = form_errors(@merge_request)
68
  = f.submit 'Compare branches and continue', class: "btn btn-new mr-compare-btn"
69

70
:javascript
71 72 73 74
  new Compare({
    targetProjectUrl: "#{update_branches_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}",
    sourceBranchUrl: "#{branch_from_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}",
    targetBranchUrl: "#{branch_to_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}"
75
  });