From 0600a1483791287115ce6b9efc4efcb3138ab4df Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 22 Oct 2021 12:12:23 +0800 Subject: [PATCH 1/6] improve dialog height, fix issue content history poster --- models/issue.go | 4 ++-- routers/web/repo/issue_content_history.go | 7 ++++--- web_src/js/features/issue-content-history.js | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/models/issue.go b/models/issue.go index 823d82a765a79..a27bb1cc7dec9 100644 --- a/models/issue.go +++ b/models/issue.go @@ -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) } @@ -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 } diff --git a/routers/web/repo/issue_content_history.go b/routers/web/repo/issue_content_history.go index c0e958203d569..c5ba74070e257 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) } diff --git a/web_src/js/features/issue-content-history.js b/web_src/js/features/issue-content-history.js index 3b830f50f8661..c71d3789d4bf9 100644 --- a/web_src/js/features/issue-content-history.js +++ b/web_src/js/features/issue-content-history.js @@ -12,7 +12,7 @@ function showContentHistoryDetail(issueBaseUrl, commentId, historyId, itemTitleH if ($dialog.length) return; $dialog = $(` -