Commit 4d459468 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'add-emails-disabled-field-to-project-type' into 'master'

Add project email disabled field to issue type

See merge request gitlab-org/gitlab!46947
parents 400d0718 c2feb61a
......@@ -73,6 +73,9 @@ module Types
field :participants, Types::UserType.connection_type, null: true, complexity: 5,
description: 'List of participants in the issue'
field :emails_disabled, GraphQL::BOOLEAN_TYPE, null: false,
method: :project_emails_disabled?,
description: 'Indicates if a project has email notifications disabled'
field :subscribed, GraphQL::BOOLEAN_TYPE, method: :subscribed?, null: false, complexity: 5,
description: 'Indicates the currently logged in user is subscribed to the issue'
field :time_estimate, GraphQL::INT_TYPE, null: false,
......
......@@ -10,6 +10,10 @@ class IssuePresenter < Gitlab::View::Presenter::Delegated
def subscribed?
issue.subscribed?(current_user, issue.project)
end
def project_emails_disabled?
issue.project.emails_disabled?
end
end
IssuePresenter.prepend_if_ee('EE::IssuePresenter')
---
title: Add emailsDisabled field for issue type
merge_request: 46947
author:
type: changed
......@@ -7360,6 +7360,11 @@ type EpicIssue implements CurrentUserTodos & Noteable {
"""
dueDate: Time
"""
Indicates if a project has email notifications disabled
"""
emailsDisabled: Boolean!
"""
Epic to which this issue belongs
"""
......@@ -9879,6 +9884,11 @@ type Issue implements CurrentUserTodos & Noteable {
"""
dueDate: Time
"""
Indicates if a project has email notifications disabled
"""
emailsDisabled: Boolean!
"""
Epic to which this issue belongs
"""
......
......@@ -20316,6 +20316,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "emailsDisabled",
"description": "Indicates if a project has email notifications disabled",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "epic",
"description": "Epic to which this issue belongs",
......@@ -26955,6 +26973,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "emailsDisabled",
"description": "Indicates if a project has email notifications disabled",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "epic",
"description": "Epic to which this issue belongs",
......@@ -1214,6 +1214,7 @@ Relationship between an epic and an issue.
| `discussions` | DiscussionConnection! | All discussions on this noteable |
| `downvotes` | Int! | Number of downvotes the issue has received |
| `dueDate` | Time | Due date of the issue |
| `emailsDisabled` | Boolean! | Indicates if a project has email notifications disabled |
| `epic` | Epic | Epic to which this issue belongs |
| `epicIssueId` | ID! | ID of the epic-issue relation |
| `healthStatus` | HealthStatus | Current health status. Returns null if `save_issuable_health_status` feature flag is disabled. |
......@@ -1480,6 +1481,7 @@ Represents a recorded measurement (object count) for the Admins.
| `discussions` | DiscussionConnection! | All discussions on this noteable |
| `downvotes` | Int! | Number of downvotes the issue has received |
| `dueDate` | Time | Due date of the issue |
| `emailsDisabled` | Boolean! | Indicates if a project has email notifications disabled |
| `epic` | Epic | Epic to which this issue belongs |
| `healthStatus` | HealthStatus | Current health status. Returns null if `save_issuable_health_status` feature flag is disabled. |
| `humanTimeEstimate` | String | Human-readable time estimate of the issue |
......
......@@ -16,7 +16,7 @@ RSpec.describe GitlabSchema.types['Issue'] do
it 'has specific fields' do
fields = %i[id iid title description state reference author assignees updated_by participants labels milestone due_date
confidential discussion_locked upvotes downvotes user_notes_count user_discussions_count web_path web_url relative_position
subscribed time_estimate total_time_spent human_time_estimate human_total_time_spent closed_at created_at updated_at task_completion_status
emails_disabled subscribed time_estimate total_time_spent human_time_estimate human_total_time_spent closed_at created_at updated_at task_completion_status
designs design_collection alert_management_alert severity current_user_todos]
fields.each do |field_name|
......
......@@ -40,4 +40,20 @@ RSpec.describe IssuePresenter do
expect(presenter.issue_path).to eq("/#{group.name}/#{project.name}/-/issues/#{issue.iid}")
end
end
describe '#project_emails_disabled?' do
subject { presenter.project_emails_disabled? }
it 'returns false when emails notifications is enabled for project' do
is_expected.to be(false)
end
context 'when emails notifications is disabled for project' do
before do
allow(project).to receive(:emails_disabled?).and_return(true)
end
it { is_expected.to be(true) }
end
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