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