Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue content history problems, improve UI #17404

Merged
merged 9 commits into from
Oct 23, 2021
4 changes: 2 additions & 2 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ func (issue *Issue) ChangeContent(doer *User, content string) (err error) {
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)
}
Expand Down Expand Up @@ -979,7 +979,7 @@ func newIssue(e db.Engine, doer *User, opts NewIssueOptions) (err error) {
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
}
Expand Down
7 changes: 4 additions & 3 deletions routers/web/repo/issue_content_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/features/issue-content-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function showContentHistoryDetail(issueBaseUrl, commentId, historyId, itemTitleH
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}
Expand All @@ -24,7 +24,7 @@ function showContentHistoryDetail(issueBaseUrl, commentId, historyId, itemTitleH
</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>`);
Expand Down