Skip to content

Commit af70545

Browse files
evur6543
andauthored
Add TrN for repository limit (#12492)
* Added TrN for repository limit * Removed form.reach_limit_of_creation_0 * disable Create Button if user can not create Co-authored-by: 6543 <[email protected]>
1 parent aa4c33b commit af70545

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

options/locale/locale_en-US.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,8 @@ archive.title = This repo is archived. You can view files and clone it, but cann
741741
archive.issue.nocomment = This repo is archived. You cannot comment on issues.
742742
archive.pull.nocomment = This repo is archived. You cannot comment on pull requests.
743743

744-
form.reach_limit_of_creation = You have already reached your limit of %d repositories.
744+
form.reach_limit_of_creation_1 = You have already reached your limit of %d repository.
745+
form.reach_limit_of_creation_n = You have already reached your limit of %d repositories.
745746
form.name_reserved = The repository name '%s' is reserved.
746747
form.name_pattern_not_allowed = The pattern '%s' is not allowed in a repository name.
747748

routers/repo/repo.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,10 @@ func Create(ctx *context.Context) {
144144
}
145145
}
146146

147-
if !ctx.User.CanCreateRepo() {
148-
ctx.RenderWithErr(ctx.Tr("repo.form.reach_limit_of_creation", ctx.User.MaxCreationLimit()), tplCreate, nil)
149-
} else {
150-
ctx.HTML(200, tplCreate)
151-
}
147+
ctx.Data["CanCreateRepo"] = ctx.User.CanCreateRepo()
148+
ctx.Data["MaxCreationLimit"] = ctx.User.MaxCreationLimit()
149+
150+
ctx.HTML(200, tplCreate)
152151
}
153152

154153
func handleCreateError(ctx *context.Context, owner *models.User, err error, name string, tpl base.TplName, form interface{}) {

templates/repo/create.tmpl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
</h3>
1010
<div class="ui attached segment">
1111
{{template "base/alert" .}}
12+
{{if not .CanCreateRepo}}
13+
<div class="ui negative message">
14+
<p>{{.i18n.Tr (TrN .i18n.Lang .MaxCreationLimit "repo.form.reach_limit_of_creation_1" "repo.form.reach_limit_of_creation_n") .MaxCreationLimit}}</p>
15+
</div>
16+
{{end}}
1217
<div class="inline required field {{if .Err_Owner}}error{{end}}">
1318
<label>{{.i18n.Tr "repo.owner"}}</label>
1419
<div class="ui selection owner dropdown">
@@ -193,7 +198,7 @@
193198
<br/>
194199
<div class="inline field">
195200
<label></label>
196-
<button class="ui green button">
201+
<button class="ui green button{{if not .CanCreateRepo}} disabled{{end}}">
197202
{{.i18n.Tr "repo.create_repo"}}
198203
</button>
199204
<a class="ui button" href="{{AppSubUrl}}/">{{.i18n.Tr "cancel"}}</a>

0 commit comments

Comments
 (0)