Welcome to mirror list, hosted at ThFree Co, Russian Federation.

assignees_type.rb « widgets « work_items « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 74da326456793c8308a138cadb5ae3f5cfa83d24 (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
# frozen_string_literal: true

module Types
  module WorkItems
    module Widgets
      # Disabling widget level authorization as it might be too granular
      # and we already authorize the parent work item
      # rubocop:disable Graphql/AuthorizeTypes
      class AssigneesType < BaseObject
        graphql_name 'WorkItemWidgetAssignees'
        description 'Represents an assignees widget'

        implements Types::WorkItems::WidgetInterface

        field :assignees, Types::UserType.connection_type,
          null: true,
          description: 'Assignees of the work item.'

        field :allows_multiple_assignees, GraphQL::Types::Boolean,
          null: true, method: :allows_multiple_assignees?,
          description: 'Indicates whether multiple assignees are allowed.'

        field :can_invite_members, GraphQL::Types::Boolean,
          null: false, resolver_method: :can_invite_members?,
          description: 'Indicates whether the current user can invite members to the work item\'s project.'

        def can_invite_members?
          Ability.allowed?(current_user, :admin_project_member, object.work_item.project)
        end
      end
      # rubocop:enable Graphql/AuthorizeTypes
    end
  end
end