diff options
author | Gusted <williamzijl7@hotmail.com> | 2021-11-11 07:29:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-11 14:29:30 +0800 |
commit | 492e1c2fbd1b646f4428207942a9f89b56f7b6a9 (patch) | |
tree | 3de3f782cc9278f3f85f9c73eda1741390099d8c /templates/repo | |
parent | a4dc0c5a82be7fbb472ec9dba204378bfd03dc8c (diff) | |
download | gitea-492e1c2fbd1b646f4428207942a9f89b56f7b6a9.tar.gz gitea-492e1c2fbd1b646f4428207942a9f89b56f7b6a9.zip |
Refactor commentTags functionality (#17558)
* feat: Allow multiple tags on comments
- Allow for multiples tags(Currently Poster + {Owner, Writer}).
- Utilize the Poster tag within the commentTag function and remove the
checking from templates.
- Use bitwise on CommentTags to enable specific tags.
- Don't show poster tag(view_content.tmpl) on the initial issue comment.
* Change parameters naming
* Change function name
* refactor variable wording
* Merge 'master' branch into 'tags-comments' branch
* Change naming
* `tag` -> `role`
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'templates/repo')
-rw-r--r-- | templates/repo/issue/view_content.tmpl | 15 | ||||
-rw-r--r-- | templates/repo/issue/view_content/comments.tmpl | 48 |
2 files changed, 33 insertions, 30 deletions
diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 9ad6bee651..29c8626596 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -49,14 +49,17 @@ </div> <div class="comment-header-right actions df ac"> {{if not $.Repository.IsArchived}} - {{if gt .Issue.ShowTag 0}} - <div class="ui basic label"> - {{if eq .Issue.ShowTag 2}} + {{if gt .Issue.ShowRole 0}} + {{if (.Issue.ShowRole.HasRole "Writer")}} + <div class="ui basic label"> {{$.i18n.Tr "repo.issues.collaborator"}} - {{else if eq .Issue.ShowTag 3}} + </div> + {{end}} + {{if (.Issue.ShowRole.HasRole "Owner")}} + <div class="ui basic label"> {{$.i18n.Tr "repo.issues.owner"}} - {{end}} - </div> + </div> + {{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 "issue" true "diff" false "IsCommentPoster" $.IsIssuePoster}} diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 51d1e093c8..57ec007bed 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -44,18 +44,19 @@ </div> <div class="comment-header-right actions df ac"> {{if not $.Repository.IsArchived}} - {{if or (and (eq .PosterID .Issue.PosterID) (eq .Issue.OriginalAuthorID 0)) (and (eq .Issue.OriginalAuthorID .OriginalAuthorID) (not (eq .OriginalAuthorID 0))) }} + {{if (.ShowRole.HasRole "Poster")}} <div class="ui basic label"> {{$.i18n.Tr "repo.issues.poster"}} </div> {{end}} - {{if gt .ShowTag 0}} + {{if (.ShowRole.HasRole "Writer")}} <div class="ui basic label"> - {{if eq .ShowTag 2}} - {{$.i18n.Tr "repo.issues.collaborator"}} - {{else if eq .ShowTag 3}} - {{$.i18n.Tr "repo.issues.owner"}} - {{end}} + {{$.i18n.Tr "repo.issues.collaborator"}} + </div> + {{end}} + {{if (.ShowRole.HasRole "Owner")}} + <div class="ui basic label"> + {{$.i18n.Tr "repo.issues.owner"}} </div> {{end}} {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} @@ -549,24 +550,23 @@ </span> </div> <div class="comment-header-right actions df ac"> - {{if not $.Repository.IsArchived}} - {{if or (and (eq .PosterID $.Issue.PosterID) (eq $.Issue.OriginalAuthorID 0)) (eq $.Issue.OriginalAuthorID .OriginalAuthorID) }} - <div class="ui basic label"> - {{$.i18n.Tr "repo.issues.poster"}} - </div> - {{end}} - {{if gt .ShowTag 0}} - <div class="ui basic label"> - {{if eq .ShowTag 2}} - {{$.i18n.Tr "repo.issues.collaborator"}} - {{else if eq .ShowTag 3}} - {{$.i18n.Tr "repo.issues.owner"}} - {{end}} - </div> - {{end}} - {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} - {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "issue" true "diff" true "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} + {{if (.ShowRole.HasRole "Poster")}} + <div class="ui basic label"> + {{$.i18n.Tr "repo.issues.poster"}} + </div> + {{end}} + {{if (.ShowRole.HasRole "Writer")}} + <div class="ui basic label"> + {{$.i18n.Tr "repo.issues.collaborator"}} + </div> + {{end}} + {{if (.ShowRole.HasRole "Owner")}} + <div class="ui basic label"> + {{$.i18n.Tr "repo.issues.owner"}} + </div> {{end}} + {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} + {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "issue" true "diff" true "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} </div> </div> <div class="text comment-content"> |