diff options
author | Marin Jankovski <maxlazio@gmail.com> | 2014-12-26 13:39:12 +0300 |
---|---|---|
committer | Marin Jankovski <maxlazio@gmail.com> | 2014-12-26 13:39:12 +0300 |
commit | 92eb3974ac28aff7c78f4ca0cbafbad842fc7160 (patch) | |
tree | daa081e7ef8cd4d1527000dbc5a7aca5caefe9af /app | |
parent | 770b2a5cfbec1081756bfa2d8bf046b7b16bb638 (diff) |
Add option to disable/enable developers push to already protected branches.
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/protected_branches_controller.rb | 17 | ||||
-rw-r--r-- | app/views/projects/protected_branches/index.html.haml | 7 |
2 files changed, 24 insertions, 0 deletions
diff --git a/app/controllers/projects/protected_branches_controller.rb b/app/controllers/projects/protected_branches_controller.rb index a0df392e424..ac68992faa0 100644 --- a/app/controllers/projects/protected_branches_controller.rb +++ b/app/controllers/projects/protected_branches_controller.rb @@ -15,6 +15,23 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController redirect_to project_protected_branches_path(@project) end + def update + protected_branch = @project.protected_branches.find(params[:id]) + + if protected_branch && + protected_branch.update_attributes( + developers_can_push: params[:developers_can_push] + ) + flash[:notice] = 'Branch was successfully updated.' + else + flash[:alert] = 'Could not update the branch.' + end + + respond_to do |format| + format.html { redirect_to project_protected_branches_path } + end + end + def destroy @project.protected_branches.find(params[:id]).destroy diff --git a/app/views/projects/protected_branches/index.html.haml b/app/views/projects/protected_branches/index.html.haml index 2d04c572c73..183f25bfc82 100644 --- a/app/views/projects/protected_branches/index.html.haml +++ b/app/views/projects/protected_branches/index.html.haml @@ -40,8 +40,15 @@ %span.label.label-info default %span.label.label-success %i.fa.fa-lock + - if branch.developers_can_push + %span.label.label-warning + %i.fa.fa-group .pull-right - if can? current_user, :admin_project, @project + - if branch.developers_can_push + = link_to 'Disable developers push', [@project, branch, { developers_can_push: false }], data: { confirm: 'Branch will be no longer writable for developers. Are you sure?' }, method: :put, class: "btn btn-grouped btn-small" + - else + = link_to 'Allow developers to push', [@project, branch, { developers_can_push: true }], data: { confirm: 'Branch will be writable for developers. Are you sure?' }, method: :put, class: "btn btn-grouped btn-small" = link_to 'Unprotect', [@project, branch], data: { confirm: 'Branch will be writable for developers. Are you sure?' }, method: :delete, class: "btn btn-remove btn-small" - if commit = branch.commit |