Skip to content
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

#13091 - add new mirror button #13105

Merged
merged 11 commits into from
Oct 23, 2020
2 changes: 2 additions & 0 deletions routers/org/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ func Home(ctx *context.Context) {
ctx.Data["Members"] = members
ctx.Data["Teams"] = org.Teams

ctx.Data["DisabledMirrors"] = setting.Repository.DisableMirrors

pager := context.NewPagination(int(count), setting.UI.User.RepoPagingNum, page, 5)
pager.SetDefaultParams(ctx)
ctx.Data["Page"] = pager
Expand Down
3 changes: 3 additions & 0 deletions routers/repo/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func Migrate(ctx *context.Context) {
ctx.Data["Services"] = append([]structs.GitServiceType{structs.PlainGitService}, structs.SupportedFullGitService...)
serviceType := ctx.QueryInt("service_type")
if serviceType == 0 {
ctx.Data["Org"] = ctx.Query("org")
ctx.Data["Mirror"] = ctx.Query("mirror")

ctx.HTML(200, tplMigrate)
return
}
Expand Down
3 changes: 3 additions & 0 deletions templates/org/home.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<div class="ui eleven wide column">
{{if .CanCreateOrgRepo}}
<div class="text right">
{{if not .DisabledMirrors}}
<a class="ui green button" href="{{AppSubUrl}}/repo/migrate?org={{.Org.ID}}&mirror=1">{{.i18n.Tr "new_mirror"}}</a>
Copy link
Member

@silverwind silverwind Oct 18, 2020

Choose a reason for hiding this comment

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

.Org and .Mirror can be nil, I think you need to conditionally add those params only when the are not nil to not break regular migrations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, but how can .Org be nil? This would be on the homepage of an Org so wouldn't .Org have to exist? Existing migrations from the dropdown to the top right will not be sending org and mirror params. In that case, from the repo selection page (second screenshot), org=&mirror= will be sent, which will have no impact on the form in screenshot 3.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, probably fine. I misinterpreted the serviceType == 0 part in the code. If that template only renders in that if clause it cannot become nil under regular means.

{{end}}
<a class="ui green button" href="{{AppSubUrl}}/repo/create?org={{.Org.ID}}">{{.i18n.Tr "new_repo"}}</a>
</div>
<div class="ui divider"></div>
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/migrate/migrate.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<div class="ui three stackable cards">
{{range .Services}}
<div class="ui card">
<a class="image" href="{{AppSubUrl}}/repo/migrate?service_type={{.}}">
<a class="image" href="{{AppSubUrl}}/repo/migrate?service_type={{.}}&org={{$.Org}}&mirror={{$.Mirror}}">
{{svg (Printf "gitea-%s" .Name) 184}}
</a>
<div class="content">
<a class="header" href="{{AppSubUrl}}/repo/migrate?service_type={{.}}">{{.Title}}</a>
<a class="header" href="{{AppSubUrl}}/repo/migrate?service_type={{.}}&org={{$.Org}}&mirror={{$.Mirror}}">{{.Title}}</a>
<div class="description">
{{(Printf "repo.migrate.%s.description" .Name) | $.i18n.Tr }}
</div>
Expand Down