2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
class DetailedStatusEntity < Grape::Entity
|
2017-08-17 22:00:37 +05:30
|
|
|
include RequestAwareEntity
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
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' }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :illustration, documentation: {
|
|
|
|
type: 'object',
|
|
|
|
example: <<~JSON
|
|
|
|
{
|
|
|
|
"image": "illustrations/job_not_triggered.svg",
|
|
|
|
"size": "svg-306",
|
|
|
|
"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|
|
2019-07-07 11:18:12 +05:30
|
|
|
illustration = {
|
|
|
|
image: ActionController::Base.helpers.image_path(status.illustration[:image])
|
|
|
|
}
|
|
|
|
illustration = status.illustration.merge(illustration)
|
2018-12-05 23:21:45 +05:30
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
illustration
|
|
|
|
rescue NotImplementedError
|
|
|
|
# ignored
|
2018-12-05 23:21:45 +05:30
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expose :favicon,
|
|
|
|
documentation: { type: 'string',
|
|
|
|
example: '/assets/ci_favicons/favicon_status_success.png' } do |status|
|
2023-06-20 00:43:36 +05:30
|
|
|
Gitlab::Favicon.ci_status_overlay(status.favicon)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
expose :action, if: -> (status, _) { status.has_action? } do
|
2023-01-13 00:05:48 +05:30
|
|
|
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' }
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|