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 %th Developers can push
- if can_admin_project
%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.prepend-left-5 default
%span.label.label-info default %td
%td - if commit = branch.commit
= check_box_tag "developers_can_push", branch.id, branch.developers_can_push, "data-url" => @url = link_to(commit.short_id, namespace_project_commit_path(@project.namespace, @project, commit.id), class: 'commit_short_id')
%td #{time_ago_with_tooltip(commit.committed_date)}
- if commit = branch.commit - else
= link_to namespace_project_commit_path(@project.namespace, @project, commit.id), class: 'commit_short_id' do (branch was removed from repository)
= commit.short_id %td
· = check_box_tag("developers_can_push", branch.id, branch.developers_can_push, data: { url: @url })
#{time_ago_with_tooltip(commit.committed_date)} - if can_admin_project
- else
(branch was removed from repository)
%td %td
.pull-right = 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"
- if can? current_user, :admin_project, @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"
- 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
%ul %h4.prepend-top-0
%li prevent pushes from everybody except #{link_to "masters", help_page_path("permissions", "permissions"), class: "vlink"} = page_title
%li prevent anyone from force pushing to the branch %p Keep stable branches secure and force developers to use Merge Requests
%li prevent anyone from deleting the branch .col-lg-9
%p Read more about #{link_to "project permissions", help_page_path("permissions", "permissions"), class: "underlined-link"} %h5.prepend-top-0
Protect a branch
.account-well.append-bottom-default
%p.light-header.append-bottom-0 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.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
= form_for [@project.namespace.becomes(Namespace), @project, @protected_branch] do |f|
= form_errors(@protected_branch)
- if can? current_user, :admin_project, @project .form-group
= form_for [@project.namespace.becomes(Namespace), @project, @protected_branch], html: { class: 'form-horizontal' } do |f| = f.label :name, "Branch", class: "label-light"
= form_errors(@protected_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 = f.check_box :developers_can_push, class: "pull-left"
= f.label :name, "Branch", class: 'control-label' .prepend-left-20
.col-sm-10 = f.label :developers_can_push, "Developers can push", class: "label-light append-bottom-0"
= f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: true}, {class: "select2", data: {placeholder: "Select branch"}}) %p.light.append-bottom-0
.form-group Allow developers to push to this branch
.col-sm-offset-2.col-sm-10 = f.submit "Protect", class: "btn-create btn"
.checkbox %hr
= f.label :developers_can_push do = render "branches_list"
= 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'
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