debian-mirror-gitlab/lib/bulk_imports/visibility_level.rb

27 lines
756 B
Ruby
Raw Normal View History

2023-04-23 21:23:45 +05:30
# frozen_string_literal: true
module BulkImports
module VisibilityLevel
private
def visibility_level(entity, namespace, visibility_string)
requested = requested_visibility_level(entity, visibility_string)
max_allowed = max_allowed_visibility_level(namespace)
return requested if max_allowed >= requested
max_allowed
end
def requested_visibility_level(entity, visibility_string)
Gitlab::VisibilityLevel.string_options[visibility_string] || entity.default_visibility_level
end
def max_allowed_visibility_level(namespace)
return Gitlab::VisibilityLevel.allowed_levels.max if namespace.blank?
Gitlab::VisibilityLevel.closest_allowed_level(namespace.visibility_level)
end
end
end