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 <lauris@nix.lv> * fix lint * revert CommentTagPoster Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
5b10da241b
commit
4f8dad37f8
4 changed files with 24 additions and 5 deletions
|
@ -67,6 +67,9 @@ type Issue struct {
|
||||||
// IsLocked limits commenting abilities to users on an issue
|
// IsLocked limits commenting abilities to users on an issue
|
||||||
// with write access
|
// with write access
|
||||||
IsLocked bool `xorm:"NOT NULL DEFAULT false"`
|
IsLocked bool `xorm:"NOT NULL DEFAULT false"`
|
||||||
|
|
||||||
|
// For view issue page.
|
||||||
|
ShowTag CommentTag `xorm:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -744,8 +744,6 @@ func commentTag(repo *models.Repository, poster *models.User, issue *models.Issu
|
||||||
}
|
}
|
||||||
if perm.IsOwner() {
|
if perm.IsOwner() {
|
||||||
return models.CommentTagOwner, nil
|
return models.CommentTagOwner, nil
|
||||||
} else if poster.ID == issue.PosterID {
|
|
||||||
return models.CommentTagPoster, nil
|
|
||||||
} else if perm.CanWrite(models.UnitTypeCode) {
|
} else if perm.CanWrite(models.UnitTypeCode) {
|
||||||
return models.CommentTagWriter, nil
|
return models.CommentTagWriter, nil
|
||||||
}
|
}
|
||||||
|
@ -999,6 +997,12 @@ func ViewIssue(ctx *context.Context) {
|
||||||
// check if dependencies can be created across repositories
|
// check if dependencies can be created across repositories
|
||||||
ctx.Data["AllowCrossRepositoryDependencies"] = setting.Service.AllowCrossRepositoryDependencies
|
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.
|
// Render comments and and fetch participants.
|
||||||
participants[0] = issue.Poster
|
participants[0] = issue.Poster
|
||||||
for _, comment = range issue.Comments {
|
for _, comment = range issue.Comments {
|
||||||
|
|
|
@ -40,6 +40,15 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if not $.Repository.IsArchived}}
|
{{if not $.Repository.IsArchived}}
|
||||||
<div class="ui right actions">
|
<div class="ui right actions">
|
||||||
|
{{if gt .Issue.ShowTag 0}}
|
||||||
|
<div class="item tag">
|
||||||
|
{{if eq .Issue.ShowTag 2}}
|
||||||
|
{{$.i18n.Tr "repo.issues.collaborator"}}
|
||||||
|
{{else if eq .Issue.ShowTag 3}}
|
||||||
|
{{$.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/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}}
|
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" .Issue "delete" false "diff" false "IsCommentPoster" $.IsIssuePoster}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -27,11 +27,14 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if not $.Repository.IsArchived}}
|
{{if not $.Repository.IsArchived}}
|
||||||
<div class="ui right actions">
|
<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}}
|
{{if gt .ShowTag 0}}
|
||||||
<div class="item tag">
|
<div class="item tag">
|
||||||
{{if eq .ShowTag 1}}
|
{{if eq .ShowTag 2}}
|
||||||
{{$.i18n.Tr "repo.issues.poster"}}
|
|
||||||
{{else if eq .ShowTag 2}}
|
|
||||||
{{$.i18n.Tr "repo.issues.collaborator"}}
|
{{$.i18n.Tr "repo.issues.collaborator"}}
|
||||||
{{else if eq .ShowTag 3}}
|
{{else if eq .ShowTag 3}}
|
||||||
{{$.i18n.Tr "repo.issues.owner"}}
|
{{$.i18n.Tr "repo.issues.owner"}}
|
||||||
|
|
Reference in a new issue