1d47ae1365
In EE we now allow individual users/groups to be set on POST, which required some refactoring. See https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/3516
33 lines
660 B
Ruby
33 lines
660 B
Ruby
module ProtectedBranches
|
|
class AccessLevelParams
|
|
attr_reader :type, :params
|
|
|
|
def initialize(type, params)
|
|
@type = type
|
|
@params = params_with_default(params)
|
|
end
|
|
|
|
def access_levels
|
|
ce_style_access_level
|
|
end
|
|
|
|
private
|
|
|
|
def params_with_default(params)
|
|
params[:"#{type}_access_level"] ||= Gitlab::Access::MASTER if use_default_access_level?(params)
|
|
params
|
|
end
|
|
|
|
def use_default_access_level?(params)
|
|
true
|
|
end
|
|
|
|
def ce_style_access_level
|
|
access_level = params[:"#{type}_access_level"]
|
|
|
|
return [] unless access_level
|
|
|
|
[{ access_level: access_level }]
|
|
end
|
|
end
|
|
end
|