From 9c3395c556db8f832f2f4fb0d63256eda443f498 Mon Sep 17 00:00:00 2001 From: Jason Song Date: Mon, 19 Dec 2022 18:44:14 +0800 Subject: [PATCH] chore: removed to shared --- routers/web/admin/runners.go | 12 ++++++------ routers/web/org/org_runners.go | 12 ++++++------ routers/web/repo/runners.go | 12 ++++++------ routers/{common => web/shared/actions}/runners.go | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) rename routers/{common => web/shared/actions}/runners.go (99%) diff --git a/routers/web/admin/runners.go b/routers/web/admin/runners.go index 6029862d97..e94c1eb39c 100644 --- a/routers/web/admin/runners.go +++ b/routers/web/admin/runners.go @@ -12,7 +12,7 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" - "code.gitea.io/gitea/routers/common" + actions_shared "code.gitea.io/gitea/routers/web/shared/actions" ) const ( @@ -40,7 +40,7 @@ func Runners(ctx *context.Context) { Filter: ctx.Req.URL.Query().Get("q"), } - common.RunnersList(ctx, tplRunners, opts) + actions_shared.RunnersList(ctx, tplRunners, opts) } // EditRunner show editing runner page @@ -54,7 +54,7 @@ func EditRunner(ctx *context.Context) { page = 1 } - common.RunnerDetails(ctx, tplRunnerEdit, page, ctx.ParamsInt64(":runnerid"), 0, 0) + actions_shared.RunnerDetails(ctx, tplRunnerEdit, page, ctx.ParamsInt64(":runnerid"), 0, 0) } // EditRunnerPost response for editing runner @@ -62,18 +62,18 @@ func EditRunnerPost(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("admin.runners.edit") ctx.Data["PageIsAdmin"] = true ctx.Data["PageIsAdminRunners"] = true - common.RunnerDetailsEditPost(ctx, ctx.ParamsInt64(":runnerid"), 0, 0, + actions_shared.RunnerDetailsEditPost(ctx, ctx.ParamsInt64(":runnerid"), 0, 0, setting.AppSubURL+"/admin/runners/"+url.PathEscape(ctx.Params(":runnerid"))) } // DeleteRunnerPost response for deleting a runner func DeleteRunnerPost(ctx *context.Context) { - common.RunnerDeletePost(ctx, ctx.ParamsInt64(":runnerid"), + actions_shared.RunnerDeletePost(ctx, ctx.ParamsInt64(":runnerid"), setting.AppSubURL+"/admin/runners/", setting.AppSubURL+"/admin/runners/"+url.PathEscape(ctx.Params(":runnerid")), ) } func ResetRunnerRegistrationToken(ctx *context.Context) { - common.RunnerResetRegistrationToken(ctx, 0, 0, setting.AppSubURL+"/admin/runners/") + actions_shared.RunnerResetRegistrationToken(ctx, 0, 0, setting.AppSubURL+"/admin/runners/") } diff --git a/routers/web/org/org_runners.go b/routers/web/org/org_runners.go index cd9b194baa..f87a506504 100644 --- a/routers/web/org/org_runners.go +++ b/routers/web/org/org_runners.go @@ -9,7 +9,7 @@ import ( actions_model "code.gitea.io/gitea/models/actions" "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/context" - "code.gitea.io/gitea/routers/common" + actions_shared "code.gitea.io/gitea/routers/web/shared/actions" ) // Runners render runners page @@ -34,12 +34,12 @@ func Runners(ctx *context.Context) { WithAvailable: true, } - common.RunnersList(ctx, tplSettingsRunners, opts) + actions_shared.RunnersList(ctx, tplSettingsRunners, opts) } // ResetRunnerRegistrationToken reset runner registration token func ResetRunnerRegistrationToken(ctx *context.Context) { - common.RunnerResetRegistrationToken(ctx, + actions_shared.RunnerResetRegistrationToken(ctx, ctx.Org.Organization.ID, 0, ctx.Org.OrgLink+"/settings/runners") } @@ -54,7 +54,7 @@ func RunnersEdit(ctx *context.Context) { page = 1 } - common.RunnerDetails(ctx, tplSettingsRunnersEdit, page, + actions_shared.RunnerDetails(ctx, tplSettingsRunnersEdit, page, ctx.ParamsInt64(":runnerid"), ctx.Org.Organization.ID, 0, ) } @@ -64,14 +64,14 @@ func RunnersEditPost(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("org.runners.edit") ctx.Data["PageIsOrgSettings"] = true ctx.Data["PageIsOrgSettingsRunners"] = true - common.RunnerDetailsEditPost(ctx, ctx.ParamsInt64(":runnerid"), + actions_shared.RunnerDetailsEditPost(ctx, ctx.ParamsInt64(":runnerid"), ctx.Org.Organization.ID, 0, ctx.Org.OrgLink+"/settings/runners/"+url.PathEscape(ctx.Params(":runnerid"))) } // RunnerDeletePost response for deleting runner func RunnerDeletePost(ctx *context.Context) { - common.RunnerDeletePost(ctx, + actions_shared.RunnerDeletePost(ctx, ctx.ParamsInt64(":runnerid"), ctx.Org.OrgLink+"/settings/runners", ctx.Org.OrgLink+"/settings/runners/"+url.PathEscape(ctx.Params(":runnerid"))) diff --git a/routers/web/repo/runners.go b/routers/web/repo/runners.go index 97bf9dd995..8be5e828af 100644 --- a/routers/web/repo/runners.go +++ b/routers/web/repo/runners.go @@ -9,7 +9,7 @@ import ( actions_model "code.gitea.io/gitea/models/actions" "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/context" - "code.gitea.io/gitea/routers/common" + actions_shared "code.gitea.io/gitea/routers/web/shared/actions" ) const ( @@ -38,7 +38,7 @@ func Runners(ctx *context.Context) { WithAvailable: true, } - common.RunnersList(ctx, tplRunners, opts) + actions_shared.RunnersList(ctx, tplRunners, opts) } func RunnersEdit(ctx *context.Context) { @@ -49,7 +49,7 @@ func RunnersEdit(ctx *context.Context) { page = 1 } - common.RunnerDetails(ctx, tplRunnerEdit, page, + actions_shared.RunnerDetails(ctx, tplRunnerEdit, page, ctx.ParamsInt64(":runnerid"), 0, ctx.Repo.Repository.ID, ) } @@ -57,20 +57,20 @@ func RunnersEdit(ctx *context.Context) { func RunnersEditPost(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings.runners") ctx.Data["PageIsSettingsRunners"] = true - common.RunnerDetailsEditPost(ctx, ctx.ParamsInt64(":runnerid"), + actions_shared.RunnerDetailsEditPost(ctx, ctx.ParamsInt64(":runnerid"), 0, ctx.Repo.Repository.ID, ctx.Repo.RepoLink+"/settings/runners/"+url.PathEscape(ctx.Params(":runnerid"))) } func ResetRunnerRegistrationToken(ctx *context.Context) { - common.RunnerResetRegistrationToken(ctx, + actions_shared.RunnerResetRegistrationToken(ctx, 0, ctx.Repo.Repository.ID, ctx.Repo.RepoLink+"/settings/runners") } // RunnerDeletePost response for deleting runner func RunnerDeletePost(ctx *context.Context) { - common.RunnerDeletePost(ctx, ctx.ParamsInt64(":runnerid"), + actions_shared.RunnerDeletePost(ctx, ctx.ParamsInt64(":runnerid"), ctx.Repo.RepoLink+"/settings/runners", ctx.Repo.RepoLink+"/settings/runners/"+url.PathEscape(ctx.Params(":runnerid"))) } diff --git a/routers/common/runners.go b/routers/web/shared/actions/runners.go similarity index 99% rename from routers/common/runners.go rename to routers/web/shared/actions/runners.go index 0aab67b8c3..d578667c48 100644 --- a/routers/common/runners.go +++ b/routers/web/shared/actions/runners.go @@ -1,7 +1,7 @@ // Copyright 2022 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT -package common +package actions import ( "errors"