From bc36f85b5fcf14c12d071f5fe6fa46c9bfadf235 Mon Sep 17 00:00:00 2001 From: oliverpool Date: Thu, 21 Mar 2024 14:43:43 +0100 Subject: [PATCH] [REFACTOR] webhook repo naming consistency --- routers/web/repo/setting/webhook.go | 24 +++++++++++------------ routers/web/web.go | 30 ++++++++++++++--------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go index 58c9d2634..bf7770bfd 100644 --- a/routers/web/repo/setting/webhook.go +++ b/routers/web/repo/setting/webhook.go @@ -39,8 +39,8 @@ const ( tplAdminHookNew base.TplName = "admin/hook_new" ) -// Webhooks render web hooks list page -func Webhooks(ctx *context.Context) { +// WebhookList render web hooks list page +func WebhookList(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings.hooks") ctx.Data["PageIsSettingsHooks"] = true ctx.Data["BaseLink"] = ctx.Repo.RepoLink + "/settings/hooks" @@ -109,8 +109,8 @@ func getOwnerRepoCtx(ctx *context.Context) (*ownerRepoCtx, error) { return nil, errors.New("unable to set OwnerRepo context") } -// WebhooksNew render creating webhook page -func WebhooksNew(ctx *context.Context) { +// WebhookNew render creating webhook page +func WebhookNew(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings.add_webhook") ctx.Data["Webhook"] = webhook.Webhook{HookEvent: &webhook_module.HookEvent{}} @@ -367,8 +367,8 @@ func checkWebhook(ctx *context.Context) (*ownerRepoCtx, *webhook.Webhook) { return orCtx, w } -// WebHooksEdit render editing web hook page -func WebHooksEdit(ctx *context.Context) { +// WebhookEdit render editing web hook page +func WebhookEdit(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings.update_webhook") ctx.Data["PageIsSettingsHooks"] = true ctx.Data["PageIsSettingsHooksEdit"] = true @@ -382,8 +382,8 @@ func WebHooksEdit(ctx *context.Context) { ctx.HTML(http.StatusOK, orCtx.NewTemplate) } -// TestWebhook test if web hook is work fine -func TestWebhook(ctx *context.Context) { +// WebhookTest test if web hook is work fine +func WebhookTest(ctx *context.Context) { hookID := ctx.ParamsInt64(":id") w, err := webhook.GetWebhookByRepoID(ctx, ctx.Repo.Repository.ID, hookID) if err != nil { @@ -443,8 +443,8 @@ func TestWebhook(ctx *context.Context) { } } -// ReplayWebhook replays a webhook -func ReplayWebhook(ctx *context.Context) { +// WebhookReplay replays a webhook +func WebhookReplay(ctx *context.Context) { hookTaskUUID := ctx.Params(":uuid") orCtx, w := checkWebhook(ctx) @@ -465,8 +465,8 @@ func ReplayWebhook(ctx *context.Context) { ctx.Redirect(fmt.Sprintf("%s/%d", orCtx.Link, w.ID)) } -// DeleteWebhook delete a webhook -func DeleteWebhook(ctx *context.Context) { +// WebhookDelete delete a webhook +func WebhookDelete(ctx *context.Context) { if err := webhook.DeleteWebhookByRepoID(ctx, ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil { ctx.Flash.Error("DeleteWebhookByRepoID: " + err.Error()) } else { diff --git a/routers/web/web.go b/routers/web/web.go index ec7f6749b..7329acd15 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -609,12 +609,12 @@ func registerRoutes(m *web.Route) { m.Group("/hooks", func() { m.Get("", user_setting.Webhooks) m.Post("/delete", user_setting.DeleteWebhook) - m.Get("/{type}/new", repo_setting.WebhooksNew) + m.Get("/{type}/new", repo_setting.WebhookNew) m.Post("/{type}/new", repo_setting.WebhookCreate) m.Group("/{id}", func() { - m.Get("", repo_setting.WebHooksEdit) + m.Get("", repo_setting.WebhookEdit) m.Post("", repo_setting.WebhookUpdate) - m.Post("/replay/{uuid}", repo_setting.ReplayWebhook) + m.Post("/replay/{uuid}", repo_setting.WebhookReplay) }) }, webhooksEnabled) @@ -714,14 +714,14 @@ func registerRoutes(m *web.Route) { m.Get("", admin.DefaultOrSystemWebhooks) m.Post("/delete", admin.DeleteDefaultOrSystemWebhook) m.Group("/{id}", func() { - m.Get("", repo_setting.WebHooksEdit) + m.Get("", repo_setting.WebhookEdit) m.Post("", repo_setting.WebhookUpdate) - m.Post("/replay/{uuid}", repo_setting.ReplayWebhook) + m.Post("/replay/{uuid}", repo_setting.WebhookReplay) }) }, webhooksEnabled) m.Group("/{configType:default-hooks|system-hooks}", func() { - m.Get("/{type}/new", repo_setting.WebhooksNew) + m.Get("/{type}/new", repo_setting.WebhookNew) m.Post("/{type}/new", repo_setting.WebhookCreate) }) @@ -880,12 +880,12 @@ func registerRoutes(m *web.Route) { m.Group("/hooks", func() { m.Get("", org.Webhooks) m.Post("/delete", org.DeleteWebhook) - m.Get("/{type}/new", repo_setting.WebhooksNew) + m.Get("/{type}/new", repo_setting.WebhookNew) m.Post("/{type}/new", repo_setting.WebhookCreate) m.Group("/{id}", func() { - m.Get("", repo_setting.WebHooksEdit) + m.Get("", repo_setting.WebhookEdit) m.Post("", repo_setting.WebhookUpdate) - m.Post("/replay/{uuid}", repo_setting.ReplayWebhook) + m.Post("/replay/{uuid}", repo_setting.WebhookReplay) }) }, webhooksEnabled) @@ -1053,15 +1053,15 @@ func registerRoutes(m *web.Route) { }, context.GitHookService()) m.Group("/hooks", func() { - m.Get("", repo_setting.Webhooks) - m.Post("/delete", repo_setting.DeleteWebhook) - m.Get("/{type}/new", repo_setting.WebhooksNew) + m.Get("", repo_setting.WebhookList) + m.Post("/delete", repo_setting.WebhookDelete) + m.Get("/{type}/new", repo_setting.WebhookNew) m.Post("/{type}/new", repo_setting.WebhookCreate) m.Group("/{id}", func() { - m.Get("", repo_setting.WebHooksEdit) + m.Get("", repo_setting.WebhookEdit) m.Post("", repo_setting.WebhookUpdate) - m.Post("/test", repo_setting.TestWebhook) - m.Post("/replay/{uuid}", repo_setting.ReplayWebhook) + m.Post("/test", repo_setting.WebhookTest) + m.Post("/replay/{uuid}", repo_setting.WebhookReplay) }) }, webhooksEnabled)