From cddba671ccd00a4386a90d4d769ed50b9780921b Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Mon, 21 Aug 2023 06:39:58 +0000 Subject: [PATCH 1/4] improve --- templates/repo/issue/view_content.tmpl | 13 +---- .../repo/issue/view_content/comments.tmpl | 56 +++---------------- .../repo/issue/view_content/show_role.tmpl | 15 +++++ 3 files changed, 23 insertions(+), 61 deletions(-) create mode 100644 templates/repo/issue/view_content/show_role.tmpl diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index f6572d49653a4..69760ac0703db 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -44,18 +44,7 @@ {{end}}
- {{if gt .Issue.ShowRole 0}} - {{if (.Issue.ShowRole.HasRole "Writer")}} -
- {{$.locale.Tr "repo.issues.collaborator"}} -
- {{end}} - {{if (.Issue.ShowRole.HasRole "Owner")}} -
- {{$.locale.Tr "repo.issues.owner"}} -
- {{end}} - {{end}} + {{template "repo/issue/view_content/show_role" dict "ShowRole" .Issue.ShowRole "locale" $.locale "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 57756e36b99e4..b79b559db3e43 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -50,21 +50,7 @@ {{end}}
- {{if (.ShowRole.HasRole "Poster")}} -
- {{$.locale.Tr "repo.issues.poster"}} -
- {{end}} - {{if (.ShowRole.HasRole "Writer")}} -
- {{$.locale.Tr "repo.issues.collaborator"}} -
- {{end}} - {{if (.ShowRole.HasRole "Owner")}} -
- {{$.locale.Tr "repo.issues.owner"}} -
- {{end}} + {{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole "locale" $.locale}} {{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 @@
- {{if (.ShowRole.HasRole "Poster")}} -
- {{$.locale.Tr "repo.issues.poster"}} -
- {{end}} - {{if (.ShowRole.HasRole "Writer")}} -
- {{$.locale.Tr "repo.issues.collaborator"}} -
- {{end}} - {{if (.ShowRole.HasRole "Owner")}} -
- {{$.locale.Tr "repo.issues.owner"}} -
- {{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 "locale" $.locale}} + {{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}}
@@ -567,21 +539,7 @@
- {{if (.ShowRole.HasRole "Poster")}} -
- {{$.locale.Tr "repo.issues.poster"}} -
- {{end}} - {{if (.ShowRole.HasRole "Writer")}} -
- {{$.locale.Tr "repo.issues.collaborator"}} -
- {{end}} - {{if (.ShowRole.HasRole "Owner")}} -
- {{$.locale.Tr "repo.issues.owner"}} -
- {{end}} + {{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole "locale" $.locale}} {{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 0000000000000..ac24a3d33de75 --- /dev/null +++ b/templates/repo/issue/view_content/show_role.tmpl @@ -0,0 +1,15 @@ +{{if and (.ShowRole.HasRole "Poster") (not .IgnorePoster)}} +
+ {{.locale.Tr "repo.issues.poster"}} +
+{{end}} +{{if (.ShowRole.HasRole "Writer")}} +
+ {{.locale.Tr "repo.issues.collaborator"}} +
+{{end}} +{{if (.ShowRole.HasRole "Owner")}} +
+ {{.locale.Tr "repo.issues.owner"}} +
+{{end}} From e266ba27413a80a490093f20bd18bcadc421e1ed Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Mon, 21 Aug 2023 07:51:06 +0000 Subject: [PATCH 2/4] fix lint --- templates/repo/issue/view_content/show_role.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/repo/issue/view_content/show_role.tmpl b/templates/repo/issue/view_content/show_role.tmpl index ac24a3d33de75..e5fc216d15895 100644 --- a/templates/repo/issue/view_content/show_role.tmpl +++ b/templates/repo/issue/view_content/show_role.tmpl @@ -4,9 +4,9 @@
{{end}} {{if (.ShowRole.HasRole "Writer")}} -
- {{.locale.Tr "repo.issues.collaborator"}} -
+
+ {{.locale.Tr "repo.issues.collaborator"}} +
{{end}} {{if (.ShowRole.HasRole "Owner")}}
From f30e182d151821cf0ead0ab6eaf7bae3e174ca5c Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Tue, 22 Aug 2023 00:10:25 +0000 Subject: [PATCH 3/4] use ctx.Locale --- templates/repo/issue/view_content.tmpl | 2 +- templates/repo/issue/view_content/comments.tmpl | 6 +++--- templates/repo/issue/view_content/show_role.tmpl | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 69760ac0703db..78587ac7b6e2a 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -44,7 +44,7 @@ {{end}}
- {{template "repo/issue/view_content/show_role" dict "ShowRole" .Issue.ShowRole "locale" $.locale "IgnorePoster" true}} + {{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 b79b559db3e43..6f2117b0d55cc 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -50,7 +50,7 @@ {{end}}
- {{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole "locale" $.locale}} + {{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))}} @@ -428,7 +428,7 @@
- {{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole "locale" $.locale}} + {{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))}} @@ -539,7 +539,7 @@
- {{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole "locale" $.locale}} + {{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 index e5fc216d15895..07e01defb71be 100644 --- a/templates/repo/issue/view_content/show_role.tmpl +++ b/templates/repo/issue/view_content/show_role.tmpl @@ -1,15 +1,15 @@ {{if and (.ShowRole.HasRole "Poster") (not .IgnorePoster)}}
- {{.locale.Tr "repo.issues.poster"}} + {{ctx.Locale.Tr "repo.issues.poster"}}
{{end}} {{if (.ShowRole.HasRole "Writer")}}
- {{.locale.Tr "repo.issues.collaborator"}} + {{ctx.Locale.Tr "repo.issues.collaborator"}}
{{end}} {{if (.ShowRole.HasRole "Owner")}}
- {{.locale.Tr "repo.issues.owner"}} + {{ctx.Locale.Tr "repo.issues.owner"}}
{{end}} From e190e1216d4de973e55a8d3c2395078edd37e478 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Tue, 22 Aug 2023 02:54:34 +0000 Subject: [PATCH 4/4] add role-label --- templates/repo/issue/view_content/show_role.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/repo/issue/view_content/show_role.tmpl b/templates/repo/issue/view_content/show_role.tmpl index 07e01defb71be..f85f43bd66ab3 100644 --- a/templates/repo/issue/view_content/show_role.tmpl +++ b/templates/repo/issue/view_content/show_role.tmpl @@ -1,15 +1,15 @@ {{if and (.ShowRole.HasRole "Poster") (not .IgnorePoster)}} -
+
{{ctx.Locale.Tr "repo.issues.poster"}}
{{end}} {{if (.ShowRole.HasRole "Writer")}} -
+
{{ctx.Locale.Tr "repo.issues.collaborator"}}
{{end}} {{if (.ShowRole.HasRole "Owner")}} -
+
{{ctx.Locale.Tr "repo.issues.owner"}}
{{end}}