diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-10-23 22:47:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-23 22:47:38 +0800 |
commit | 943dc087229aa922503eab7e49f4c63667dbb632 (patch) | |
tree | 093cba9ef2897aed1e68219e1b0eb8496faf47b8 /routers/web | |
parent | 6c49517cbd9d353d2d56d899632f301919818a03 (diff) | |
download | gitea-943dc087229aa922503eab7e49f4c63667dbb632.tar.gz gitea-943dc087229aa922503eab7e49f4c63667dbb632.zip |
Fix issue content history problems, improve UI (#17404)
* Improve: make diff result better, make the HTML element fit the full height in the content history diff dialog
* Bug fix: when edit the main issue, the poster is wrongly set to the issue poster
Diffstat (limited to 'routers/web')
-rw-r--r-- | routers/web/repo/issue_content_history.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/routers/web/repo/issue_content_history.go b/routers/web/repo/issue_content_history.go index c0e958203d..dc647b8809 100644 --- a/routers/web/repo/issue_content_history.go +++ b/routers/web/repo/issue_content_history.go @@ -88,12 +88,13 @@ func canSoftDeleteContentHistory(ctx *context.Context, issue *models.Issue, comm if ctx.Repo.IsOwner() { canSoftDelete = true } else if ctx.Repo.CanWrite(models.UnitTypeIssues) { - canSoftDelete = ctx.User.ID == history.PosterID if comment == nil { - canSoftDelete = canSoftDelete && (ctx.User.ID == issue.PosterID) + // the issue poster or the history poster can soft-delete + canSoftDelete = ctx.User.ID == issue.PosterID || ctx.User.ID == history.PosterID canSoftDelete = canSoftDelete && (history.IssueID == issue.ID) } else { - canSoftDelete = canSoftDelete && (ctx.User.ID == comment.PosterID) + // the comment poster or the history poster can soft-delete + canSoftDelete = ctx.User.ID == comment.PosterID || ctx.User.ID == history.PosterID canSoftDelete = canSoftDelete && (history.IssueID == issue.ID) canSoftDelete = canSoftDelete && (history.CommentID == comment.ID) } @@ -137,7 +138,8 @@ func GetContentHistoryDetail(ctx *context.Context) { // compare the current history revision with the previous one dmp := diffmatchpatch.New() - diff := dmp.DiffMain(prevHistoryContentText, history.ContentText, true) + // `checklines=false` makes better diff result + diff := dmp.DiffMain(prevHistoryContentText, history.ContentText, false) diff = dmp.DiffCleanupEfficiency(diff) // use chroma to render the diff html |