summaryrefslogtreecommitdiff
path: root/app/graphql/types/ci/detailed_status_type.rb
blob: f4a50115ee60f827173c31ddd6205daf2756a0ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true
module Types
  module Ci
    # rubocop: disable Graphql/AuthorizeTypes
    # This is presented through `PipelineType` that has its own authorization
    class DetailedStatusType < BaseObject
      graphql_name 'DetailedStatus'

      field :group, GraphQL::STRING_TYPE, null: true,
            description: 'Group of the status'
      field :icon, GraphQL::STRING_TYPE, null: true,
            description: 'Icon of the status'
      field :favicon, GraphQL::STRING_TYPE, null: true,
            description: 'Favicon of the status'
      field :details_path, GraphQL::STRING_TYPE, null: true,
            description: 'Path of the details for the status'
      field :has_details, GraphQL::BOOLEAN_TYPE, null: true,
            description: 'Indicates if the status has further details',
            method: :has_details?
      field :label, GraphQL::STRING_TYPE, null: true,
            description: 'Label of the status'
      field :text, GraphQL::STRING_TYPE, null: true,
            description: 'Text of the status'
      field :tooltip, GraphQL::STRING_TYPE, null: true,
            description: 'Tooltip associated with the 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
end