Commit e254da81 authored by Steve Azzopardi's avatar Steve Azzopardi Committed by Kamil Trzciński

Add empty state illustration information in job API

parent 7dd8d379
# frozen_string_literal: true # frozen_string_literal: true
class StatusEntity < Grape::Entity class DetailedStatusEntity < Grape::Entity
include RequestAwareEntity include RequestAwareEntity
expose :icon, :text, :label, :group expose :icon, :text, :label, :group
...@@ -8,6 +8,14 @@ class StatusEntity < Grape::Entity ...@@ -8,6 +8,14 @@ class StatusEntity < Grape::Entity
expose :has_details?, as: :has_details expose :has_details?, as: :has_details
expose :details_path expose :details_path
expose :illustration do |status|
begin
status.illustration
rescue NotImplementedError
# ignored
end
end
expose :favicon do |status| expose :favicon do |status|
Gitlab::Favicon.status_overlay(status.favicon) Gitlab::Favicon.status_overlay(status.favicon)
end end
......
...@@ -27,7 +27,7 @@ class JobEntity < Grape::Entity ...@@ -27,7 +27,7 @@ class JobEntity < Grape::Entity
expose :playable?, as: :playable expose :playable?, as: :playable
expose :created_at expose :created_at
expose :updated_at expose :updated_at
expose :detailed_status, as: :status, with: StatusEntity expose :detailed_status, as: :status, with: DetailedStatusEntity
expose :callout_message, if: -> (*) { failed? && !build.script_failure? } expose :callout_message, if: -> (*) { failed? && !build.script_failure? }
expose :recoverable, if: -> (*) { failed? } expose :recoverable, if: -> (*) { failed? }
......
...@@ -5,7 +5,7 @@ class JobGroupEntity < Grape::Entity ...@@ -5,7 +5,7 @@ class JobGroupEntity < Grape::Entity
expose :name expose :name
expose :size expose :size
expose :detailed_status, as: :status, with: StatusEntity expose :detailed_status, as: :status, with: DetailedStatusEntity
expose :jobs, with: JobEntity expose :jobs, with: JobEntity
private private
......
...@@ -30,7 +30,7 @@ class PipelineEntity < Grape::Entity ...@@ -30,7 +30,7 @@ class PipelineEntity < Grape::Entity
end end
expose :details do expose :details do
expose :detailed_status, as: :status, with: StatusEntity expose :detailed_status, as: :status, with: DetailedStatusEntity
expose :duration expose :duration
expose :finished_at expose :finished_at
end end
......
...@@ -19,7 +19,7 @@ class StageEntity < Grape::Entity ...@@ -19,7 +19,7 @@ class StageEntity < Grape::Entity
latest_statuses latest_statuses
end end
expose :detailed_status, as: :status, with: StatusEntity expose :detailed_status, as: :status, with: DetailedStatusEntity
expose :path do |stage| expose :path do |stage|
project_pipeline_path( project_pipeline_path(
......
---
title: Add empty state illustration information in job API
merge_request: 21532
author:
type: other
...@@ -194,6 +194,18 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do ...@@ -194,6 +194,18 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
expect(json_response['terminal_path']).to match(%r{/terminal}) expect(json_response['terminal_path']).to match(%r{/terminal})
end end
end end
context 'when job passed with no trace' do
let(:job) { create(:ci_build, :success, :artifacts, pipeline: pipeline) }
it 'exposes empty state illustrations' do
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('job/job_details')
expect(json_response['status']['illustration']).to have_key('image')
expect(json_response['status']['illustration']).to have_key('size')
expect(json_response['status']['illustration']).to have_key('title')
end
end
end end
def get_show(**extra_params) def get_show(**extra_params)
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
"playable": { "type": "boolean" }, "playable": { "type": "boolean" },
"created_at": { "type": "string" }, "created_at": { "type": "string" },
"updated_at": { "type": "string" }, "updated_at": { "type": "string" },
"status": { "$ref": "../ci_detailed_status.json" } "status": { "$ref": "../status/ci_detailed_status.json" }
}, },
"additionalProperties": true "additionalProperties": true
} }
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"items": { "$ref": "job/job.json" }, "items": { "$ref": "job/job.json" },
"optional": true "optional": true
}, },
"status": { "$ref": "ci_detailed_status.json" }, "status": { "$ref": "status/ci_detailed_status.json" },
"path": { "type": "string" }, "path": { "type": "string" },
"dropdown_path": { "type": "string" } "dropdown_path": { "type": "string" }
}, },
......
{
"type": "object",
"required": [
"icon",
"title",
"path",
"method"
],
"properties": {
"icon": {
"type": "string",
"enum": [
"retry",
"play",
"cancel"
]
},
"title": { "type": "string" },
"path": { "type": "string" },
"method": { "$ref": "../http_method.json" }
}
}
{ {
"type": "object", "type": "object",
"required" : [ "required": [
"icon", "icon",
"text", "text",
"label", "label",
...@@ -19,28 +19,8 @@ ...@@ -19,28 +19,8 @@
"has_details": { "type": "boolean" }, "has_details": { "type": "boolean" },
"details_path": { "type": "string" }, "details_path": { "type": "string" },
"favicon": { "type": "string" }, "favicon": { "type": "string" },
"action": { "illustration": { "$ref": "illustration.json" },
"type": "object", "action": { "$ref": "action.json" }
"required": [
"icon",
"title",
"path",
"method"
],
"properties": {
"icon": {
"type": "string",
"enum": [
"retry",
"play",
"cancel"
]
},
"title": { "type": "string" },
"path": { "type": "string" },
"method": { "$ref": "http_method.json" }
}
}
}, },
"additionalProperties": false "additionalProperties": false
} }
{
"oneOf": [
{ "type": "null" },
{
"type": "object",
"required": [
"image",
"size",
"title"
],
"properties": {
"image": { "type": "string" },
"size": { "type": "string" },
"title": { "type": "string" },
"content": { "type": "string" }
}
}
]
}
require 'spec_helper' require 'spec_helper'
describe StatusEntity do describe DetailedStatusEntity do
let(:entity) { described_class.new(status) } let(:entity) { described_class.new(status) }
let(:status) do let(:status) do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment