summaryrefslogtreecommitdiff
path: root/app/serializers/detailed_status_entity.rb
blob: 4f23ef0ed8212bddaeb3baf8403e72593f9f908c (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
27
28
29
30
31
32
33
# frozen_string_literal: true

class DetailedStatusEntity < Grape::Entity
  include RequestAwareEntity

  expose :icon, :text, :label, :group
  expose :status_tooltip, as: :tooltip
  expose :has_details?, as: :has_details
  expose :details_path

  expose :illustration do |status|
    illustration = {
        image: ActionController::Base.helpers.image_path(status.illustration[:image])
    }
    illustration = status.illustration.merge(illustration)

    illustration
  rescue NotImplementedError
    # ignored
  end

  expose :favicon do |status|
    Gitlab::Favicon.status_overlay(status.favicon)
  end

  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
    expose :action_button_title, as: :button_title
  end
end