%h4
  Set by #{link_to_member(@project, @merge_request.merge_user, avatar: true)}
  to be merged automatically when the build succeeds.
%div
  - should_remove_source_branch = @merge_request.merge_params["should_remove_source_branch"].present?
  %p
    = succeed '.' do
      The changes will be merged into
      %span.label-branch= @merge_request.target_branch
    - if should_remove_source_branch
      The source branch will be removed.
    - else
      The source branch will not be removed.

  - remove_source_branch_button = @merge_request.can_remove_source_branch?(current_user) && !should_remove_source_branch && @merge_request.merge_user == current_user
  - user_can_cancel_automatic_merge = @merge_request.can_cancel_merge_when_build_succeeds?(current_user)
  - if remove_source_branch_button || user_can_cancel_automatic_merge
    .clearfix.prepend-top-10
      - if remove_source_branch_button
        = link_to merge_namespace_project_merge_request_path(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request, merge_when_build_succeeds: true, should_remove_source_branch: true), remote: true, method: :post, class: "btn btn-grouped btn-primary btn-sm remove_source_branch" do
          = icon('times')
          Remove Source Branch When Merged

      - if user_can_cancel_automatic_merge
        = link_to cancel_merge_when_build_succeeds_namespace_project_merge_request_path(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request), remote: true, method: :post, class: "btn btn-grouped btn-warning btn-sm" do
          Cancel Automatic Merge
