- page_title "Protected branches"
%h3.page-title Protected branches
%p.light Keep stable branches secure and force developers to use Merge Requests
%hr

.well
  %p Protected branches are designed to
  %ul
    %li prevent pushes from everybody except #{link_to "masters", help_page_path("permissions", "permissions"), class: "vlink"}
    %li prevent anyone from force pushing to the branch
    %li prevent anyone from deleting the branch
  %p Read more about #{link_to "project permissions", help_page_path("permissions", "permissions"), class: "underlined-link"}

- if can? current_user, :admin_project, @project
  = form_for [@project.namespace.becomes(Namespace), @project, @protected_branch], html: { class: 'form-horizontal' } do |f|
    -if @protected_branch.errors.any?
      .alert.alert-danger
        %ul
          - @protected_branch.errors.full_messages.each do |msg|
            %li= msg

    .form-group
      = f.label :name, "Branch", class: 'control-label'
      .col-sm-10
        = f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: true}, {class: "select2", data: {placeholder: "Select branch"}})
    .form-group
      .col-sm-offset-2.col-sm-10
        .checkbox
          = f.label :developers_can_push do
            = f.check_box :developers_can_push
            %strong Developers can push
          .help-block Allow developers to push to this branch
    .form-actions
      = f.submit 'Protect', class: "btn-create btn"
= render 'branches_list'
