Skip to content

WIP: Add TrN for repository limit (part 2) #15949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions routers/repo/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
17 changes: 12 additions & 5 deletions templates/repo/migrate/git.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
</h3>
<div class="ui attached segment">
{{template "base/alert" .}}
{{if not .CanCreateRepo}}
<div class="ui negative message">
<p>{{.i18n.Tr (TrN .i18n.Lang .MaxCreationLimit "repo.form.reach_limit_of_creation_1" "repo.form.reach_limit_of_creation_n") .MaxCreationLimit}}</p>
</div>
{{end}}
<div class="inline required field {{if .Err_CloneAddr}}error{{end}}">
<label for="clone_addr">{{.i18n.Tr "repo.migrate.clone_address"}}</label>
<input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required>
Expand Down Expand Up @@ -41,10 +46,12 @@
</span>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="menu" title="{{.SignedUser.Name}}">
<div class="item truncated-item-container" data-value="{{.SignedUser.ID}}">
{{avatar .SignedUser}}
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
</div>
{{if .CanCreateRepo}}
<div class="item truncated-item-container" data-value="{{.SignedUser.ID}}">
{{avatar .SignedUser}}
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
</div>
{{end}}
{{range .Orgs}}
<div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}">
{{avatar .}}
Expand Down Expand Up @@ -78,7 +85,7 @@

<div class="inline field">
<label></label>
<button class="ui green button">
<button class="ui green button {{if and (not .CanCreateRepo) (not .Orgs)}} disabled{{end}}">
{{.i18n.Tr "repo.migrate_repo"}}
</button>
<a class="ui button" href="{{AppSubUrl}}/">{{.i18n.Tr "cancel"}}</a>
Expand Down
17 changes: 12 additions & 5 deletions templates/repo/migrate/gitea.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
</h3>
<div class="ui attached segment">
{{template "base/alert" .}}
{{if not .CanCreateRepo}}
<div class="ui negative message">
<p>{{.i18n.Tr (TrN .i18n.Lang .MaxCreationLimit "repo.form.reach_limit_of_creation_1" "repo.form.reach_limit_of_creation_n") .MaxCreationLimit}}</p>
</div>
{{end}}
<div class="inline required field {{if .Err_CloneAddr}}error{{end}}">
<label for="clone_addr">{{.i18n.Tr "repo.migrate.clone_address"}}</label>
<input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required>
Expand Down Expand Up @@ -75,10 +80,12 @@
</span>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="menu" title="{{.SignedUser.Name}}">
<div class="item truncated-item-container" data-value="{{.SignedUser.ID}}">
{{avatar .SignedUser}}
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
</div>
{{if .CanCreateRepo}}
<div class="item truncated-item-container" data-value="{{.SignedUser.ID}}">
{{avatar .SignedUser}}
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
</div>
{{end}}
{{range .Orgs}}
<div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}">
{{avatar .}}
Expand Down Expand Up @@ -112,7 +119,7 @@

<div class="inline field">
<label></label>
<button class="ui green button">
<button class="ui green button {{if and (not .CanCreateRepo) (not .Orgs)}} disabled{{end}}">
{{.i18n.Tr "repo.migrate_repo"}}
</button>
<a class="ui button" href="{{AppSubUrl}}/">{{.i18n.Tr "cancel"}}</a>
Expand Down
17 changes: 12 additions & 5 deletions templates/repo/migrate/github.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
</h3>
<div class="ui attached segment">
{{template "base/alert" .}}
{{if not .CanCreateRepo}}
<div class="ui negative message">
<p>{{.i18n.Tr (TrN .i18n.Lang .MaxCreationLimit "repo.form.reach_limit_of_creation_1" "repo.form.reach_limit_of_creation_n") .MaxCreationLimit}}</p>
</div>
{{end}}
<div class="inline required field {{if .Err_CloneAddr}}error{{end}}">
<label for="clone_addr">{{.i18n.Tr "repo.migrate.clone_address"}}</label>
<input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required>
Expand Down Expand Up @@ -75,10 +80,12 @@
</span>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="menu" title="{{.SignedUser.Name}}">
<div class="item truncated-item-container" data-value="{{.SignedUser.ID}}">
{{avatar .SignedUser 28 "mini"}}
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
</div>
{{if .CanCreateRepo}}
<div class="item truncated-item-container" data-value="{{.SignedUser.ID}}">
{{avatar .SignedUser 28 "mini"}}
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
</div>
{{end}}
{{range .Orgs}}
<div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}">
{{avatar . 28 "mini"}}
Expand Down Expand Up @@ -112,7 +119,7 @@

<div class="inline field">
<label></label>
<button class="ui green button">
<button class="ui green button {{if and (not .CanCreateRepo) (not .Orgs)}} disabled{{end}}">
{{.i18n.Tr "repo.migrate_repo"}}
</button>
<a class="ui button" href="{{AppSubUrl}}/">{{.i18n.Tr "cancel"}}</a>
Expand Down
17 changes: 12 additions & 5 deletions templates/repo/migrate/gitlab.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
</h3>
<div class="ui attached segment">
{{template "base/alert" .}}
{{if not .CanCreateRepo}}
<div class="ui negative message">
<p>{{.i18n.Tr (TrN .i18n.Lang .MaxCreationLimit "repo.form.reach_limit_of_creation_1" "repo.form.reach_limit_of_creation_n") .MaxCreationLimit}}</p>
</div>
{{end}}
<div class="inline required field {{if .Err_CloneAddr}}error{{end}}">
<label for="clone_addr">{{.i18n.Tr "repo.migrate.clone_address"}}</label>
<input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required>
Expand Down Expand Up @@ -75,10 +80,12 @@
</span>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="menu" title="{{.SignedUser.Name}}">
<div class="item truncated-item-container" data-value="{{.SignedUser.ID}}">
{{avatar .SignedUser 28 "mini"}}
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
</div>
{{if .CanCreateRepo}}
<div class="item truncated-item-container" data-value="{{.SignedUser.ID}}">
{{avatar .SignedUser 28 "mini"}}
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
</div>
{{end}}
{{range .Orgs}}
<div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}">
{{avatar . 28 "mini"}}
Expand Down Expand Up @@ -112,7 +119,7 @@

<div class="inline field">
<label></label>
<button class="ui green button">
<button class="ui green button {{if and (not .CanCreateRepo) (not .Orgs)}} disabled{{end}}">
{{.i18n.Tr "repo.migrate_repo"}}
</button>
<a class="ui button" href="{{AppSubUrl}}/">{{.i18n.Tr "cancel"}}</a>
Expand Down
17 changes: 12 additions & 5 deletions templates/repo/migrate/gogs.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
</h3>
<div class="ui attached segment">
{{template "base/alert" .}}
{{if not .CanCreateRepo}}
<div class="ui negative message">
<p>{{.i18n.Tr (TrN .i18n.Lang .MaxCreationLimit "repo.form.reach_limit_of_creation_1" "repo.form.reach_limit_of_creation_n") .MaxCreationLimit}}</p>
</div>
{{end}}
<div class="inline required field {{if .Err_CloneAddr}}error{{end}}">
<label for="clone_addr">{{.i18n.Tr "repo.migrate.clone_address"}}</label>
<input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required>
Expand Down Expand Up @@ -77,10 +82,12 @@
</span>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="menu" title="{{.SignedUser.Name}}">
<div class="item truncated-item-container" data-value="{{.SignedUser.ID}}">
{{avatar .SignedUser}}
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
</div>
{{if .CanCreateRepo}}
<div class="item truncated-item-container" data-value="{{.SignedUser.ID}}">
{{avatar .SignedUser}}
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
</div>
{{end}}
{{range .Orgs}}
<div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}">
{{avatar .}}
Expand Down Expand Up @@ -114,7 +121,7 @@

<div class="inline field">
<label></label>
<button class="ui green button">
<button class="ui green button {{if and (not .CanCreateRepo) (not .Orgs)}} disabled{{end}}">
{{.i18n.Tr "repo.migrate_repo"}}
</button>
<a class="ui button" href="{{AppSubUrl}}/">{{.i18n.Tr "cancel"}}</a>
Expand Down