Commit f3571f65 authored by Eulyeon Ko's avatar Eulyeon Ko

Add notification graphql fields to issue type

Add "emailsDiabled" field that indicates whether the project
associated with an issue has emails notifications enabled or not.

Add "subscribeDisabledDescription" field that contains the message
to display when the project associated with an issue has
emails notifications disabled.
parent a86581ac
......@@ -73,6 +73,10 @@ 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, method: :project_emails_disabled?, null: false, complexity: 5,
description: 'Indicates if a project has email notifications disabled'
field :subscribe_disabled_description, GraphQL::STRING_TYPE, method: :subscribe_disabled_description, null: false,
description: 'The message to display when a project has emails 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,
......
# frozen_string_literal: true
class IssuePresenter < Gitlab::View::Presenter::Delegated
include NotificationsHelper
presents :issue
def issue_path
......@@ -10,6 +12,14 @@ class IssuePresenter < Gitlab::View::Presenter::Delegated
def subscribed?
issue.subscribed?(current_user, issue.project)
end
def project_emails_disabled?
issue.project.emails_disabled?
end
def subscribe_disabled_description
notification_description(:owner_disabled)
end
end
IssuePresenter.prepend_if_ee('EE::IssuePresenter')
---
title: Add emailsDisabled and subscribeDisabledescription fields 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
"""
......@@ -7520,6 +7525,11 @@ type EpicIssue implements CurrentUserTodos & Noteable {
"""
statusPagePublishedIncident: Boolean
"""
The message to display when a project has emails notifications disabled
"""
subscribeDisabledDescription: String!
"""
Indicates the currently logged in user is subscribed to the issue
"""
......@@ -9879,6 +9889,11 @@ type Issue implements CurrentUserTodos & Noteable {
"""
dueDate: Time
"""
Indicates if a project has email notifications disabled
"""
emailsDisabled: Boolean!
"""
Epic to which this issue belongs
"""
......@@ -10029,6 +10044,11 @@ type Issue implements CurrentUserTodos & Noteable {
"""
statusPagePublishedIncident: Boolean
"""
The message to display when a project has emails notifications disabled
"""
subscribeDisabledDescription: String!
"""
Indicates the currently logged in user is subscribed to the issue
"""
......
......@@ -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",
......@@ -20728,6 +20746,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "subscribeDisabledDescription",
"description": "The message to display when a project has emails notifications disabled",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "subscribed",
"description": "Indicates the currently logged in user is subscribed to the issue",
......@@ -26955,6 +26991,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",
......@@ -27339,6 +27393,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "subscribeDisabledDescription",
"description": "The message to display when a project has emails notifications disabled",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "subscribed",
"description": "Indicates the currently logged in user is subscribed to the issue",
......@@ -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. |
......@@ -1233,6 +1234,7 @@ Relationship between an epic and an issue.
| `slaDueAt` | Time | Timestamp of when the issue SLA expires. |
| `state` | IssueState! | State of the issue |
| `statusPagePublishedIncident` | Boolean | Indicates whether an issue is published to the status page |
| `subscribeDisabledDescription` | String! | The message to display when a project has emails notifications disabled |
| `subscribed` | Boolean! | Indicates the currently logged in user is subscribed to the issue |
| `taskCompletionStatus` | TaskCompletionStatus! | Task completion status of the issue |
| `timeEstimate` | Int! | Time estimate of the issue |
......@@ -1480,6 +1482,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 |
......@@ -1497,6 +1500,7 @@ Represents a recorded measurement (object count) for the Admins.
| `slaDueAt` | Time | Timestamp of when the issue SLA expires. |
| `state` | IssueState! | State of the issue |
| `statusPagePublishedIncident` | Boolean | Indicates whether an issue is published to the status page |
| `subscribeDisabledDescription` | String! | The message to display when a project has emails notifications disabled |
| `subscribed` | Boolean! | Indicates the currently logged in user is subscribed to the issue |
| `taskCompletionStatus` | TaskCompletionStatus! | Task completion status of the issue |
| `timeEstimate` | Int! | 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 subscribe_disabled_description 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|
......
......@@ -35,6 +35,31 @@ RSpec.describe IssuePresenter do
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 'returns true' do
is_expected.to be(true)
end
end
end
describe '#subscribe_disabled_description' do
subject { presenter.subscribe_disabled_description }
it 'returns correct message' do
is_expected.to equal('Notifications have been disabled by the project or group owner')
end
end
describe '#issue_path' do
it 'returns correct path' do
expect(presenter.issue_path).to eq("/#{group.name}/#{project.name}/-/issues/#{issue.iid}")
......
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