Improved comment rendering in "Files" view by adding Comments to DiffLine

Signed-off-by: Jonas Franz <info@jonasfranz.software>
This commit is contained in:
Jonas Franz
2018-05-12 19:09:42 +02:00
parent 58fb672d0d
commit 066086c390
9 changed files with 112 additions and 26 deletions

View File

@@ -456,6 +456,12 @@ func ViewPullFiles(ctx *context.Context) {
ctx.ServerError("GetDiffRange", err)
return
}
if err = diff.LoadComments(issue, ctx.User); err != nil {
ctx.ServerError("LoadComments", err)
return
}
ctx.Data["Diff"] = diff
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
@@ -470,13 +476,6 @@ func ViewPullFiles(ctx *context.Context) {
ctx.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", "commit", startCommitID)
ctx.Data["RawPath"] = setting.AppSubURL + "/" + path.Join(headTarget, "raw", "commit", endCommitID)
ctx.Data["RequireHighlightJS"] = true
pathToLineToComment, err := models.FetchCodeComments(issue, ctx.User)
if err != nil {
ctx.ServerError("FetchCodeComments", err)
return
}
ctx.Data["CodeComments"] = pathToLineToComment
ctx.Data["CurrentReview"], err = models.GetCurrentReview(ctx.User, issue)
if err != nil && !models.IsErrReviewNotExist(err) {
ctx.ServerError("GetCurrentReview", err)