From 4f8dad37f834833012004bf5b158e5129af4b610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=99=BA=E8=B6=85?= <1012112796@qq.com> Date: Fri, 11 Sep 2020 02:09:14 +0800 Subject: [PATCH] ui: change commentTag style (#11668) * ui: change commentTag style * Add comment tag in first comment (issue content) * Show CommentTagPoster in other way Signed-off-by: a1012112796 <1012112796@qq.com> * Update routers/repo/issue.go Co-authored-by: Lauris BH * fix lint * revert CommentTagPoster Co-authored-by: Lauris BH Co-authored-by: techknowlogick --- models/issue.go | 3 +++ routers/repo/issue.go | 8 ++++++-- templates/repo/issue/view_content.tmpl | 9 +++++++++ templates/repo/issue/view_content/comments.tmpl | 9 ++++++--- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/models/issue.go b/models/issue.go index 228316fc3c3..ede3180954f 100644 --- a/models/issue.go +++ b/models/issue.go @@ -67,6 +67,9 @@ type Issue struct { // IsLocked limits commenting abilities to users on an issue // with write access IsLocked bool `xorm:"NOT NULL DEFAULT false"` + + // For view issue page. + ShowTag CommentTag `xorm:"-"` } var ( diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 4fc83719fd0..71c0488972c 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -744,8 +744,6 @@ func commentTag(repo *models.Repository, poster *models.User, issue *models.Issu } if perm.IsOwner() { return models.CommentTagOwner, nil - } else if poster.ID == issue.PosterID { - return models.CommentTagPoster, nil } else if perm.CanWrite(models.UnitTypeCode) { return models.CommentTagWriter, nil } @@ -999,6 +997,12 @@ func ViewIssue(ctx *context.Context) { // check if dependencies can be created across repositories ctx.Data["AllowCrossRepositoryDependencies"] = setting.Service.AllowCrossRepositoryDependencies + if issue.ShowTag, err = commentTag(repo, issue.Poster, issue); err != nil { + ctx.ServerError("commentTag", err) + return + } + marked[issue.PosterID] = issue.ShowTag + // Render comments and and fetch participants. participants[0] = issue.Poster for _, comment = range issue.Comments { diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index a61832dd3c6..1addbaf5bb0 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -40,6 +40,15 @@ {{end}} {{if not $.Repository.IsArchived}}
+ {{if gt .Issue.ShowTag 0}} +
+ {{if eq .Issue.ShowTag 2}} + {{$.i18n.Tr "repo.issues.collaborator"}} + {{else if eq .Issue.ShowTag 3}} + {{$.i18n.Tr "repo.issues.owner"}} + {{end}} +
+ {{end}} {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index)}} {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" .Issue "delete" false "diff" false "IsCommentPoster" $.IsIssuePoster}}
diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index c222e6cec24..686d88e17fb 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -27,11 +27,14 @@ {{end}} {{if not $.Repository.IsArchived}}
+ {{if eq .PosterID .Issue.PosterID }} +
+ {{$.i18n.Tr "repo.issues.poster"}} +
+ {{end}} {{if gt .ShowTag 0}}
- {{if eq .ShowTag 1}} - {{$.i18n.Tr "repo.issues.poster"}} - {{else if eq .ShowTag 2}} + {{if eq .ShowTag 2}} {{$.i18n.Tr "repo.issues.collaborator"}} {{else if eq .ShowTag 3}} {{$.i18n.Tr "repo.issues.owner"}}