Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e254da81
Commit
e254da81
authored
Sep 11, 2018
by
Steve Azzopardi
Committed by
Kamil Trzciński
Sep 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add empty state illustration information in job API
parent
7dd8d379
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
77 additions
and
31 deletions
+77
-31
app/serializers/detailed_status_entity.rb
app/serializers/detailed_status_entity.rb
+9
-1
app/serializers/job_entity.rb
app/serializers/job_entity.rb
+1
-1
app/serializers/job_group_entity.rb
app/serializers/job_group_entity.rb
+1
-1
app/serializers/pipeline_entity.rb
app/serializers/pipeline_entity.rb
+1
-1
app/serializers/stage_entity.rb
app/serializers/stage_entity.rb
+1
-1
changelogs/unreleased/51112-add-status-illustration-in-job-api.yml
...s/unreleased/51112-add-status-illustration-in-job-api.yml
+5
-0
spec/controllers/projects/jobs_controller_spec.rb
spec/controllers/projects/jobs_controller_spec.rb
+12
-0
spec/fixtures/api/schemas/job/job.json
spec/fixtures/api/schemas/job/job.json
+1
-1
spec/fixtures/api/schemas/pipeline_stage.json
spec/fixtures/api/schemas/pipeline_stage.json
+1
-1
spec/fixtures/api/schemas/status/action.json
spec/fixtures/api/schemas/status/action.json
+22
-0
spec/fixtures/api/schemas/status/ci_detailed_status.json
spec/fixtures/api/schemas/status/ci_detailed_status.json
+3
-23
spec/fixtures/api/schemas/status/illustration.json
spec/fixtures/api/schemas/status/illustration.json
+19
-0
spec/serializers/detailed_status_entity_spec.rb
spec/serializers/detailed_status_entity_spec.rb
+1
-1
No files found.
app/serializers/status_entity.rb
→
app/serializers/
detailed_
status_entity.rb
View file @
e254da81
# frozen_string_literal: true
# frozen_string_literal: true
class
StatusEntity
<
Grape
::
Entity
class
Detailed
StatusEntity
<
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
...
...
app/serializers/job_entity.rb
View file @
e254da81
...
@@ -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:
Detailed
StatusEntity
expose
:callout_message
,
if:
->
(
*
)
{
failed?
&&
!
build
.
script_failure?
}
expose
:callout_message
,
if:
->
(
*
)
{
failed?
&&
!
build
.
script_failure?
}
expose
:recoverable
,
if:
->
(
*
)
{
failed?
}
expose
:recoverable
,
if:
->
(
*
)
{
failed?
}
...
...
app/serializers/job_group_entity.rb
View file @
e254da81
...
@@ -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:
Detailed
StatusEntity
expose
:jobs
,
with:
JobEntity
expose
:jobs
,
with:
JobEntity
private
private
...
...
app/serializers/pipeline_entity.rb
View file @
e254da81
...
@@ -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:
Detailed
StatusEntity
expose
:duration
expose
:duration
expose
:finished_at
expose
:finished_at
end
end
...
...
app/serializers/stage_entity.rb
View file @
e254da81
...
@@ -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:
Detailed
StatusEntity
expose
:path
do
|
stage
|
expose
:path
do
|
stage
|
project_pipeline_path
(
project_pipeline_path
(
...
...
changelogs/unreleased/51112-add-status-illustration-in-job-api.yml
0 → 100644
View file @
e254da81
---
title
:
Add empty state illustration information in job API
merge_request
:
21532
author
:
type
:
other
spec/controllers/projects/jobs_controller_spec.rb
View file @
e254da81
...
@@ -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
)
...
...
spec/fixtures/api/schemas/job/job.json
View file @
e254da81
...
@@ -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
}
}
spec/fixtures/api/schemas/pipeline_stage.json
View file @
e254da81
...
@@ -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"
}
},
},
...
...
spec/fixtures/api/schemas/status/action.json
0 → 100644
View file @
e254da81
{
"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"
}
}
}
spec/fixtures/api/schemas/ci_detailed_status.json
→
spec/fixtures/api/schemas/
status/
ci_detailed_status.json
View file @
e254da81
{
{
"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
}
}
spec/fixtures/api/schemas/status/illustration.json
0 → 100644
View file @
e254da81
{
"oneOf"
:
[
{
"type"
:
"null"
},
{
"type"
:
"object"
,
"required"
:
[
"image"
,
"size"
,
"title"
],
"properties"
:
{
"image"
:
{
"type"
:
"string"
},
"size"
:
{
"type"
:
"string"
},
"title"
:
{
"type"
:
"string"
},
"content"
:
{
"type"
:
"string"
}
}
}
]
}
spec/serializers/status_entity_spec.rb
→
spec/serializers/
detailed_
status_entity_spec.rb
View file @
e254da81
require
'spec_helper'
require
'spec_helper'
describe
StatusEntity
do
describe
Detailed
StatusEntity
do
let
(
:entity
)
{
described_class
.
new
(
status
)
}
let
(
:entity
)
{
described_class
.
new
(
status
)
}
let
(
:status
)
do
let
(
:status
)
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment