Commit d1336e51 authored by Mark Chao's avatar Mark Chao

Merge branch 'lm-add-action-to-detailed-status' into 'master'

Adds action to DetailedStatusType

See merge request gitlab-org/gitlab!44088
parents 373740c6 9e2c3fc6
......@@ -24,6 +24,21 @@ module Types
field :tooltip, GraphQL::STRING_TYPE, null: false,
description: 'Tooltip associated with the pipeline status',
method: :status_tooltip
field :action, Types::Ci::StatusActionType, null: true,
description: 'Action information for the status. This includes method, button title, icon, path, and title',
resolve: -> (obj, _args, _ctx) {
if obj.has_action?
{
button_title: obj.action_button_title,
icon: obj.icon,
method: obj.action_method,
path: obj.action_path,
title: obj.action_title
}
else
nil
end
}
end
# rubocop: enable Graphql/AuthorizeTypes
end
......
# frozen_string_literal: true
module Types
module Ci
# rubocop: disable Graphql/AuthorizeTypes
class StatusActionType < BaseObject
graphql_name 'StatusAction'
field :button_title, GraphQL::STRING_TYPE, null: true,
description: 'Title for the button, for example: Retry this job'
field :icon, GraphQL::STRING_TYPE, null: true,
description: 'Icon used in the action button'
field :method, GraphQL::STRING_TYPE, null: true,
description: 'Method for the action, for example: :post',
resolver_method: :action_method
field :path, GraphQL::STRING_TYPE, null: true,
description: 'Path for the action'
field :title, GraphQL::STRING_TYPE, null: true,
description: 'Title for the action, for example: Retry'
def action_method
object[:method]
end
end
end
end
---
title: 'GraphQL: Adds action to DetailedStatusType and StatusActioType'
merge_request: 44088
author:
type: added
......@@ -5184,6 +5184,11 @@ type DestroySnippetPayload {
}
type DetailedStatus {
"""
Action information for the status. This includes method, button title, icon, path, and title
"""
action: StatusAction
"""
Path of the details for the pipeline status
"""
......@@ -17717,6 +17722,33 @@ enum Sort {
updated_desc @deprecated(reason: "Use UPDATED_DESC. Deprecated in 13.5")
}
type StatusAction {
"""
Title for the button, for example: Retry this job
"""
buttonTitle: String
"""
Icon used in the action button
"""
icon: String
"""
Method for the action, for example: :post
"""
method: String
"""
Path for the action
"""
path: String
"""
Title for the action, for example: Retry
"""
title: String
}
type Submodule implements Entry {
"""
Flat path of the entry
......
......@@ -14210,6 +14210,20 @@
"name": "DetailedStatus",
"description": null,
"fields": [
{
"name": "action",
"description": "Action information for the status. This includes method, button title, icon, path, and title",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "StatusAction",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "detailsPath",
"description": "Path of the details for the pipeline status",
......@@ -51487,6 +51501,89 @@
],
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "StatusAction",
"description": null,
"fields": [
{
"name": "buttonTitle",
"description": "Title for the button, for example: Retry this job",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "icon",
"description": "Icon used in the action button",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "method",
"description": "Method for the action, for example: :post",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "path",
"description": "Path for the action",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "title",
"description": "Title for the action, for example: Retry",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "String",
......@@ -839,6 +839,7 @@ Autogenerated return type of DestroySnippet.
| Field | Type | Description |
| ----- | ---- | ----------- |
| `action` | StatusAction | Action information for the status. This includes method, button title, icon, path, and title |
| `detailsPath` | String! | Path of the details for the pipeline status |
| `favicon` | String! | Favicon of the pipeline status |
| `group` | String! | Group of the pipeline status |
......@@ -2455,6 +2456,16 @@ Represents how the blob content should be displayed.
| `reportSnippet` | Boolean! | Indicates the user can perform `report_snippet` on this resource |
| `updateSnippet` | Boolean! | Indicates the user can perform `update_snippet` on this resource |
### StatusAction
| Field | Type | Description |
| ----- | ---- | ----------- |
| `buttonTitle` | String | Title for the button, for example: Retry this job |
| `icon` | String | Icon used in the action button |
| `method` | String | Method for the action, for example: :post |
| `path` | String | Path for the action |
| `title` | String | Title for the action, for example: Retry |
### Submodule
| Field | Type | Description |
......
......@@ -8,6 +8,6 @@ RSpec.describe Types::Ci::DetailedStatusType do
it "has all fields" do
expect(described_class).to have_graphql_fields(:group, :icon, :favicon,
:details_path, :has_details,
:label, :text, :tooltip)
:label, :text, :tooltip, :action)
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Types::Ci::StatusActionType do
specify { expect(described_class.graphql_name).to eq('StatusAction') }
it 'exposes the expected fields' do
expected_fields = %i[
buttonTitle
icon
path
method
title
]
expect(described_class).to have_graphql_fields(*expected_fields)
end
end
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