]> source.dussan.org Git - gitea.git/commitdiff
Add button to delete undeleted repositories from failed migrations (#16197)
authorzeripath <art27@cantab.net>
Wed, 30 Jun 2021 19:14:53 +0000 (20:14 +0100)
committerGitHub <noreply@github.com>
Wed, 30 Jun 2021 19:14:53 +0000 (21:14 +0200)
This PR adds a button to delete failed repositories if there has been a
failure during migration and for whatever reason the repository doesn't
get deleted automatically.

Fix #16154

Signed-off-by: Andrew Thornton <art27@cantab.net>
routers/web/repo/view.go
templates/repo/migrate/migrating.tmpl

index 74e2a2959772471f1919cc09c2455369ecc68147..90d06d11c1e1a3864471c52bd8bf8a69ee428190 100644 (file)
@@ -29,6 +29,7 @@ import (
        "code.gitea.io/gitea/modules/log"
        "code.gitea.io/gitea/modules/markup"
        "code.gitea.io/gitea/modules/setting"
+       "code.gitea.io/gitea/modules/structs"
        "code.gitea.io/gitea/modules/typesniffer"
 )
 
@@ -624,6 +625,7 @@ func Home(ctx *context.Context) {
                        ctx.Data["Repo"] = ctx.Repo
                        ctx.Data["MigrateTask"] = task
                        ctx.Data["CloneAddr"] = safeURL(cfg.CloneAddr)
+                       ctx.Data["Failed"] = task.Status == structs.TaskStatusFailed
                        ctx.HTML(http.StatusOK, tplMigrating)
                        return
                }
index c1f189553f6fc899fb3cf23831234fdb929a3028..cc12243205c15cc619e2c1a3d89796fcdd6bd69a 100644 (file)
                                                                <p>{{.i18n.Tr "repo.migrate.migrating_failed" .CloneAddr | Safe}}</p>
                                                                <p id="repo_migrating_failed_error"></p>
                                                        </div>
+                                                       {{if and .Failed .Permission.IsAdmin}}
+                                                               <div class="ui divider"></div>
+                                                               <div class="item">
+                                                                       <button class="ui basic red show-modal button" data-modal="#delete-repo-modal">{{.i18n.Tr "repo.settings.delete"}}</button>
+                                                               </div>
+                                                       {{end}}
                                                </div>
                                        </div>
                                </div>
                </div>
        </div>
 </div>
+<div class="ui small modal" id="delete-repo-modal">
+       <div class="header">
+               {{.i18n.Tr "repo.settings.delete"}}
+       </div>
+       <div class="content">
+               <div class="ui warning message text left">
+                       {{.i18n.Tr "repo.settings.delete_notices_1" | Safe}}<br>
+                       {{.i18n.Tr "repo.settings.delete_notices_2" .Repository.FullName | Safe}}
+                       {{if .Repository.NumForks}}<br>
+                       {{.i18n.Tr "repo.settings.delete_notices_fork_1"}}
+                       {{end}}
+               </div>
+               <form class="ui form" action="{{.Link}}/settings" method="post">
+                       {{.CsrfTokenHtml}}
+                       <input type="hidden" name="action" value="delete">
+                       <div class="field">
+                               <label>
+                                       {{.i18n.Tr "repo.settings.transfer_form_title"}}
+                                       <span class="text red">{{.Repository.Name}}</span>
+                               </label>
+                       </div>
+                       <div class="required field">
+                               <label for="repo_name">{{.i18n.Tr "repo.repo_name"}}</label>
+                               <input id="repo_name" name="repo_name" required>
+                       </div>
+
+                       <div class="text right actions">
+                               <div class="ui cancel button">{{.i18n.Tr "settings.cancel"}}</div>
+                               <button class="ui red button">{{.i18n.Tr "repo.settings.confirm_delete"}}</button>
+                       </div>
+               </form>
+       </div>
+</div>
 {{template "base/footer" .}}