Skip to content
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
12 changes: 10 additions & 2 deletions routers/web/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ func Create(ctx *context.Context) {
if ctx.Written() {
return
}
ctx.Data["ContextUser"] = ctxUser

ctx.Data["repo_template_name"] = ctx.Tr("repo.template_select")
templateID := ctx.FormInt64("template_id")
Expand All @@ -158,8 +157,17 @@ func Create(ctx *context.Context) {
}
}

ctx.Data["CanCreateRepo"] = ctx.Doer.CanCreateRepo()
canCreateRepo := ctx.Doer.CanCreateRepo()
if !canCreateRepo && ctx.Doer.ID == ctxUser.ID {
orgs, has := ctx.Data["Orgs"].([]*organization.Organization)
if has && len(orgs) > 0 {
ctxUser = orgs[0].AsUser()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the first organizaiton?

Copy link
Member Author

@a1012112796 a1012112796 May 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because curent user can't create repo, and user hasn't choose an organizaiton by query option, so use the the first organizaiton as default.
image

}
}

ctx.Data["CanCreateRepo"] = canCreateRepo
ctx.Data["MaxCreationLimit"] = ctx.Doer.MaxCreationLimit()
ctx.Data["ContextUser"] = ctxUser

ctx.HTML(http.StatusOK, tplCreate)
}
Expand Down
14 changes: 8 additions & 6 deletions templates/repo/create.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<p class="ui center">{{.i18n.Tr "repo.new_repo_helper" ((printf "%s%s" AppSubUrl "/repo/migrate")|Escape) | Safe}}</p>
{{end}}

{{if not .CanCreateRepo}}
{{if and (not .CanCreateRepo) (not .Orgs)}}
<div class="ui negative message">
<p>{{.i18n.TrN .MaxCreationLimit "repo.form.reach_limit_of_creation_1" "repo.form.reach_limit_of_creation_n" .MaxCreationLimit}}</p>
</div>
Expand All @@ -29,10 +29,12 @@
</span>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="menu">
<div class="item truncated-item-container" data-value="{{.SignedUser.ID}}" title="{{.SignedUser.Name}}">
{{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}}" title="{{.SignedUser.Name}}">
{{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 @@ -216,7 +218,7 @@
<br/>
<div class="inline field">
<label></label>
<button class="ui green button{{if not .CanCreateRepo}} disabled{{end}}">
<button class="ui green button{{if and (not .CanCreateRepo) (not .Orgs)}} disabled{{end}}">
{{.i18n.Tr "repo.create_repo"}}
</button>
<a class="ui button" href="{{AppSubUrl}}/">{{.i18n.Tr "cancel"}}</a>
Expand Down