Add attachments for PR reviews (#16075)

* First step for multiple dropzones per page.

* Allow attachments on review comments.

* Lint.

* Fixed accidental initialize of the review textarea.

* Initialize SimpleMDE textarea.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
KN4CK3R 2021-06-15 03:12:33 +02:00 committed by GitHub
parent 0adcea9ba6
commit ebf253b841
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 87 additions and 47 deletions

View file

@ -762,6 +762,8 @@ func updateCommentInfos(e *xorm.Session, opts *CreateCommentOptions, comment *Co
}
}
fallthrough
case CommentTypeReview:
fallthrough
case CommentTypeComment:
if _, err = e.Exec("UPDATE `issue` SET num_comments=num_comments+1 WHERE id=?", opts.Issue.ID); err != nil {
return err

View file

@ -347,7 +347,7 @@ func IsContentEmptyErr(err error) bool {
}
// SubmitReview creates a review out of the existing pending review or creates a new one if no pending review exist
func SubmitReview(doer *User, issue *Issue, reviewType ReviewType, content, commitID string, stale bool) (*Review, *Comment, error) {
func SubmitReview(doer *User, issue *Issue, reviewType ReviewType, content, commitID string, stale bool, attachmentUUIDs []string) (*Review, *Comment, error) {
sess := x.NewSession()
defer sess.Close()
if err := sess.Begin(); err != nil {
@ -419,12 +419,13 @@ func SubmitReview(doer *User, issue *Issue, reviewType ReviewType, content, comm
}
comm, err := createComment(sess, &CreateCommentOptions{
Type: CommentTypeReview,
Doer: doer,
Content: review.Content,
Issue: issue,
Repo: issue.Repo,
ReviewID: review.ID,
Type: CommentTypeReview,
Doer: doer,
Content: review.Content,
Issue: issue,
Repo: issue.Repo,
ReviewID: review.ID,
Attachments: attachmentUUIDs,
})
if err != nil || comm == nil {
return nil, nil, err