From 7441ac33b9d20fdf67203bcf5354a64814ed50c7 Mon Sep 17 00:00:00 2001 From: Ellen Emilia Anna Zscheile Date: Sun, 2 Mar 2025 00:55:36 +0100 Subject: [PATCH] feat(repo,locale): merge PR/issues cases for some repo/issue strings - `nocomment` (originally propsed in https://codeberg.org/forgejo/forgejo/pulls/6439#issue-941717 by @0ko) - `comment.blocked_by_user` Fixes #6443 Signed-off-by: Ellen Emilia Anna Zscheile --- options/locale/locale_en-US.ini | 6 ++---- routers/web/repo/issue.go | 6 +----- templates/repo/issue/view_content.tmpl | 18 +++--------------- tests/integration/block_test.go | 2 +- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 2a8c789385..24679c8266 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1217,8 +1217,7 @@ template.invalid = Must select a template repository archive.title = This repository is archived. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments. archive.title_date = This repository has been archived on %s. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments. -archive.issue.nocomment = This repository is archived. You cannot comment on issues. -archive.pull.nocomment = This repository is archived. You cannot comment on pull requests. +archive.nocomment = Commenting is not possible because the repository is archived. archive.pull.noreview = This repository is archived. You cannot review pull requests. form.reach_limit_of_creation_1 = The owner has already reached the limit of %d repository. @@ -1881,7 +1880,7 @@ issues.content_history.delete_from_history_confirm = Delete from history? issues.content_history.options = Options issues.reference_link = Reference: %s issues.blocked_by_user = You cannot create issues in this repository because you are blocked by the repository owner. -issues.comment.blocked_by_user = You cannot comment on this issue because you are blocked by the repository owner or the poster of the issue. +comment.blocked_by_user = Commenting is not possible because you are blocked by the repository owner or the author. issues.reopen.blocked_by_user = You cannot reopen this issue because you are blocked by the repository owner or the poster of this issue. issues.summary_card_alt = Summary card of an issue titled "%s" in repository %s @@ -1966,7 +1965,6 @@ pulls.waiting_count_1 = %d waiting review pulls.waiting_count_n = %d waiting reviews pulls.wrong_commit_id = commit id must be a commit id on the target branch pulls.blocked_by_user = You cannot create a pull request on this repository because you are blocked by the repository owner. -pulls.comment.blocked_by_user = You cannot comment on this pull request because you are blocked by the repository owner or the poster of the pull request. pulls.no_merge_desc = This pull request cannot be merged because all repository merge options are disabled. pulls.no_merge_helper = Enable merge options in the repository settings or merge the pull request manually. diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index ff3a903aed..8efcce9ab1 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -3253,11 +3253,7 @@ func NewComment(ctx *context.Context) { comment, err := issue_service.CreateIssueComment(ctx, ctx.Doer, ctx.Repo.Repository, issue, form.Content, attachments) if err != nil { if errors.Is(err, user_model.ErrBlockedByUser) { - if issue.IsPull { - ctx.JSONError(ctx.Tr("repo.pulls.comment.blocked_by_user")) - } else { - ctx.JSONError(ctx.Tr("repo.issues.comment.blocked_by_user")) - } + ctx.JSONError(ctx.Tr("repo.comment.blocked_by_user")) } else { ctx.ServerError("CreateIssueComment", err) } diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 8ede0f36e5..268c77d880 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -116,29 +116,17 @@ {{else if .Repository.IsArchived}}
- {{if .Issue.IsPull}} - {{ctx.Locale.Tr "repo.archive.pull.nocomment"}} - {{else}} - {{ctx.Locale.Tr "repo.archive.issue.nocomment"}} - {{end}} + {{ctx.Locale.Tr "repo.archive.nocomment"}}
{{end}} {{else if .IsBlocked}}
- {{if .Issue.IsPull}} - {{ctx.Locale.Tr "repo.pulls.comment.blocked_by_user"}} - {{else}} - {{ctx.Locale.Tr "repo.issues.comment.blocked_by_user"}} - {{end}} + {{ctx.Locale.Tr "repo.comment.blocked_by_user"}}
{{else}} {{/* not .IsSigned */}} {{if .Repository.IsArchived}}
- {{if .Issue.IsPull}} - {{ctx.Locale.Tr "repo.archive.pull.nocomment"}} - {{else}} - {{ctx.Locale.Tr "repo.archive.issue.nocomment"}} - {{end}} + {{ctx.Locale.Tr "repo.archive.nocomment"}}
{{else}}
diff --git a/tests/integration/block_test.go b/tests/integration/block_test.go index d249737555..b1c2c422e7 100644 --- a/tests/integration/block_test.go +++ b/tests/integration/block_test.go @@ -236,7 +236,7 @@ func TestBlockActions(t *testing.T) { // Ensures that comment creation on doer's owned repositories and doer's // posted issues are blocked. t.Run("Comment creation", func(t *testing.T) { - expectedMessage := locale.Tr("repo.issues.comment.blocked_by_user") + expectedMessage := locale.Tr("repo.comment.blocked_by_user") t.Run("Blocked by repository owner", func(t *testing.T) { defer tests.PrintCurrentTest(t)()