Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
342e8cf8
Commit
342e8cf8
authored
Oct 29, 2020
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature categories to the API G -> Discussions
This adds a feature category to API classes from G -> Discussions
parent
f66ae213
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
78 additions
and
31 deletions
+78
-31
ee/lib/ee/api/helpers/discussions_helpers.rb
ee/lib/ee/api/helpers/discussions_helpers.rb
+3
-3
ee/lib/ee/api/helpers/notes_helpers.rb
ee/lib/ee/api/helpers/notes_helpers.rb
+6
-3
lib/api/discussions.rb
lib/api/discussions.rb
+10
-10
lib/api/helpers/discussions_helpers.rb
lib/api/helpers/discussions_helpers.rb
+7
-2
lib/api/helpers/notes_helpers.rb
lib/api/helpers/notes_helpers.rb
+6
-4
lib/api/import_bitbucket_server.rb
lib/api/import_bitbucket_server.rb
+2
-0
lib/api/import_github.rb
lib/api/import_github.rb
+2
-0
lib/api/issue_links.rb
lib/api/issue_links.rb
+2
-0
lib/api/issues.rb
lib/api/issues.rb
+2
-2
lib/api/job_artifacts.rb
lib/api/job_artifacts.rb
+2
-0
lib/api/jobs.rb
lib/api/jobs.rb
+2
-0
lib/api/keys.rb
lib/api/keys.rb
+2
-0
lib/api/labels.rb
lib/api/labels.rb
+2
-0
lib/api/lint.rb
lib/api/lint.rb
+2
-0
lib/api/markdown.rb
lib/api/markdown.rb
+2
-0
lib/api/members.rb
lib/api/members.rb
+2
-0
lib/api/merge_request_approvals.rb
lib/api/merge_request_approvals.rb
+2
-0
lib/api/merge_request_diffs.rb
lib/api/merge_request_diffs.rb
+2
-0
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+2
-0
lib/api/metrics/dashboard/annotations.rb
lib/api/metrics/dashboard/annotations.rb
+2
-0
lib/api/metrics/user_starred_dashboards.rb
lib/api/metrics/user_starred_dashboards.rb
+2
-0
lib/api/namespaces.rb
lib/api/namespaces.rb
+2
-0
lib/api/notes.rb
lib/api/notes.rb
+5
-5
spec/lib/api/every_api_endpoint_spec.rb
spec/lib/api/every_api_endpoint_spec.rb
+7
-2
No files found.
ee/lib/ee/api/helpers/discussions_helpers.rb
View file @
342e8cf8
...
...
@@ -9,9 +9,9 @@ module EE
class_methods
do
extend
::
Gitlab
::
Utils
::
Override
override
:
noteable_types
def
noteable_types
[
::
Epic
,
*
super
]
override
:
feature_category_per_noteable_type
def
feature_category_per_noteable_type
super
.
merge!
(
::
Epic
=>
:issue_tracking
)
end
end
end
...
...
ee/lib/ee/api/helpers/notes_helpers.rb
View file @
342e8cf8
...
...
@@ -9,9 +9,12 @@ module EE
class_methods
do
extend
::
Gitlab
::
Utils
::
Override
override
:noteable_types
def
noteable_types
[
::
Epic
,
::
Vulnerability
,
*
super
]
override
:feature_category_per_noteable_type
def
feature_category_per_noteable_type
super
.
merge!
(
::
Epic
=>
:issue_tracking
,
::
Vulnerability
=>
:vulnerability_management
)
end
end
...
...
lib/api/discussions.rb
View file @
342e8cf8
...
...
@@ -8,7 +8,7 @@ module API
before
{
authenticate!
}
Helpers
::
DiscussionsHelpers
.
noteable_types
.
each
do
|
noteable_type
|
Helpers
::
DiscussionsHelpers
.
feature_category_per_noteable_type
.
each
do
|
noteable_type
,
feature_category
|
parent_type
=
noteable_type
.
parent_class
.
to_s
.
underscore
noteables_str
=
noteable_type
.
to_s
.
underscore
.
pluralize
noteables_path
=
noteable_type
==
Commit
?
"repository/
#{
noteables_str
}
"
:
noteables_str
...
...
@@ -25,7 +25,7 @@ module API
use
:pagination
end
get
":id/
#{
noteables_path
}
/:noteable_id/discussions"
do
get
":id/
#{
noteables_path
}
/:noteable_id/discussions"
,
feature_category:
feature_category
do
noteable
=
find_noteable
(
noteable_type
,
params
[
:noteable_id
])
discussion_ids
=
paginate
(
noteable
.
discussion_ids_relation
)
...
...
@@ -41,7 +41,7 @@ module API
requires
:discussion_id
,
type:
String
,
desc:
'The ID of a discussion'
requires
:noteable_id
,
types:
[
Integer
,
String
],
desc:
'The ID of the noteable'
end
get
":id/
#{
noteables_path
}
/:noteable_id/discussions/:discussion_id"
do
get
":id/
#{
noteables_path
}
/:noteable_id/discussions/:discussion_id"
,
feature_category:
feature_category
do
noteable
=
find_noteable
(
noteable_type
,
params
[
:noteable_id
])
notes
=
readable_discussion_notes
(
noteable
,
params
[
:discussion_id
])
...
...
@@ -91,7 +91,7 @@ module API
end
end
end
post
":id/
#{
noteables_path
}
/:noteable_id/discussions"
do
post
":id/
#{
noteables_path
}
/:noteable_id/discussions"
,
feature_category:
feature_category
do
noteable
=
find_noteable
(
noteable_type
,
params
[
:noteable_id
])
type
=
params
[
:position
]
?
'DiffNote'
:
'DiscussionNote'
id_key
=
noteable
.
is_a?
(
Commit
)
?
:commit_id
:
:noteable_id
...
...
@@ -121,7 +121,7 @@ module API
requires
:discussion_id
,
type:
String
,
desc:
'The ID of a discussion'
requires
:noteable_id
,
types:
[
Integer
,
String
],
desc:
'The ID of the noteable'
end
get
":id/
#{
noteables_path
}
/:noteable_id/discussions/:discussion_id/notes"
do
get
":id/
#{
noteables_path
}
/:noteable_id/discussions/:discussion_id/notes"
,
feature_category:
feature_category
do
noteable
=
find_noteable
(
noteable_type
,
params
[
:noteable_id
])
notes
=
readable_discussion_notes
(
noteable
,
params
[
:discussion_id
])
...
...
@@ -141,7 +141,7 @@ module API
requires
:body
,
type:
String
,
desc:
'The content of a note'
optional
:created_at
,
type:
String
,
desc:
'The creation date of the note'
end
post
":id/
#{
noteables_path
}
/:noteable_id/discussions/:discussion_id/notes"
do
post
":id/
#{
noteables_path
}
/:noteable_id/discussions/:discussion_id/notes"
,
feature_category:
feature_category
do
noteable
=
find_noteable
(
noteable_type
,
params
[
:noteable_id
])
notes
=
readable_discussion_notes
(
noteable
,
params
[
:discussion_id
])
first_note
=
notes
.
first
...
...
@@ -175,7 +175,7 @@ module API
requires
:discussion_id
,
type:
String
,
desc:
'The ID of a discussion'
requires
:note_id
,
type:
Integer
,
desc:
'The ID of a note'
end
get
":id/
#{
noteables_path
}
/:noteable_id/discussions/:discussion_id/notes/:note_id"
do
get
":id/
#{
noteables_path
}
/:noteable_id/discussions/:discussion_id/notes/:note_id"
,
feature_category:
feature_category
do
noteable
=
find_noteable
(
noteable_type
,
params
[
:noteable_id
])
get_note
(
noteable
,
params
[
:note_id
])
...
...
@@ -192,7 +192,7 @@ module API
optional
:resolved
,
type:
Boolean
,
desc:
'Mark note resolved/unresolved'
exactly_one_of
:body
,
:resolved
end
put
":id/
#{
noteables_path
}
/:noteable_id/discussions/:discussion_id/notes/:note_id"
do
put
":id/
#{
noteables_path
}
/:noteable_id/discussions/:discussion_id/notes/:note_id"
,
feature_category:
feature_category
do
noteable
=
find_noteable
(
noteable_type
,
params
[
:noteable_id
])
if
params
[
:resolved
].
nil?
...
...
@@ -210,7 +210,7 @@ module API
requires
:discussion_id
,
type:
String
,
desc:
'The ID of a discussion'
requires
:note_id
,
type:
Integer
,
desc:
'The ID of a note'
end
delete
":id/
#{
noteables_path
}
/:noteable_id/discussions/:discussion_id/notes/:note_id"
do
delete
":id/
#{
noteables_path
}
/:noteable_id/discussions/:discussion_id/notes/:note_id"
,
feature_category:
feature_category
do
noteable
=
find_noteable
(
noteable_type
,
params
[
:noteable_id
])
delete_note
(
noteable
,
params
[
:note_id
])
...
...
@@ -225,7 +225,7 @@ module API
requires
:discussion_id
,
type:
String
,
desc:
'The ID of a discussion'
requires
:resolved
,
type:
Boolean
,
desc:
'Mark discussion resolved/unresolved'
end
put
":id/
#{
noteables_path
}
/:noteable_id/discussions/:discussion_id"
do
put
":id/
#{
noteables_path
}
/:noteable_id/discussions/:discussion_id"
,
feature_category:
feature_category
do
noteable
=
find_noteable
(
noteable_type
,
params
[
:noteable_id
])
resolve_discussion
(
noteable
,
params
[
:discussion_id
],
params
[
:resolved
])
...
...
lib/api/helpers/discussions_helpers.rb
View file @
342e8cf8
...
...
@@ -3,10 +3,15 @@
module
API
module
Helpers
module
DiscussionsHelpers
def
self
.
noteable_types
def
self
.
feature_category_per_noteable_type
# This is a method instead of a constant, allowing EE to more easily
# extend it.
[
Issue
,
Snippet
,
MergeRequest
,
Commit
]
{
Issue
=>
:issue_tracking
,
Snippet
=>
:snippets
,
MergeRequest
=>
:code_review
,
Commit
=>
:code_review
}
end
end
end
...
...
lib/api/helpers/notes_helpers.rb
View file @
342e8cf8
...
...
@@ -5,10 +5,12 @@ module API
module
NotesHelpers
include
::
RendersNotes
def
self
.
noteable_types
# This is a method instead of a constant, allowing EE to more easily
# extend it.
[
Issue
,
MergeRequest
,
Snippet
]
def
self
.
feature_category_per_noteable_type
{
Issue
=>
:issue_tracking
,
MergeRequest
=>
:code_review
,
Snippet
=>
:snippets
}
end
def
update_note
(
noteable
,
note_id
)
...
...
lib/api/import_bitbucket_server.rb
View file @
342e8cf8
...
...
@@ -2,6 +2,8 @@
module
API
class
ImportBitbucketServer
<
::
API
::
Base
feature_category
:importers
helpers
do
def
client
@client
||=
BitbucketServer
::
Client
.
new
(
credentials
)
...
...
lib/api/import_github.rb
View file @
342e8cf8
...
...
@@ -2,6 +2,8 @@
module
API
class
ImportGithub
<
::
API
::
Base
feature_category
:importers
rescue_from
Octokit
::
Unauthorized
,
with: :provider_unauthorized
before
do
...
...
lib/api/issue_links.rb
View file @
342e8cf8
...
...
@@ -6,6 +6,8 @@ module API
before
{
authenticate!
}
feature_category
:issue_tracking
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
requires
:issue_iid
,
type:
Integer
,
desc:
'The internal ID of a project issue'
...
...
lib/api/issues.rb
View file @
342e8cf8
...
...
@@ -6,10 +6,10 @@ module API
helpers
Helpers
::
IssuesHelpers
helpers
Helpers
::
RateLimiter
feature_category
:issue_tracking
before
{
authenticate_non_get!
}
feature_category
:issue_tracking
helpers
do
params
:negatable_issue_filter_params
do
optional
:labels
,
type:
Array
[
String
],
coerce_with:
::
API
::
Validations
::
Types
::
CommaSeparatedToArray
.
coerce
,
desc:
'Comma-separated list of label names'
...
...
lib/api/job_artifacts.rb
View file @
342e8cf8
...
...
@@ -4,6 +4,8 @@ module API
class
JobArtifacts
<
::
API
::
Base
before
{
authenticate_non_get!
}
feature_category
:continuous_integration
# EE::API::JobArtifacts would override the following helpers
helpers
do
def
authorize_download_artifacts!
...
...
lib/api/jobs.rb
View file @
342e8cf8
...
...
@@ -6,6 +6,8 @@ module API
before
{
authenticate!
}
feature_category
:continuous_integration
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
...
...
lib/api/keys.rb
View file @
342e8cf8
...
...
@@ -5,6 +5,8 @@ module API
class
Keys
<
::
API
::
Base
before
{
authenticate!
}
feature_category
:authentication_and_authorization
resource
:keys
do
desc
'Get single ssh key by id. Only available to admin users'
do
success
Entities
::
SSHKeyWithUser
...
...
lib/api/labels.rb
View file @
342e8cf8
...
...
@@ -7,6 +7,8 @@ module API
before
{
authenticate!
}
feature_category
:issue_tracking
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
...
...
lib/api/lint.rb
View file @
342e8cf8
...
...
@@ -2,6 +2,8 @@
module
API
class
Lint
<
::
API
::
Base
feature_category
:pipeline_authoring
namespace
:ci
do
desc
'Validation of .gitlab-ci.yml content'
params
do
...
...
lib/api/markdown.rb
View file @
342e8cf8
...
...
@@ -2,6 +2,8 @@
module
API
class
Markdown
<
::
API
::
Base
feature_category
:not_owned
params
do
requires
:text
,
type:
String
,
desc:
"The markdown text to render"
optional
:gfm
,
type:
Boolean
,
desc:
"Render text using GitLab Flavored Markdown"
...
...
lib/api/members.rb
View file @
342e8cf8
...
...
@@ -6,6 +6,8 @@ module API
before
{
authenticate!
}
feature_category
:authentication_and_authorization
helpers
::
API
::
Helpers
::
MembersHelpers
%w[group project]
.
each
do
|
source_type
|
...
...
lib/api/merge_request_approvals.rb
View file @
342e8cf8
...
...
@@ -4,6 +4,8 @@ module API
class
MergeRequestApprovals
<
::
API
::
Base
before
{
authenticate_non_get!
}
feature_category
:code_review
helpers
do
params
:ee_approval_params
do
end
...
...
lib/api/merge_request_diffs.rb
View file @
342e8cf8
...
...
@@ -7,6 +7,8 @@ module API
before
{
authenticate!
}
feature_category
:code_review
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
...
...
lib/api/merge_requests.rb
View file @
342e8cf8
...
...
@@ -8,6 +8,8 @@ module API
before
{
authenticate_non_get!
}
feature_category
:code_review
helpers
Helpers
::
MergeRequestsHelpers
# EE::API::MergeRequests would override the following helpers
...
...
lib/api/metrics/dashboard/annotations.rb
View file @
342e8cf8
...
...
@@ -4,6 +4,8 @@ module API
module
Metrics
module
Dashboard
class
Annotations
<
::
API
::
Base
feature_category
:metrics
desc
'Create a new monitoring dashboard annotation'
do
success
Entities
::
Metrics
::
Dashboard
::
Annotation
end
...
...
lib/api/metrics/user_starred_dashboards.rb
View file @
342e8cf8
...
...
@@ -3,6 +3,8 @@
module
API
module
Metrics
class
UserStarredDashboards
<
::
API
::
Base
feature_category
:metrics
resource
:projects
do
desc
'Marks selected metrics dashboard as starred'
do
success
Entities
::
Metrics
::
UserStarredDashboard
...
...
lib/api/namespaces.rb
View file @
342e8cf8
...
...
@@ -6,6 +6,8 @@ module API
before
{
authenticate!
}
feature_category
:subgroups
helpers
do
params
:optional_list_params_ee
do
# EE::API::Namespaces would override this helper
...
...
lib/api/notes.rb
View file @
342e8cf8
...
...
@@ -7,7 +7,7 @@ module API
before
{
authenticate!
}
Helpers
::
NotesHelpers
.
noteable_types
.
each
do
|
noteable_type
|
Helpers
::
NotesHelpers
.
feature_category_per_noteable_type
.
each
do
|
noteable_type
,
feature_category
|
parent_type
=
noteable_type
.
parent_class
.
to_s
.
underscore
noteables_str
=
noteable_type
.
to_s
.
underscore
.
pluralize
...
...
@@ -29,7 +29,7 @@ module API
use
:pagination
end
# rubocop: disable CodeReuse/ActiveRecord
get
":id/
#{
noteables_str
}
/:noteable_id/notes"
do
get
":id/
#{
noteables_str
}
/:noteable_id/notes"
,
feature_category:
feature_category
do
noteable
=
find_noteable
(
noteable_type
,
params
[
:noteable_id
])
# We exclude notes that are cross-references and that cannot be viewed
...
...
@@ -57,7 +57,7 @@ module API
requires
:note_id
,
type:
Integer
,
desc:
'The ID of a note'
requires
:noteable_id
,
type:
Integer
,
desc:
'The ID of the noteable'
end
get
":id/
#{
noteables_str
}
/:noteable_id/notes/:note_id"
do
get
":id/
#{
noteables_str
}
/:noteable_id/notes/:note_id"
,
feature_category:
feature_category
do
noteable
=
find_noteable
(
noteable_type
,
params
[
:noteable_id
])
get_note
(
noteable
,
params
[
:note_id
])
end
...
...
@@ -71,7 +71,7 @@ module API
optional
:confidential
,
type:
Boolean
,
desc:
'Confidentiality note flag, default is false'
optional
:created_at
,
type:
String
,
desc:
'The creation date of the note'
end
post
":id/
#{
noteables_str
}
/:noteable_id/notes"
do
post
":id/
#{
noteables_str
}
/:noteable_id/notes"
,
feature_category:
feature_category
do
noteable
=
find_noteable
(
noteable_type
,
params
[
:noteable_id
])
opts
=
{
...
...
@@ -104,7 +104,7 @@ module API
optional
:body
,
type:
String
,
allow_blank:
false
,
desc:
'The content of a note'
optional
:confidential
,
type:
Boolean
,
desc:
'Confidentiality note flag'
end
put
":id/
#{
noteables_str
}
/:noteable_id/notes/:note_id"
do
put
":id/
#{
noteables_str
}
/:noteable_id/notes/:note_id"
,
feature_category:
feature_category
do
noteable
=
find_noteable
(
noteable_type
,
params
[
:noteable_id
])
update_note
(
noteable
,
params
[
:note_id
])
...
...
spec/lib/api/every_api_endpoint_spec.rb
View file @
342e8cf8
...
...
@@ -31,8 +31,13 @@ RSpec.describe 'Every API endpoint' do
::
API
::
FeatureFlagsUserLists
,
::
API
::
Features
,
::
API
::
Files
,
::
API
::
FreezePeriods
,
::
API
::
GroupBoards
,
::
API
::
GroupClusters
,
::
API
::
GroupExport
,
::
API
::
GroupImport
,
::
API
::
GroupLabels
,
::
API
::
GroupMilestones
,
::
API
::
Groups
,
::
API
::
GroupContainerRepositories
,
::
API
::
GroupVariables
::
API
::
GroupContainerRepositories
,
::
API
::
GroupVariables
,
::
API
::
ImportBitbucketServer
,
::
API
::
ImportGithub
,
::
API
::
IssueLinks
,
::
API
::
Issues
,
::
API
::
JobArtifacts
,
::
API
::
Jobs
,
::
API
::
Keys
,
::
API
::
Labels
,
::
API
::
Lint
,
::
API
::
Markdown
,
::
API
::
Members
,
::
API
::
MergeRequestDiffs
,
::
API
::
MergeRequests
,
::
API
::
MergeRequestApprovals
,
::
API
::
Metrics
::
Dashboard
::
Annotations
,
::
API
::
Metrics
::
UserStarredDashboards
,
::
API
::
Namespaces
,
::
API
::
Notes
,
::
API
::
Discussions
]
next
unless
completed_classes
.
include?
(
klass
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment