Skip to content

Commit 4f8dad3

Browse files
a1012112796lafrikstechknowlogick
authored
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 <[email protected]> * Update routers/repo/issue.go Co-authored-by: Lauris BH <[email protected]> * fix lint * revert CommentTagPoster Co-authored-by: Lauris BH <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 5b10da2 commit 4f8dad3

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

models/issue.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ type Issue struct {
6767
// IsLocked limits commenting abilities to users on an issue
6868
// with write access
6969
IsLocked bool `xorm:"NOT NULL DEFAULT false"`
70+
71+
// For view issue page.
72+
ShowTag CommentTag `xorm:"-"`
7073
}
7174

7275
var (

routers/repo/issue.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,6 @@ func commentTag(repo *models.Repository, poster *models.User, issue *models.Issu
744744
}
745745
if perm.IsOwner() {
746746
return models.CommentTagOwner, nil
747-
} else if poster.ID == issue.PosterID {
748-
return models.CommentTagPoster, nil
749747
} else if perm.CanWrite(models.UnitTypeCode) {
750748
return models.CommentTagWriter, nil
751749
}
@@ -999,6 +997,12 @@ func ViewIssue(ctx *context.Context) {
999997
// check if dependencies can be created across repositories
1000998
ctx.Data["AllowCrossRepositoryDependencies"] = setting.Service.AllowCrossRepositoryDependencies
1001999

1000+
if issue.ShowTag, err = commentTag(repo, issue.Poster, issue); err != nil {
1001+
ctx.ServerError("commentTag", err)
1002+
return
1003+
}
1004+
marked[issue.PosterID] = issue.ShowTag
1005+
10021006
// Render comments and and fetch participants.
10031007
participants[0] = issue.Poster
10041008
for _, comment = range issue.Comments {

templates/repo/issue/view_content.tmpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@
4040
{{end}}
4141
{{if not $.Repository.IsArchived}}
4242
<div class="ui right actions">
43+
{{if gt .Issue.ShowTag 0}}
44+
<div class="item tag">
45+
{{if eq .Issue.ShowTag 2}}
46+
{{$.i18n.Tr "repo.issues.collaborator"}}
47+
{{else if eq .Issue.ShowTag 3}}
48+
{{$.i18n.Tr "repo.issues.owner"}}
49+
{{end}}
50+
</div>
51+
{{end}}
4352
{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index)}}
4453
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" .Issue "delete" false "diff" false "IsCommentPoster" $.IsIssuePoster}}
4554
</div>

templates/repo/issue/view_content/comments.tmpl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@
2727
{{end}}
2828
{{if not $.Repository.IsArchived}}
2929
<div class="ui right actions">
30+
{{if eq .PosterID .Issue.PosterID }}
31+
<div class="item tag">
32+
{{$.i18n.Tr "repo.issues.poster"}}
33+
</div>
34+
{{end}}
3035
{{if gt .ShowTag 0}}
3136
<div class="item tag">
32-
{{if eq .ShowTag 1}}
33-
{{$.i18n.Tr "repo.issues.poster"}}
34-
{{else if eq .ShowTag 2}}
37+
{{if eq .ShowTag 2}}
3538
{{$.i18n.Tr "repo.issues.collaborator"}}
3639
{{else if eq .ShowTag 3}}
3740
{{$.i18n.Tr "repo.issues.owner"}}

0 commit comments

Comments
 (0)