diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2021-06-15 03:12:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-14 21:12:33 -0400 |
commit | ebf253b841d56c5cb1e57cb1e5e50c06d315bdee (patch) | |
tree | 703f8c4d0302e578d402d6aa42635852303026df /routers | |
parent | 0adcea9ba6946e9479314e188afe53dcb39da6b0 (diff) | |
download | gitea-ebf253b841d56c5cb1e57cb1e5e50c06d315bdee.tar.gz gitea-ebf253b841d56c5cb1e57cb1e5e50c06d315bdee.zip |
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>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/pull_review.go | 4 | ||||
-rw-r--r-- | routers/web/repo/pull.go | 4 | ||||
-rw-r--r-- | routers/web/repo/pull_review.go | 8 |
3 files changed, 13 insertions, 3 deletions
diff --git a/routers/api/v1/repo/pull_review.go b/routers/api/v1/repo/pull_review.go index 63179aa990..35414e0a80 100644 --- a/routers/api/v1/repo/pull_review.go +++ b/routers/api/v1/repo/pull_review.go @@ -359,7 +359,7 @@ func CreatePullReview(ctx *context.APIContext) { } // create review and associate all pending review comments - review, _, err := pull_service.SubmitReview(ctx.User, ctx.Repo.GitRepo, pr.Issue, reviewType, opts.Body, opts.CommitID) + review, _, err := pull_service.SubmitReview(ctx.User, ctx.Repo.GitRepo, pr.Issue, reviewType, opts.Body, opts.CommitID, nil) if err != nil { ctx.Error(http.StatusInternalServerError, "SubmitReview", err) return @@ -447,7 +447,7 @@ func SubmitPullReview(ctx *context.APIContext) { } // create review and associate all pending review comments - review, _, err = pull_service.SubmitReview(ctx.User, ctx.Repo.GitRepo, pr.Issue, reviewType, opts.Body, headCommitID) + review, _, err = pull_service.SubmitReview(ctx.User, ctx.Repo.GitRepo, pr.Issue, reviewType, opts.Body, headCommitID, nil) if err != nil { ctx.Error(http.StatusInternalServerError, "SubmitReview", err) return diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 28f94c8417..e5554e9664 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -694,6 +694,10 @@ func ViewPullFiles(ctx *context.Context) { getBranchData(ctx, issue) ctx.Data["IsIssuePoster"] = ctx.IsSigned && issue.IsPoster(ctx.User.ID) ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) + + ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled + upload.AddUploadContext(ctx, "comment") + ctx.HTML(http.StatusOK, tplPullFiles) } diff --git a/routers/web/repo/pull_review.go b/routers/web/repo/pull_review.go index 9e505c3db3..36eee3f377 100644 --- a/routers/web/repo/pull_review.go +++ b/routers/web/repo/pull_review.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/services/forms" pull_service "code.gitea.io/gitea/services/pull" @@ -211,7 +212,12 @@ func SubmitReview(ctx *context.Context) { } } - _, comm, err := pull_service.SubmitReview(ctx.User, ctx.Repo.GitRepo, issue, reviewType, form.Content, form.CommitID) + var attachments []string + if setting.Attachment.Enabled { + attachments = form.Files + } + + _, comm, err := pull_service.SubmitReview(ctx.User, ctx.Repo.GitRepo, issue, reviewType, form.Content, form.CommitID, attachments) if err != nil { if models.IsContentEmptyErr(err) { ctx.Flash.Error(ctx.Tr("repo.issues.review.content.empty")) |