mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-23 05:42:33 +09:00
While editing frontend, I found some inconsistencies while testing transferring repositories: - No button for accepting/rejecting/cancelling the transfer of an empty repository. - The `redirect_to` in `templates/repo/header.tmpl` is useless. - There's no redirection when there's an error from `handleActionError` in `routers/web/repo/repo.go`. Therefore, instead of flash message, a blank page will be displayed. This pr adds some commits to resolve all these issues. Update: see the new changes https://github.com/go-gitea/gitea/pull/37277#issuecomment-4276150232 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
39 lines
982 B
Go
39 lines
982 B
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package repo
|
|
|
|
import (
|
|
"code.gitea.io/gitea/services/context"
|
|
repo_service "code.gitea.io/gitea/services/repository"
|
|
)
|
|
|
|
func acceptTransfer(ctx *context.Context) {
|
|
err := repo_service.AcceptTransferOwnership(ctx, ctx.Repo.Repository, ctx.Doer)
|
|
if err == nil {
|
|
ctx.Flash.Success(ctx.Tr("repo.settings.transfer.success"))
|
|
ctx.JSONRedirect(ctx.Repo.Repository.Link())
|
|
return
|
|
}
|
|
handleActionError(ctx, err)
|
|
}
|
|
|
|
func rejectTransfer(ctx *context.Context) {
|
|
err := repo_service.RejectRepositoryTransfer(ctx, ctx.Repo.Repository, ctx.Doer)
|
|
if err == nil {
|
|
ctx.Flash.Success(ctx.Tr("repo.settings.transfer.rejected"))
|
|
ctx.JSONRedirect(ctx.Repo.Repository.Link())
|
|
return
|
|
}
|
|
handleActionError(ctx, err)
|
|
}
|
|
|
|
func ActionTransfer(ctx *context.Context) {
|
|
switch ctx.PathParam("action") {
|
|
case "accept_transfer":
|
|
acceptTransfer(ctx)
|
|
case "reject_transfer":
|
|
rejectTransfer(ctx)
|
|
}
|
|
}
|