Commit b65c39ca authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '51112-add-status-illustration-in-job-api' into 'master'

Add empty state illustration information in job API

Closes #51112

See merge request gitlab-org/gitlab-ce!21532
parents 7dd8d379 e254da81
# frozen_string_literal: true
class StatusEntity < Grape::Entity
class DetailedStatusEntity < Grape::Entity
include RequestAwareEntity
expose :icon, :text, :label, :group
......@@ -8,6 +8,14 @@ class StatusEntity < Grape::Entity
expose :has_details?, as: :has_details
expose :details_path
expose :illustration do |status|
begin
status.illustration
rescue NotImplementedError
# ignored
end
end
expose :favicon do |status|
Gitlab::Favicon.status_overlay(status.favicon)
end
......
......@@ -27,7 +27,7 @@ class JobEntity < Grape::Entity
expose :playable?, as: :playable
expose :created_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 :recoverable, if: -> (*) { failed? }
......
......@@ -5,7 +5,7 @@ class JobGroupEntity < Grape::Entity
expose :name
expose :size
expose :detailed_status, as: :status, with: StatusEntity
expose :detailed_status, as: :status, with: DetailedStatusEntity
expose :jobs, with: JobEntity
private
......
......@@ -30,7 +30,7 @@ class PipelineEntity < Grape::Entity
end
expose :details do
expose :detailed_status, as: :status, with: StatusEntity
expose :detailed_status, as: :status, with: DetailedStatusEntity
expose :duration
expose :finished_at
end
......
......@@ -19,7 +19,7 @@ class StageEntity < Grape::Entity
latest_statuses
end
expose :detailed_status, as: :status, with: StatusEntity
expose :detailed_status, as: :status, with: DetailedStatusEntity
expose :path do |stage|
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
expect(json_response['terminal_path']).to match(%r{/terminal})
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
def get_show(**extra_params)
......
......@@ -25,7 +25,7 @@
"playable": { "type": "boolean" },
"created_at": { "type": "string" },
"updated_at": { "type": "string" },
"status": { "$ref": "../ci_detailed_status.json" }
"status": { "$ref": "../status/ci_detailed_status.json" }
},
"additionalProperties": true
}
......@@ -16,7 +16,7 @@
"items": { "$ref": "job/job.json" },
"optional": true
},
"status": { "$ref": "ci_detailed_status.json" },
"status": { "$ref": "status/ci_detailed_status.json" },
"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",
"required" : [
"required": [
"icon",
"text",
"label",
......@@ -19,28 +19,8 @@
"has_details": { "type": "boolean" },
"details_path": { "type": "string" },
"favicon": { "type": "string" },
"action": {
"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" }
}
}
"illustration": { "$ref": "illustration.json" },
"action": { "$ref": "action.json" }
},
"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'
describe StatusEntity do
describe DetailedStatusEntity do
let(:entity) { described_class.new(status) }
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