#13091 - add new mirror button (#13105)

* added button

* got URL params to carry through to service specific migrate pages

* do not display add mirror button if mirroring turned off

* added corrections by reviewers

* Add silverwind's suggestion

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: silverwind <me@silverwind.io>
release/v1.15
Divyam Bhasin 2020-10-23 19:01:58 -04:00 committed by GitHub
parent d2ad4dec63
commit 9b11c3e320
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 2 deletions

View File

@ -127,6 +127,8 @@ func Home(ctx *context.Context) {
ctx.Data["Members"] = members ctx.Data["Members"] = members
ctx.Data["Teams"] = org.Teams ctx.Data["Teams"] = org.Teams
ctx.Data["DisabledMirrors"] = setting.Repository.DisableMirrors
pager := context.NewPagination(int(count), setting.UI.User.RepoPagingNum, page, 5) pager := context.NewPagination(int(count), setting.UI.User.RepoPagingNum, page, 5)
pager.SetDefaultParams(ctx) pager.SetDefaultParams(ctx)
ctx.Data["Page"] = pager ctx.Data["Page"] = pager

View File

@ -28,6 +28,9 @@ func Migrate(ctx *context.Context) {
ctx.Data["Services"] = append([]structs.GitServiceType{structs.PlainGitService}, structs.SupportedFullGitService...) ctx.Data["Services"] = append([]structs.GitServiceType{structs.PlainGitService}, structs.SupportedFullGitService...)
serviceType := ctx.QueryInt("service_type") serviceType := ctx.QueryInt("service_type")
if serviceType == 0 { if serviceType == 0 {
ctx.Data["Org"] = ctx.Query("org")
ctx.Data["Mirror"] = ctx.Query("mirror")
ctx.HTML(200, tplMigrate) ctx.HTML(200, tplMigrate)
return return
} }

View File

@ -28,6 +28,9 @@
<div class="ui eleven wide column"> <div class="ui eleven wide column">
{{if .CanCreateOrgRepo}} {{if .CanCreateOrgRepo}}
<div class="text right"> <div class="text right">
{{if not .DisabledMirrors}}
<a class="ui green button" href="{{AppSubUrl}}/repo/migrate?org={{.Org.ID}}&mirror=1">{{.i18n.Tr "new_migrate"}}</a>
{{end}}
<a class="ui green button" href="{{AppSubUrl}}/repo/create?org={{.Org.ID}}">{{.i18n.Tr "new_repo"}}</a> <a class="ui green button" href="{{AppSubUrl}}/repo/create?org={{.Org.ID}}">{{.i18n.Tr "new_repo"}}</a>
</div> </div>
<div class="ui divider"></div> <div class="ui divider"></div>

View File

@ -5,11 +5,11 @@
<div class="ui three stackable cards"> <div class="ui three stackable cards">
{{range .Services}} {{range .Services}}
<div class="ui card"> <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}} {{svg (Printf "gitea-%s" .Name) 184}}
</a> </a>
<div class="content"> <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"> <div class="description">
{{(Printf "repo.migrate.%s.description" .Name) | $.i18n.Tr }} {{(Printf "repo.migrate.%s.description" .Name) | $.i18n.Tr }}
</div> </div>