Commit b5834108 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '207471-confidential-notes-api' into 'master'

Add information about note confidentiality to APIs

See merge request gitlab-org/gitlab!28124
parents 5fa7e989 456a8828
...@@ -51,6 +51,9 @@ module Types ...@@ -51,6 +51,9 @@ module Types
description: "Timestamp of the note's resolution" description: "Timestamp of the note's resolution"
field :position, Types::Notes::DiffPositionType, null: true, field :position, Types::Notes::DiffPositionType, null: true,
description: 'The position of this note on a diff' description: 'The position of this note on a diff'
field :confidential, GraphQL::BOOLEAN_TYPE, null: true,
description: 'Indicates if this note is confidential',
method: :confidential?
end end
end end
end end
...@@ -48,6 +48,7 @@ class DiscussionEntity < Grape::Entity ...@@ -48,6 +48,7 @@ class DiscussionEntity < Grape::Entity
expose :for_commit?, as: :for_commit expose :for_commit?, as: :for_commit
expose :commit_id expose :commit_id
expose :confidential?, as: :confidential
private private
......
...@@ -5335,6 +5335,11 @@ type Note { ...@@ -5335,6 +5335,11 @@ type Note {
""" """
bodyHtml: String bodyHtml: String
"""
Indicates if this note is confidential
"""
confidential: Boolean
""" """
Timestamp of the note creation Timestamp of the note creation
""" """
......
...@@ -16149,6 +16149,20 @@ ...@@ -16149,6 +16149,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "confidential",
"description": "Indicates if this note is confidential",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "createdAt", "name": "createdAt",
"description": "Timestamp of the note creation", "description": "Timestamp of the note creation",
......
...@@ -810,6 +810,7 @@ Represents a milestone. ...@@ -810,6 +810,7 @@ Represents a milestone.
| `author` | User! | User who wrote this note | | `author` | User! | User who wrote this note |
| `body` | String! | Content of the note | | `body` | String! | Content of the note |
| `bodyHtml` | String | The GitLab Flavored Markdown rendering of `note` | | `bodyHtml` | String | The GitLab Flavored Markdown rendering of `note` |
| `confidential` | Boolean | Indicates if this note is confidential |
| `createdAt` | Time! | Timestamp of the note creation | | `createdAt` | Time! | Timestamp of the note creation |
| `discussion` | Discussion | The discussion this note is a part of | | `discussion` | Discussion | The discussion this note is a part of |
| `id` | ID! | ID of the note | | `id` | ID! | ID of the note |
......
...@@ -54,7 +54,8 @@ GET /projects/:id/issues/:issue_iid/notes?sort=asc&order_by=updated_at ...@@ -54,7 +54,8 @@ GET /projects/:id/issues/:issue_iid/notes?sort=asc&order_by=updated_at
"noteable_id": 377, "noteable_id": 377,
"noteable_type": "Issue", "noteable_type": "Issue",
"noteable_iid": 377, "noteable_iid": 377,
"resolvable": false "resolvable": false,
"confidential": false
}, },
{ {
"id": 305, "id": 305,
...@@ -74,7 +75,8 @@ GET /projects/:id/issues/:issue_iid/notes?sort=asc&order_by=updated_at ...@@ -74,7 +75,8 @@ GET /projects/:id/issues/:issue_iid/notes?sort=asc&order_by=updated_at
"noteable_id": 121, "noteable_id": 121,
"noteable_type": "Issue", "noteable_type": "Issue",
"noteable_iid": 121, "noteable_iid": 121,
"resolvable": false "resolvable": false,
"confidential": true
} }
] ]
``` ```
...@@ -332,7 +334,8 @@ Parameters: ...@@ -332,7 +334,8 @@ Parameters:
"noteable_id": 2, "noteable_id": 2,
"noteable_type": "MergeRequest", "noteable_type": "MergeRequest",
"noteable_iid": 2, "noteable_iid": 2,
"resolvable": false "resolvable": false,
"confidential": false
} }
``` ```
...@@ -449,7 +452,8 @@ Parameters: ...@@ -449,7 +452,8 @@ Parameters:
}, },
"expires_at": null, "expires_at": null,
"updated_at": "2013-10-02T07:34:20Z", "updated_at": "2013-10-02T07:34:20Z",
"created_at": "2013-10-02T07:34:20Z" "created_at": "2013-10-02T07:34:20Z",
"confidential": false
} }
``` ```
......
...@@ -23,6 +23,8 @@ module API ...@@ -23,6 +23,8 @@ module API
expose :resolved?, as: :resolved, if: ->(note, options) { note.resolvable? } expose :resolved?, as: :resolved, if: ->(note, options) { note.resolvable? }
expose :resolved_by, using: Entities::UserBasic, if: ->(note, options) { note.resolvable? } expose :resolved_by, using: Entities::UserBasic, if: ->(note, options) { note.resolvable? }
expose :confidential?, as: :confidential
# Avoid N+1 queries as much as possible # Avoid N+1 queries as much as possible
expose(:noteable_iid) { |note| note.noteable.iid if NOTEABLE_TYPES_WITH_IID.include?(note.noteable_type) } expose(:noteable_iid) { |note| note.noteable.iid if NOTEABLE_TYPES_WITH_IID.include?(note.noteable_type) }
......
...@@ -1377,7 +1377,7 @@ describe Projects::IssuesController do ...@@ -1377,7 +1377,7 @@ describe Projects::IssuesController do
it 'returns discussion json' do it 'returns discussion json' do
get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid } get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
expect(json_response.first.keys).to match_array(%w[id reply_id expanded notes diff_discussion discussion_path individual_note resolvable resolved resolved_at resolved_by resolved_by_push commit_id for_commit project_id]) expect(json_response.first.keys).to match_array(%w[id reply_id expanded notes diff_discussion discussion_path individual_note resolvable resolved resolved_at resolved_by resolved_by_push commit_id for_commit project_id confidential])
end end
it 'renders the author status html if there is a status' do it 'renders the author status html if there is a status' do
......
...@@ -55,7 +55,8 @@ ...@@ -55,7 +55,8 @@
"human_access": { "type": ["string", "null"] }, "human_access": { "type": ["string", "null"] },
"toggle_award_path": { "type": "string" }, "toggle_award_path": { "type": "string" },
"path": { "type": "string" }, "path": { "type": "string" },
"commands_changes": { "type": "object", "additionalProperties": true } "commands_changes": { "type": "object", "additionalProperties": true },
"confidential": { "type": ["boolean", "null"] }
}, },
"required": [ "required": [
"id", "attachment", "author", "created_at", "updated_at", "id", "attachment", "author", "created_at", "updated_at",
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
"noteable_type": { "type": "string" }, "noteable_type": { "type": "string" },
"resolved": { "type": "boolean" }, "resolved": { "type": "boolean" },
"resolvable": { "type": "boolean" }, "resolvable": { "type": "boolean" },
"resolved_by": { "type": ["string", "null"] } "resolved_by": { "type": ["string", "null"] },
"confidential": { "type": ["boolean", "null"] }
}, },
"required": [ "required": [
"id", "body", "attachment", "author", "created_at", "updated_at", "id", "body", "attachment", "author", "created_at", "updated_at",
......
...@@ -5,7 +5,7 @@ describe GitlabSchema.types['Note'] do ...@@ -5,7 +5,7 @@ describe GitlabSchema.types['Note'] do
it 'exposes the expected fields' do it 'exposes the expected fields' do
expected_fields = [:id, :project, :author, :body, :created_at, expected_fields = [:id, :project, :author, :body, :created_at,
:updated_at, :discussion, :resolvable, :position, :user_permissions, :updated_at, :discussion, :resolvable, :position, :user_permissions,
:resolved_by, :resolved_at, :system, :body_html] :resolved_by, :resolved_at, :system, :body_html, :confidential]
expect(described_class).to have_graphql_fields(*expected_fields) expect(described_class).to have_graphql_fields(*expected_fields)
end end
......
...@@ -34,7 +34,8 @@ describe DiscussionEntity do ...@@ -34,7 +34,8 @@ describe DiscussionEntity do
:discussion_path, :discussion_path,
:resolved_at, :resolved_at,
:for_commit, :for_commit,
:commit_id :commit_id,
:confidential
) )
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