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

detailed_status_entity.rb « serializers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 37d7bb8fdbece5596faa3d5252666de577fd6746 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true

class DetailedStatusEntity < Grape::Entity
  include RequestAwareEntity

  expose :icon, documentation: { type: 'string', example: 'status_success' }
  expose :text, documentation: { type: 'string', example: 'passed' }
  expose :label, documentation: { type: 'string', example: 'passed' }
  expose :group, documentation: { type: 'string', example: 'success' }
  expose :status_tooltip, as: :tooltip, documentation: { type: 'string', example: 'passed' }
  expose :has_details?, as: :has_details, documentation: { type: 'boolean', example: true }
  expose :details_path, documentation: { type: 'string', example: '/test-group/test-project/-/pipelines/287' }

  expose :illustration, documentation: {
    type: 'object',
    example: <<~JSON
      {
        "image": "illustrations/empty-state/empty-job-not-triggered-md.svg",
        "size": "",
        "title": "This job has not been triggered yet",
        "content": "This job depends on upstream jobs that need to succeed in order for this job to be triggered"
      }
    JSON
  } do |status|
    illustration = {
        image: ActionController::Base.helpers.image_path(status.illustration[:image])
    }
    illustration = status.illustration.merge(illustration)

    illustration
  rescue NotImplementedError
    # ignored
  end

  expose :favicon,
    documentation: { type: 'string',
                     example: '/assets/ci_favicons/favicon_status_success.png' } do |status|
    Gitlab::Favicon.ci_status_overlay(status.favicon)
  end

  expose :action, if: -> (status, _) { status.has_action? } do
    expose :action_icon, as: :icon, documentation: { type: 'string', example: 'cancel' }
    expose :action_title, as: :title, documentation: { type: 'string', example: 'Cancel' }
    expose :action_path, as: :path, documentation: { type: 'string', example: '/namespace1/project1/-/jobs/2/cancel' }
    expose :action_method, as: :method, documentation: { type: 'string', example: 'post' }
    expose :action_button_title, as: :button_title, documentation: { type: 'string', example: 'Cancel this job' }
  end
end