visibility_level_helper.rb 1.8 KB
Newer Older
1 2 3 4
module VisibilityLevelHelper
  def visibility_level_color(level)
    case level
    when Gitlab::VisibilityLevel::PRIVATE
5
      'vs-private'
6
    when Gitlab::VisibilityLevel::INTERNAL
7
      'vs-internal'
8
    when Gitlab::VisibilityLevel::PUBLIC
9
      'vs-public'
10 11 12 13 14 15 16 17 18 19 20
    end
  end

  def visibility_level_description(level)
    capture_haml do
      haml_tag :span do
        case level
        when Gitlab::VisibilityLevel::PRIVATE
          haml_concat "Project access must be granted explicitly for each user."
        when Gitlab::VisibilityLevel::INTERNAL
          haml_concat "The project can be cloned by"
21
          haml_concat "any logged in user."
22 23
        when Gitlab::VisibilityLevel::PUBLIC
          haml_concat "The project can be cloned"
24
          haml_concat "without any"
25 26 27 28 29 30
          haml_concat "authentication."
        end
      end
    end
  end

V
Valery Sizov 已提交
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
  def snippet_visibility_level_description(level)
    capture_haml do
      haml_tag :span do
        case level
        when Gitlab::VisibilityLevel::PRIVATE
          haml_concat "The snippet is visible only for me"
        when Gitlab::VisibilityLevel::INTERNAL
          haml_concat "The snippet is visible for any logged in user."
        when Gitlab::VisibilityLevel::PUBLIC
          haml_concat "The snippet can be accessed"
          haml_concat "without any"
          haml_concat "authentication."
        end
      end
    end
  end

48 49 50 51 52 53 54 55 56 57 58 59 60 61
  def visibility_level_icon(level)
    case level
    when Gitlab::VisibilityLevel::PRIVATE
      private_icon
    when Gitlab::VisibilityLevel::INTERNAL
      internal_icon
    when Gitlab::VisibilityLevel::PUBLIC
      public_icon
    end
  end

  def visibility_level_label(level)
    Project.visibility_levels.key(level)
  end
62

63 64 65
  def restricted_visibility_levels
    current_user.is_admin? ? [] : gitlab_config.restricted_visibility_levels
  end
66
end