Commit a3d6b610 authored by Phil Hughes's avatar Phil Hughes

Protected branches UI

Closes #14027
parent 6ff740ff
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
.prepend-top-10 { margin-top: 10px } .prepend-top-10 { margin-top: 10px }
.prepend-top-default { margin-top: $gl-padding !important; } .prepend-top-default { margin-top: $gl-padding !important; }
.prepend-top-20 { margin-top: 20px } .prepend-top-20 { margin-top: 20px }
.prepend-left-5 { margin-left: 5px }
.prepend-left-10 { margin-left: 10px } .prepend-left-10 { margin-left: 10px }
.prepend-left-default { margin-left: $gl-padding; } .prepend-left-default { margin-left: $gl-padding; }
.prepend-left-20 { margin-left: 20px } .prepend-left-20 { margin-left: 20px }
......
...@@ -205,6 +205,10 @@ h1, h2, h3, h4, h5, h6 { ...@@ -205,6 +205,10 @@ h1, h2, h3, h4, h5, h6 {
font-weight: 600; font-weight: 600;
} }
.light-header {
font-weight: 600;
}
/** CODE **/ /** CODE **/
pre { pre {
font-family: $monospace_font; font-family: $monospace_font;
......
...@@ -256,12 +256,6 @@ ...@@ -256,12 +256,6 @@
} }
} }
table.table.protected-branches-list tr.no-border {
th, td {
border: 0;
}
}
.project-import .btn { .project-import .btn {
float: left; float: left;
margin-right: 10px; margin-right: 10px;
...@@ -474,3 +468,14 @@ pre.light-well { ...@@ -474,3 +468,14 @@ pre.light-well {
color: #fff; color: #fff;
} }
} }
.protected-branches-list {
a {
color: $gl-gray;
font-weight: 600;
&:hover {
color: $gl-link-color;
}
}
}
- unless @branches.empty? %h5.prepend-top-0
%br Already Protected (#{@branches.size})
%h4 Already Protected: - if @branches.empty?
.table-holder %p.profile-settings-message.text-center
No branches are protected, protect a branch with the form above.
- else
- can_admin_project = can?(current_user, :admin_project, @project)
.table-responsive
%table.table.protected-branches-list %table.table.protected-branches-list
%colgroup
%col{ width: "30%" }
%col{ width: "30%" }
%col{ width: "25%" }
- if can_admin_project
%col
%thead %thead
%tr.no-border %tr
%th Branch %th Branch
%th Developers can push
%th Last commit %th Last commit
%th Developers can push
- if can_admin_project
%th %th
%tbody %tbody
- @branches.each do |branch| - @branches.each do |branch|
- @url = namespace_project_protected_branch_path(@project.namespace, @project, branch) - @url = namespace_project_protected_branch_path(@project.namespace, @project, branch)
%tr %tr
%td %td
= link_to namespace_project_commits_path(@project.namespace, @project, branch.name) do = link_to(branch.name, namespace_project_commits_path(@project.namespace, @project, branch.name))
%strong= branch.name
- if @project.root_ref?(branch.name) - if @project.root_ref?(branch.name)
%span.label.label-info default %span.label.label-info.prepend-left-5 default
%td
= check_box_tag "developers_can_push", branch.id, branch.developers_can_push, "data-url" => @url
%td %td
- if commit = branch.commit - if commit = branch.commit
= link_to namespace_project_commit_path(@project.namespace, @project, commit.id), class: 'commit_short_id' do = link_to(commit.short_id, namespace_project_commit_path(@project.namespace, @project, commit.id), class: 'commit_short_id')
= commit.short_id
·
#{time_ago_with_tooltip(commit.committed_date)} #{time_ago_with_tooltip(commit.committed_date)}
- else - else
(branch was removed from repository) (branch was removed from repository)
%td %td
.pull-right = check_box_tag("developers_can_push", branch.id, branch.developers_can_push, data: { url: @url })
- if can? current_user, :admin_project, @project - if can_admin_project
= link_to 'Unprotect', [@project.namespace.becomes(Namespace), @project, branch], data: { confirm: 'Branch will be writable for developers. Are you sure?' }, method: :delete, class: "btn btn-remove btn-sm" %td
= link_to 'Unprotect', [@project.namespace.becomes(Namespace), @project, branch], data: { confirm: 'Branch will be writable for developers. Are you sure?' }, method: :delete, class: "btn btn-warning btn-sm"
- page_title "Protected branches" - page_title "Protected branches"
%h3.page-title Protected branches
%p.light Keep stable branches secure and force developers to use Merge Requests
%hr
.well .row.prepend-top-default.append-bottom-default
%p Protected branches are designed to .col-lg-3
%h4.prepend-top-0
= page_title
%p Keep stable branches secure and force developers to use Merge Requests
.col-lg-9
%h5.prepend-top-0
Protect a branch
.account-well.append-bottom-default
%p.light-header.append-bottom-0 Protected branches are designed to
%ul %ul
%li prevent pushes from everybody except #{link_to "masters", help_page_path("permissions", "permissions"), class: "vlink"} %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 force pushing to the branch
%li prevent anyone from deleting 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"} %p.append-bottom-0 Read more about #{link_to "project permissions", help_page_path("permissions", "permissions"), class: "underlined-link"}
- if can? current_user, :admin_project, @project
- if can? current_user, :admin_project, @project = form_for [@project.namespace.becomes(Namespace), @project, @protected_branch] do |f|
= form_for [@project.namespace.becomes(Namespace), @project, @protected_branch], html: { class: 'form-horizontal' } do |f|
= form_errors(@protected_branch) = form_errors(@protected_branch)
.form-group .form-group
= f.label :name, "Branch", class: 'control-label' = f.label :name, "Branch", class: "label-light"
.col-sm-10
= f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: true}, {class: "select2", data: {placeholder: "Select branch"}}) = f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: true}, {class: "select2", data: {placeholder: "Select branch"}})
.form-group .form-group
.col-sm-offset-2.col-sm-10 = f.check_box :developers_can_push, class: "pull-left"
.checkbox .prepend-left-20
= f.label :developers_can_push do = f.label :developers_can_push, "Developers can push", class: "label-light append-bottom-0"
= f.check_box :developers_can_push %p.light.append-bottom-0
%strong Developers can push Allow developers to push to this branch
.help-block Allow developers to push to this branch = f.submit "Protect", class: "btn-create btn"
.form-actions %hr
= f.submit 'Protect', class: "btn-create btn" = render "branches_list"
= render 'branches_list'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment