BigW Consortium Gitlab

status_entity.rb 771 Bytes
Newer Older
1 2 3
class StatusEntity < Grape::Entity
  include RequestAwareEntity

4
  expose :icon, :text, :label, :group
5
  expose :status_tooltip, as: :tooltip
6 7
  expose :has_details?, as: :has_details
  expose :details_path
8

Luke "Jared" Bennett committed
9
  expose :favicon do |status|
10 11 12 13 14 15 16 17
    dir =
      if Gitlab::Utils.to_boolean(ENV['CANARY'])
        File.join('ci_favicons', 'canary')
      elsif Rails.env.development?
        File.join('ci_favicons', 'dev')
      else
        'ci_favicons'
      end
18 19

    ActionController::Base.helpers.image_path(File.join(dir, "#{status.favicon}.ico"))
Luke "Jared" Bennett committed
20
  end
21 22 23 24 25 26 27

  expose :action, if: -> (status, _) { status.has_action? } do
    expose :action_icon, as: :icon
    expose :action_title, as: :title
    expose :action_path, as: :path
    expose :action_method, as: :method
  end
28
end