Skip to content
3 changes: 3 additions & 0 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,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 (
Expand Down
1 change: 0 additions & 1 deletion models/issue_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ type CommentTag int
// Enumerate all the comment tag types
const (
CommentTagNone CommentTag = iota
CommentTagPoster
Comment thread
a1012112796 marked this conversation as resolved.
CommentTagWriter
CommentTagOwner
)
Expand Down
8 changes: 6 additions & 2 deletions routers/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,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
}
Expand Down Expand Up @@ -909,6 +907,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 {
Expand Down
9 changes: 9 additions & 0 deletions templates/repo/issue/view_content.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@
{{end}}
{{if not $.Repository.IsArchived}}
<div class="ui right actions">
{{if gt .Issue.ShowTag 0}}
<div class="item tag">
{{if eq .Issue.ShowTag 1}}
{{$.i18n.Tr "repo.issues.collaborator"}}
{{else if eq .Issue.ShowTag 2}}
{{$.i18n.Tr "repo.issues.owner"}}
{{end}}
</div>
{{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 }}
</div>
Expand Down
9 changes: 6 additions & 3 deletions templates/repo/issue/view_content/comments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@
{{end}}
{{if not $.Repository.IsArchived}}
<div class="ui right actions">
{{if eq .PosterID .Issue.PosterID }}
<div class="item tag">
{{$.i18n.Tr "repo.issues.poster"}}
</div>
{{end}}
{{if gt .ShowTag 0}}
<div class="item tag">
{{if eq .ShowTag 1}}
{{$.i18n.Tr "repo.issues.poster"}}
{{else if eq .ShowTag 2}}
{{$.i18n.Tr "repo.issues.collaborator"}}
{{else if eq .ShowTag 3}}
{{else if eq .ShowTag 2}}
{{$.i18n.Tr "repo.issues.owner"}}
{{end}}
</div>
Expand Down