diff --git a/app/graphql/types/work_items/widgets/assignees_type.rb b/app/graphql/types/work_items/widgets/assignees_type.rb index 001ace77d6ef25f1f8fcd1d804808420f03593bf..08ee06fdfa04d948ba61a5030f3dda5ffc680d2b 100644 --- a/app/graphql/types/work_items/widgets/assignees_type.rb +++ b/app/graphql/types/work_items/widgets/assignees_type.rb @@ -17,6 +17,13 @@ class AssigneesType < BaseObject 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 diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index ed9842870cd80d8bb20d08a93cf2a8b085801fd5..0f4040d0ae9b9a277921e284e94cd3cc094f0ec3 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -18498,6 +18498,7 @@ Represents an assignees widget. | ---- | ---- | ----------- | | <a id="workitemwidgetassigneesallowsmultipleassignees"></a>`allowsMultipleAssignees` | [`Boolean`](#boolean) | Indicates whether multiple assignees are allowed. | | <a id="workitemwidgetassigneesassignees"></a>`assignees` | [`UserCoreConnection`](#usercoreconnection) | Assignees of the work item. (see [Connections](#connections)) | +| <a id="workitemwidgetassigneescaninvitemembers"></a>`canInviteMembers` | [`Boolean!`](#boolean) | Indicates whether the current user can invite members to the work item's project. | | <a id="workitemwidgetassigneestype"></a>`type` | [`WorkItemWidgetType`](#workitemwidgettype) | Widget type. | ### `WorkItemWidgetDescription` diff --git a/spec/graphql/types/work_items/widgets/assignees_type_spec.rb b/spec/graphql/types/work_items/widgets/assignees_type_spec.rb index 2db0667faea4e89cf04f08a9fa65dc076a443107..816e66f1db1df5a19feeb1f66ec3e164b84a9d5f 100644 --- a/spec/graphql/types/work_items/widgets/assignees_type_spec.rb +++ b/spec/graphql/types/work_items/widgets/assignees_type_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Types::WorkItems::Widgets::AssigneesType do it 'exposes the expected fields' do - expected_fields = %i[assignees allows_multiple_assignees type] + expected_fields = %i[assignees allows_multiple_assignees can_invite_members type] expect(described_class).to have_graphql_fields(*expected_fields) end diff --git a/spec/requests/api/graphql/work_item_spec.rb b/spec/requests/api/graphql/work_item_spec.rb index 70fa8100411f1a2e8be0d6af42a851a855c15c5c..f17d2ebbb7e1dd1bfcbeda4d9a19014543e4568b 100644 --- a/spec/requests/api/graphql/work_item_spec.rb +++ b/spec/requests/api/graphql/work_item_spec.rb @@ -200,6 +200,7 @@ type ... on WorkItemWidgetAssignees { allowsMultipleAssignees + canInviteMembers assignees { nodes { id @@ -218,6 +219,7 @@ hash_including( 'type' => 'ASSIGNEES', 'allowsMultipleAssignees' => boolean, + 'canInviteMembers' => boolean, 'assignees' => { 'nodes' => match_array( assignees.map { |a| { 'id' => a.to_gid.to_s, 'username' => a.username } }