Welcome to mirror list, hosted at ThFree Co, Russian Federation.

visibility_level.rb « bulk_imports « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6b0af15dd7be595aac3ae038fa3f72e9675e0b71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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