Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/draft_notes.rb')
-rw-r--r--lib/api/draft_notes.rb39
1 files changed, 37 insertions, 2 deletions
diff --git a/lib/api/draft_notes.rb b/lib/api/draft_notes.rb
index df9e060e592..6fadc68233d 100644
--- a/lib/api/draft_notes.rb
+++ b/lib/api/draft_notes.rb
@@ -45,9 +45,42 @@ module API
access_denied! unless can?(current_user, :admin_note, draft_note)
end
+ params :positional do
+ optional :position, type: Hash do
+ requires :base_sha, type: String, desc: 'Base commit SHA in the source branch'
+ requires :start_sha, type: String, desc: 'SHA referencing commit in target branch'
+ requires :head_sha, type: String, desc: 'SHA referencing HEAD of this merge request'
+ requires :position_type, type: String, desc: 'Type of the position reference', values: %w[text image]
+ optional :new_path, type: String, desc: 'File path after change'
+ optional :new_line, type: Integer, desc: 'Line number after change'
+ optional :old_path, type: String, desc: 'File path before change'
+ optional :old_line, type: Integer, desc: 'Line number before change'
+ optional :width, type: Integer, desc: 'Width of the image'
+ optional :height, type: Integer, desc: 'Height of the image'
+ optional :x, type: Integer, desc: 'X coordinate in the image'
+ optional :y, type: Integer, desc: 'Y coordinate in the image'
+
+ optional :line_range, type: Hash, desc: 'Multi-line start and end' do
+ optional :start, type: Hash do
+ optional :line_code, type: String, desc: 'Start line code for multi-line note'
+ optional :type, type: String, desc: 'Start line type for multi-line note'
+ optional :old_line, type: String, desc: 'Start old_line line number'
+ optional :new_line, type: String, desc: 'Start new_line line number'
+ end
+ optional :end, type: Hash do
+ optional :line_code, type: String, desc: 'End line code for multi-line note'
+ optional :type, type: String, desc: 'End line type for multi-line note'
+ optional :old_line, type: String, desc: 'End old_line line number'
+ optional :new_line, type: String, desc: 'End new_line line number'
+ end
+ end
+ end
+ end
+
def draft_note_params
{
note: params[:note],
+ position: params[:position],
commit_id: params[:commit_id] == 'undefined' ? nil : params[:commit_id],
resolve_discussion: params[:resolve_discussion] || false
}
@@ -104,9 +137,10 @@ module API
requires :id, type: String, desc: "The ID of a project."
requires :merge_request_iid, type: Integer, desc: "The ID of a merge request."
requires :note, type: String, desc: 'The content of a note.'
- optional :in_reply_to_discussion_id, type: Integer, desc: 'The ID of a discussion the draft note replies to.'
+ optional :in_reply_to_discussion_id, type: String, desc: 'The ID of a discussion the draft note replies to.'
optional :commit_id, type: String, desc: 'The sha of a commit to associate the draft note to.'
optional :resolve_discussion, type: Boolean, desc: 'The associated discussion should be resolved.'
+ use :positional
end
post ":id/merge_requests/:merge_request_iid/draft_notes", feature_category: :code_review_workflow do
authorize_create_note!(params: params)
@@ -135,6 +169,7 @@ module API
requires :merge_request_iid, type: Integer, desc: "The ID of a merge request."
requires :draft_note_id, type: Integer, desc: "The ID of a draft note"
optional :note, type: String, allow_blank: false, desc: 'The content of a note.'
+ use :positional
end
put ":id/merge_requests/:merge_request_iid/draft_notes/:draft_note_id", feature_category: :code_review_workflow do
bad_request!('Missing params to modify') unless params[:note].present?
@@ -144,7 +179,7 @@ module API
if draft_note
authorize_admin_draft!(draft_note)
- draft_note.update!(note: params[:note])
+ draft_note.update!(note: params[:note], position: params[:position])
present draft_note, with: Entities::DraftNote
else
not_found!("Draft Note")