From e8fe1217c694cba1b08d7dd5f44a8a8380ef63d8 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Sat, 22 May 2021 22:11:39 +0800 Subject: [PATCH] Add TrN for repository limit (part 2) follow #12492, do same thing on repo migrate page - readd ``form.reach_limit_of_creation`` because it's still be used - part of #15924 also Signed-off-by: a1012112796 <1012112796@qq.com> --- options/locale/locale_en-US.ini | 1 + routers/repo/migrate.go | 11 +++++++++++ templates/repo/migrate/git.tmpl | 17 ++++++++++++----- templates/repo/migrate/gitea.tmpl | 17 ++++++++++++----- templates/repo/migrate/github.tmpl | 17 ++++++++++++----- templates/repo/migrate/gitlab.tmpl | 17 ++++++++++++----- templates/repo/migrate/gogs.tmpl | 17 ++++++++++++----- 7 files changed, 72 insertions(+), 25 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index ab7367ba7ad3f..e485f60dbd117 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -779,6 +779,7 @@ archive.title = This repo is archived. You can view files and clone it, but cann archive.issue.nocomment = This repo is archived. You cannot comment on issues. archive.pull.nocomment = This repo is archived. You cannot comment on pull requests. +form.reach_limit_of_creation = You have already reached your limit of %d repositories. form.reach_limit_of_creation_1 = You have already reached your limit of %d repository. form.reach_limit_of_creation_n = You have already reached your limit of %d repositories. form.name_reserved = The repository name '%s' is reserved. diff --git a/routers/repo/migrate.go b/routers/repo/migrate.go index 24d4ef4099bd9..e6da984495a5a 100644 --- a/routers/repo/migrate.go +++ b/routers/repo/migrate.go @@ -60,6 +60,17 @@ func Migrate(ctx *context.Context) { if ctx.Written() { return } + + canCreateRepo := ctx.User.CanCreateRepo() + if !canCreateRepo && ctx.User.ID == ctxUser.ID { + orgs, has := ctx.Data["Orgs"].([]*models.User) + if has && len(orgs) > 0 { + ctxUser = orgs[0] + } + } + + ctx.Data["CanCreateRepo"] = canCreateRepo + ctx.Data["MaxCreationLimit"] = ctx.User.MaxCreationLimit() ctx.Data["ContextUser"] = ctxUser ctx.HTML(http.StatusOK, base.TplName("repo/migrate/"+serviceType.Name())) diff --git a/templates/repo/migrate/git.tmpl b/templates/repo/migrate/git.tmpl index 6525a9b4f50c9..72b7f428b74ee 100644 --- a/templates/repo/migrate/git.tmpl +++ b/templates/repo/migrate/git.tmpl @@ -10,6 +10,11 @@
{{template "base/alert" .}} + {{if not .CanCreateRepo}} +
+

{{.i18n.Tr (TrN .i18n.Lang .MaxCreationLimit "repo.form.reach_limit_of_creation_1" "repo.form.reach_limit_of_creation_n") .MaxCreationLimit}}

+
+ {{end}}
@@ -41,10 +46,12 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}}