aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2023-08-22 14:30:33 +0900
committerGitHub <noreply@github.com>2023-08-22 05:30:33 +0000
commitbd8a253220e5261d18127030ffd971305832b65c (patch)
tree53f28b870a962dd3ee4e7a1b2941cf63e6af439a
parent7934602a4ccaba7f398490ca739988a0b6f5ca2a (diff)
downloadgitea-bd8a253220e5261d18127030ffd971305832b65c.tar.gz
gitea-bd8a253220e5261d18127030ffd971305832b65c.zip
Improve show role (#26621)
Add a general show role template.
-rw-r--r--templates/repo/issue/view_content.tmpl13
-rw-r--r--templates/repo/issue/view_content/comments.tmpl56
-rw-r--r--templates/repo/issue/view_content/show_role.tmpl15
3 files changed, 23 insertions, 61 deletions
diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl
index f6572d4965..78587ac7b6 100644
--- a/templates/repo/issue/view_content.tmpl
+++ b/templates/repo/issue/view_content.tmpl
@@ -44,18 +44,7 @@
{{end}}
</div>
<div class="comment-header-right actions gt-df gt-ac">
- {{if gt .Issue.ShowRole 0}}
- {{if (.Issue.ShowRole.HasRole "Writer")}}
- <div class="ui basic label role-label">
- {{$.locale.Tr "repo.issues.collaborator"}}
- </div>
- {{end}}
- {{if (.Issue.ShowRole.HasRole "Owner")}}
- <div class="ui basic label role-label">
- {{$.locale.Tr "repo.issues.owner"}}
- </div>
- {{end}}
- {{end}}
+ {{template "repo/issue/view_content/show_role" dict "ShowRole" .Issue.ShowRole "IgnorePoster" true}}
{{if not $.Repository.IsArchived}}
{{template "repo/issue/view_content/add_reaction" dict "ctxData" $ "ActionURL" (printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index)}}
{{template "repo/issue/view_content/context_menu" dict "ctxData" $ "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 57756e36b9..6f2117b0d5 100644
--- a/templates/repo/issue/view_content/comments.tmpl
+++ b/templates/repo/issue/view_content/comments.tmpl
@@ -50,21 +50,7 @@
{{end}}
</div>
<div class="comment-header-right actions gt-df gt-ac">
- {{if (.ShowRole.HasRole "Poster")}}
- <div class="ui basic label">
- {{$.locale.Tr "repo.issues.poster"}}
- </div>
- {{end}}
- {{if (.ShowRole.HasRole "Writer")}}
- <div class="ui basic label">
- {{$.locale.Tr "repo.issues.collaborator"}}
- </div>
- {{end}}
- {{if (.ShowRole.HasRole "Owner")}}
- <div class="ui basic label">
- {{$.locale.Tr "repo.issues.owner"}}
- </div>
- {{end}}
+ {{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole}}
{{if not $.Repository.IsArchived}}
{{template "repo/issue/view_content/add_reaction" dict "ctxData" $ "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID)}}
{{template "repo/issue/view_content/context_menu" dict "ctxData" $ "item" . "delete" true "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}}
@@ -442,25 +428,11 @@
</span>
</div>
<div class="comment-header-right actions gt-df gt-ac">
- {{if (.ShowRole.HasRole "Poster")}}
- <div class="ui basic label">
- {{$.locale.Tr "repo.issues.poster"}}
- </div>
- {{end}}
- {{if (.ShowRole.HasRole "Writer")}}
- <div class="ui basic label">
- {{$.locale.Tr "repo.issues.collaborator"}}
- </div>
- {{end}}
- {{if (.ShowRole.HasRole "Owner")}}
- <div class="ui basic label">
- {{$.locale.Tr "repo.issues.owner"}}
- </div>
- {{end}}
- {{if not $.Repository.IsArchived}}
- {{template "repo/issue/view_content/add_reaction" dict "ctxData" $ "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID)}}
- {{template "repo/issue/view_content/context_menu" dict "ctxData" $ "item" . "delete" false "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}}
- {{end}}
+ {{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole}}
+ {{if not $.Repository.IsArchived}}
+ {{template "repo/issue/view_content/add_reaction" dict "ctxData" $ "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID)}}
+ {{template "repo/issue/view_content/context_menu" dict "ctxData" $ "item" . "delete" false "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}}
+ {{end}}
</div>
</div>
<div class="ui attached segment comment-body">
@@ -567,21 +539,7 @@
</span>
</div>
<div class="comment-header-right actions gt-df gt-ac">
- {{if (.ShowRole.HasRole "Poster")}}
- <div class="ui basic label">
- {{$.locale.Tr "repo.issues.poster"}}
- </div>
- {{end}}
- {{if (.ShowRole.HasRole "Writer")}}
- <div class="ui basic label">
- {{$.locale.Tr "repo.issues.collaborator"}}
- </div>
- {{end}}
- {{if (.ShowRole.HasRole "Owner")}}
- <div class="ui basic label">
- {{$.locale.Tr "repo.issues.owner"}}
- </div>
- {{end}}
+ {{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole}}
{{if not $.Repository.IsArchived}}
{{template "repo/issue/view_content/add_reaction" dict "ctxData" $ "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID)}}
{{template "repo/issue/view_content/context_menu" dict "ctxData" $ "item" . "delete" true "issue" true "diff" true "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}}
diff --git a/templates/repo/issue/view_content/show_role.tmpl b/templates/repo/issue/view_content/show_role.tmpl
new file mode 100644
index 0000000000..f85f43bd66
--- /dev/null
+++ b/templates/repo/issue/view_content/show_role.tmpl
@@ -0,0 +1,15 @@
+{{if and (.ShowRole.HasRole "Poster") (not .IgnorePoster)}}
+ <div class="ui basic label role-label">
+ {{ctx.Locale.Tr "repo.issues.poster"}}
+ </div>
+{{end}}
+{{if (.ShowRole.HasRole "Writer")}}
+ <div class="ui basic label role-label">
+ {{ctx.Locale.Tr "repo.issues.collaborator"}}
+ </div>
+{{end}}
+{{if (.ShowRole.HasRole "Owner")}}
+ <div class="ui basic label role-label">
+ {{ctx.Locale.Tr "repo.issues.owner"}}
+ </div>
+{{end}}