diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-07-07 16:18:07 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-07-29 15:20:39 +0530 |
commit | ab6096c17261605d835a4a8edae21f31d90026df (patch) | |
tree | 0a4490cc0a62b86bf240fbc5bdff709b2e8d11b0 /app/services | |
parent | f8a04e15371815ad39e2c66056db4ab0439555f4 (diff) | |
download | gitlab-ce-ab6096c17261605d835a4a8edae21f31d90026df.tar.gz |
Add "No One Can Push" to the protected branches UI.
1. Move to dropdowns instead of checkboxes. One each for "Allowed to
Push" and "Allowed to Merge"
2. Refactor the `ProtectedBranches` coffeescript class into
`ProtectedBranchesAccessSelect`.
3. Modify the backend to accept the new parameters.
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/protected_branches/base_service.rb | 20 | ||||
-rw-r--r-- | app/services/protected_branches/create_service.rb | 28 |
2 files changed, 27 insertions, 21 deletions
diff --git a/app/services/protected_branches/base_service.rb b/app/services/protected_branches/base_service.rb index d4be8698a5f..3a7c35327fe 100644 --- a/app/services/protected_branches/base_service.rb +++ b/app/services/protected_branches/base_service.rb @@ -1,17 +1,21 @@ module ProtectedBranches class BaseService < ::BaseService def set_access_levels! - if params[:developers_can_push] == '0' - @protected_branch.push_access_level.masters! - elsif params[:developers_can_push] == '1' - @protected_branch.push_access_level.developers! - end - - if params[:developers_can_merge] == '0' + case params[:allowed_to_merge] + when 'masters' @protected_branch.merge_access_level.masters! - elsif params[:developers_can_merge] == '1' + when 'developers' @protected_branch.merge_access_level.developers! end + + case params[:allowed_to_push] + when 'masters' + @protected_branch.push_access_level.masters! + when 'developers' + @protected_branch.push_access_level.developers! + when 'no_one' + @protected_branch.push_access_level.no_one! + end end end end diff --git a/app/services/protected_branches/create_service.rb b/app/services/protected_branches/create_service.rb index 743f7bd2ce1..ab462f3054e 100644 --- a/app/services/protected_branches/create_service.rb +++ b/app/services/protected_branches/create_service.rb @@ -1,19 +1,21 @@ -class ProtectedBranches::CreateService < BaseService - attr_reader :protected_branch +module ProtectedBranches + class CreateService < BaseService + attr_reader :protected_branch - def execute - ProtectedBranch.transaction do - @protected_branch = project.protected_branches.new(name: params[:name]) - @protected_branch.save! + def execute + ProtectedBranch.transaction do + @protected_branch = project.protected_branches.new(name: params[:name]) + @protected_branch.save! - @protected_branch.create_push_access_level! - @protected_branch.create_merge_access_level! + @protected_branch.create_push_access_level! + @protected_branch.create_merge_access_level! - set_access_levels! - end + set_access_levels! + end - true - rescue ActiveRecord::RecordInvalid - false + true + rescue ActiveRecord::RecordInvalid + false + end end end |