Commit 342e8cf8 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Add feature categories to the API G -> Discussions

This adds a feature category to API classes from G -> Discussions
parent f66ae213
...@@ -9,9 +9,9 @@ module EE ...@@ -9,9 +9,9 @@ module EE
class_methods do class_methods do
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
override :noteable_types override :feature_category_per_noteable_type
def noteable_types def feature_category_per_noteable_type
[::Epic, *super] super.merge!(::Epic => :issue_tracking)
end end
end end
end end
......
...@@ -9,9 +9,12 @@ module EE ...@@ -9,9 +9,12 @@ module EE
class_methods do class_methods do
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
override :noteable_types override :feature_category_per_noteable_type
def noteable_types def feature_category_per_noteable_type
[::Epic, ::Vulnerability, *super] super.merge!(
::Epic => :issue_tracking,
::Vulnerability => :vulnerability_management
)
end end
end end
......
...@@ -8,7 +8,7 @@ module API ...@@ -8,7 +8,7 @@ module API
before { authenticate! } 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 parent_type = noteable_type.parent_class.to_s.underscore
noteables_str = noteable_type.to_s.underscore.pluralize noteables_str = noteable_type.to_s.underscore.pluralize
noteables_path = noteable_type == Commit ? "repository/#{noteables_str}" : noteables_str noteables_path = noteable_type == Commit ? "repository/#{noteables_str}" : noteables_str
...@@ -25,7 +25,7 @@ module API ...@@ -25,7 +25,7 @@ module API
use :pagination use :pagination
end 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]) noteable = find_noteable(noteable_type, params[:noteable_id])
discussion_ids = paginate(noteable.discussion_ids_relation) discussion_ids = paginate(noteable.discussion_ids_relation)
...@@ -41,7 +41,7 @@ module API ...@@ -41,7 +41,7 @@ module API
requires :discussion_id, type: String, desc: 'The ID of a discussion' requires :discussion_id, type: String, desc: 'The ID of a discussion'
requires :noteable_id, types: [Integer, String], desc: 'The ID of the noteable' requires :noteable_id, types: [Integer, String], desc: 'The ID of the noteable'
end 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]) noteable = find_noteable(noteable_type, params[:noteable_id])
notes = readable_discussion_notes(noteable, params[:discussion_id]) notes = readable_discussion_notes(noteable, params[:discussion_id])
...@@ -91,7 +91,7 @@ module API ...@@ -91,7 +91,7 @@ module API
end end
end 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]) noteable = find_noteable(noteable_type, params[:noteable_id])
type = params[:position] ? 'DiffNote' : 'DiscussionNote' type = params[:position] ? 'DiffNote' : 'DiscussionNote'
id_key = noteable.is_a?(Commit) ? :commit_id : :noteable_id id_key = noteable.is_a?(Commit) ? :commit_id : :noteable_id
...@@ -121,7 +121,7 @@ module API ...@@ -121,7 +121,7 @@ module API
requires :discussion_id, type: String, desc: 'The ID of a discussion' requires :discussion_id, type: String, desc: 'The ID of a discussion'
requires :noteable_id, types: [Integer, String], desc: 'The ID of the noteable' requires :noteable_id, types: [Integer, String], desc: 'The ID of the noteable'
end 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]) noteable = find_noteable(noteable_type, params[:noteable_id])
notes = readable_discussion_notes(noteable, params[:discussion_id]) notes = readable_discussion_notes(noteable, params[:discussion_id])
...@@ -141,7 +141,7 @@ module API ...@@ -141,7 +141,7 @@ module API
requires :body, type: String, desc: 'The content of a note' requires :body, type: String, desc: 'The content of a note'
optional :created_at, type: String, desc: 'The creation date of the note' optional :created_at, type: String, desc: 'The creation date of the note'
end 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]) noteable = find_noteable(noteable_type, params[:noteable_id])
notes = readable_discussion_notes(noteable, params[:discussion_id]) notes = readable_discussion_notes(noteable, params[:discussion_id])
first_note = notes.first first_note = notes.first
...@@ -175,7 +175,7 @@ module API ...@@ -175,7 +175,7 @@ module API
requires :discussion_id, type: String, desc: 'The ID of a discussion' requires :discussion_id, type: String, desc: 'The ID of a discussion'
requires :note_id, type: Integer, desc: 'The ID of a note' requires :note_id, type: Integer, desc: 'The ID of a note'
end 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]) noteable = find_noteable(noteable_type, params[:noteable_id])
get_note(noteable, params[:note_id]) get_note(noteable, params[:note_id])
...@@ -192,7 +192,7 @@ module API ...@@ -192,7 +192,7 @@ module API
optional :resolved, type: Boolean, desc: 'Mark note resolved/unresolved' optional :resolved, type: Boolean, desc: 'Mark note resolved/unresolved'
exactly_one_of :body, :resolved exactly_one_of :body, :resolved
end 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]) noteable = find_noteable(noteable_type, params[:noteable_id])
if params[:resolved].nil? if params[:resolved].nil?
...@@ -210,7 +210,7 @@ module API ...@@ -210,7 +210,7 @@ module API
requires :discussion_id, type: String, desc: 'The ID of a discussion' requires :discussion_id, type: String, desc: 'The ID of a discussion'
requires :note_id, type: Integer, desc: 'The ID of a note' requires :note_id, type: Integer, desc: 'The ID of a note'
end 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]) noteable = find_noteable(noteable_type, params[:noteable_id])
delete_note(noteable, params[:note_id]) delete_note(noteable, params[:note_id])
...@@ -225,7 +225,7 @@ module API ...@@ -225,7 +225,7 @@ module API
requires :discussion_id, type: String, desc: 'The ID of a discussion' requires :discussion_id, type: String, desc: 'The ID of a discussion'
requires :resolved, type: Boolean, desc: 'Mark discussion resolved/unresolved' requires :resolved, type: Boolean, desc: 'Mark discussion resolved/unresolved'
end 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]) noteable = find_noteable(noteable_type, params[:noteable_id])
resolve_discussion(noteable, params[:discussion_id], params[:resolved]) resolve_discussion(noteable, params[:discussion_id], params[:resolved])
......
...@@ -3,10 +3,15 @@ ...@@ -3,10 +3,15 @@
module API module API
module Helpers module Helpers
module DiscussionsHelpers 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 # This is a method instead of a constant, allowing EE to more easily
# extend it. # extend it.
[Issue, Snippet, MergeRequest, Commit] {
Issue => :issue_tracking,
Snippet => :snippets,
MergeRequest => :code_review,
Commit => :code_review
}
end end
end end
end end
......
...@@ -5,10 +5,12 @@ module API ...@@ -5,10 +5,12 @@ module API
module NotesHelpers module NotesHelpers
include ::RendersNotes include ::RendersNotes
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 => :issue_tracking,
[Issue, MergeRequest, Snippet] MergeRequest => :code_review,
Snippet => :snippets
}
end end
def update_note(noteable, note_id) def update_note(noteable, note_id)
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
module API module API
class ImportBitbucketServer < ::API::Base class ImportBitbucketServer < ::API::Base
feature_category :importers
helpers do helpers do
def client def client
@client ||= BitbucketServer::Client.new(credentials) @client ||= BitbucketServer::Client.new(credentials)
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
module API module API
class ImportGithub < ::API::Base class ImportGithub < ::API::Base
feature_category :importers
rescue_from Octokit::Unauthorized, with: :provider_unauthorized rescue_from Octokit::Unauthorized, with: :provider_unauthorized
before do before do
......
...@@ -6,6 +6,8 @@ module API ...@@ -6,6 +6,8 @@ module API
before { authenticate! } before { authenticate! }
feature_category :issue_tracking
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue' requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue'
......
...@@ -6,10 +6,10 @@ module API ...@@ -6,10 +6,10 @@ module API
helpers Helpers::IssuesHelpers helpers Helpers::IssuesHelpers
helpers Helpers::RateLimiter helpers Helpers::RateLimiter
feature_category :issue_tracking
before { authenticate_non_get! } before { authenticate_non_get! }
feature_category :issue_tracking
helpers do helpers do
params :negatable_issue_filter_params 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' optional :labels, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'Comma-separated list of label names'
......
...@@ -4,6 +4,8 @@ module API ...@@ -4,6 +4,8 @@ module API
class JobArtifacts < ::API::Base class JobArtifacts < ::API::Base
before { authenticate_non_get! } before { authenticate_non_get! }
feature_category :continuous_integration
# EE::API::JobArtifacts would override the following helpers # EE::API::JobArtifacts would override the following helpers
helpers do helpers do
def authorize_download_artifacts! def authorize_download_artifacts!
......
...@@ -6,6 +6,8 @@ module API ...@@ -6,6 +6,8 @@ module API
before { authenticate! } before { authenticate! }
feature_category :continuous_integration
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
......
...@@ -5,6 +5,8 @@ module API ...@@ -5,6 +5,8 @@ module API
class Keys < ::API::Base class Keys < ::API::Base
before { authenticate! } before { authenticate! }
feature_category :authentication_and_authorization
resource :keys do resource :keys do
desc 'Get single ssh key by id. Only available to admin users' do desc 'Get single ssh key by id. Only available to admin users' do
success Entities::SSHKeyWithUser success Entities::SSHKeyWithUser
......
...@@ -7,6 +7,8 @@ module API ...@@ -7,6 +7,8 @@ module API
before { authenticate! } before { authenticate! }
feature_category :issue_tracking
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
module API module API
class Lint < ::API::Base class Lint < ::API::Base
feature_category :pipeline_authoring
namespace :ci do namespace :ci do
desc 'Validation of .gitlab-ci.yml content' desc 'Validation of .gitlab-ci.yml content'
params do params do
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
module API module API
class Markdown < ::API::Base class Markdown < ::API::Base
feature_category :not_owned
params do params do
requires :text, type: String, desc: "The markdown text to render" requires :text, type: String, desc: "The markdown text to render"
optional :gfm, type: Boolean, desc: "Render text using GitLab Flavored Markdown" optional :gfm, type: Boolean, desc: "Render text using GitLab Flavored Markdown"
......
...@@ -6,6 +6,8 @@ module API ...@@ -6,6 +6,8 @@ module API
before { authenticate! } before { authenticate! }
feature_category :authentication_and_authorization
helpers ::API::Helpers::MembersHelpers helpers ::API::Helpers::MembersHelpers
%w[group project].each do |source_type| %w[group project].each do |source_type|
......
...@@ -4,6 +4,8 @@ module API ...@@ -4,6 +4,8 @@ module API
class MergeRequestApprovals < ::API::Base class MergeRequestApprovals < ::API::Base
before { authenticate_non_get! } before { authenticate_non_get! }
feature_category :code_review
helpers do helpers do
params :ee_approval_params do params :ee_approval_params do
end end
......
...@@ -7,6 +7,8 @@ module API ...@@ -7,6 +7,8 @@ module API
before { authenticate! } before { authenticate! }
feature_category :code_review
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
......
...@@ -8,6 +8,8 @@ module API ...@@ -8,6 +8,8 @@ module API
before { authenticate_non_get! } before { authenticate_non_get! }
feature_category :code_review
helpers Helpers::MergeRequestsHelpers helpers Helpers::MergeRequestsHelpers
# EE::API::MergeRequests would override the following helpers # EE::API::MergeRequests would override the following helpers
......
...@@ -4,6 +4,8 @@ module API ...@@ -4,6 +4,8 @@ module API
module Metrics module Metrics
module Dashboard module Dashboard
class Annotations < ::API::Base class Annotations < ::API::Base
feature_category :metrics
desc 'Create a new monitoring dashboard annotation' do desc 'Create a new monitoring dashboard annotation' do
success Entities::Metrics::Dashboard::Annotation success Entities::Metrics::Dashboard::Annotation
end end
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
module API module API
module Metrics module Metrics
class UserStarredDashboards < ::API::Base class UserStarredDashboards < ::API::Base
feature_category :metrics
resource :projects do resource :projects do
desc 'Marks selected metrics dashboard as starred' do desc 'Marks selected metrics dashboard as starred' do
success Entities::Metrics::UserStarredDashboard success Entities::Metrics::UserStarredDashboard
......
...@@ -6,6 +6,8 @@ module API ...@@ -6,6 +6,8 @@ module API
before { authenticate! } before { authenticate! }
feature_category :subgroups
helpers do helpers do
params :optional_list_params_ee do params :optional_list_params_ee do
# EE::API::Namespaces would override this helper # EE::API::Namespaces would override this helper
......
...@@ -7,7 +7,7 @@ module API ...@@ -7,7 +7,7 @@ module API
before { authenticate! } 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 parent_type = noteable_type.parent_class.to_s.underscore
noteables_str = noteable_type.to_s.underscore.pluralize noteables_str = noteable_type.to_s.underscore.pluralize
...@@ -29,7 +29,7 @@ module API ...@@ -29,7 +29,7 @@ module API
use :pagination use :pagination
end end
# rubocop: disable CodeReuse/ActiveRecord # 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]) noteable = find_noteable(noteable_type, params[:noteable_id])
# We exclude notes that are cross-references and that cannot be viewed # We exclude notes that are cross-references and that cannot be viewed
...@@ -57,7 +57,7 @@ module API ...@@ -57,7 +57,7 @@ module API
requires :note_id, type: Integer, desc: 'The ID of a note' requires :note_id, type: Integer, desc: 'The ID of a note'
requires :noteable_id, type: Integer, desc: 'The ID of the noteable' requires :noteable_id, type: Integer, desc: 'The ID of the noteable'
end 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]) noteable = find_noteable(noteable_type, params[:noteable_id])
get_note(noteable, params[:note_id]) get_note(noteable, params[:note_id])
end end
...@@ -71,7 +71,7 @@ module API ...@@ -71,7 +71,7 @@ module API
optional :confidential, type: Boolean, desc: 'Confidentiality note flag, default is false' optional :confidential, type: Boolean, desc: 'Confidentiality note flag, default is false'
optional :created_at, type: String, desc: 'The creation date of the note' optional :created_at, type: String, desc: 'The creation date of the note'
end 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]) noteable = find_noteable(noteable_type, params[:noteable_id])
opts = { opts = {
...@@ -104,7 +104,7 @@ module API ...@@ -104,7 +104,7 @@ module API
optional :body, type: String, allow_blank: false, desc: 'The content of a note' optional :body, type: String, allow_blank: false, desc: 'The content of a note'
optional :confidential, type: Boolean, desc: 'Confidentiality note flag' optional :confidential, type: Boolean, desc: 'Confidentiality note flag'
end 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]) noteable = find_noteable(noteable_type, params[:noteable_id])
update_note(noteable, params[:note_id]) update_note(noteable, params[:note_id])
......
...@@ -31,8 +31,13 @@ RSpec.describe 'Every API endpoint' do ...@@ -31,8 +31,13 @@ RSpec.describe 'Every API endpoint' do
::API::FeatureFlagsUserLists, ::API::Features, ::API::Files, ::API::FreezePeriods, ::API::FeatureFlagsUserLists, ::API::Features, ::API::Files, ::API::FreezePeriods,
::API::GroupBoards, ::API::GroupClusters, ::API::GroupExport, ::API::GroupImport, ::API::GroupBoards, ::API::GroupClusters, ::API::GroupExport, ::API::GroupImport,
::API::GroupLabels, ::API::GroupMilestones, ::API::Groups, ::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) next unless completed_classes.include?(klass)
......
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