* 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
return fmt.Errorf("UpdateIssueCols: %v", err)
}
- if err = issues.SaveIssueContentHistory(db.GetEngine(ctx), issue.PosterID, issue.ID, 0,
+ if err = issues.SaveIssueContentHistory(db.GetEngine(ctx), doer.ID, issue.ID, 0,
timeutil.TimeStampNow(), issue.Content, false); err != nil {
return fmt.Errorf("SaveIssueContentHistory: %v", err)
}
return err
}
- if err = issues.SaveIssueContentHistory(e, opts.Issue.PosterID, opts.Issue.ID, 0,
+ if err = issues.SaveIssueContentHistory(e, doer.ID, opts.Issue.ID, 0,
timeutil.TimeStampNow(), opts.Issue.Content, true); err != nil {
return err
}
issue := Issue{
RepoID: repo.ID,
PosterID: user.ID,
+ Poster: user,
Title: title,
Content: content,
}
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)
}
// 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
if ($dialog.length) return;
$dialog = $(`
-<div class="ui modal content-history-detail-dialog" style="min-height: 50%;">
+<div class="ui modal content-history-detail-dialog">
<i class="close icon inside"></i>
<div class="header">
${itemTitleHtml}
</div>
</div>
<!-- ".modal .content" style was polluted in "_base.less": "&.modal > .content" -->
- <div class="scrolling content" style="text-align: left;">
+ <div class="scrolling content" style="text-align: left; min-height: 30vh;">
<div class="ui loader active"></div>
</div>
</div>`);