Files
gitea/routers/web/user/setting/webhooks.go
T
silverwind 055105d42f fix(web): match settings page titles to the UI (#40336)
Many settings pages had a generic or missing title, so browser tabs and
history named the wrong page. Titles now use the active sidebar label,
or the page header on sub-pages, and are set once where several handlers
render the same page. The user and org webhook list headers print the
title, so they now read "Webhooks" instead of "Settings".

| Page | Before | After |
| --- | --- | --- |
| Runners, secrets, Actions general, admin job queue | Actions |
Runners, Secrets, General, Job queue |
| User and org webhooks, org options, 2FA enroll, account and keys after
a form error | Settings | Webhooks, Organization, Enroll in Two-Factor
Authentication, Account, SSH / GPG Keys |
| Admin self check, OAuth2 app edit, repo public access, repo LFS
pointer files | (none), owner/repo | Self Check, Edit OAuth2
Application, Public Access, Find pointer files |
| Admin trace, new branch protection rule, package cleanup rules |
Monitoring, Branch Protection -, Packages | Trace, Add New Rule,
Add/Edit Cleanup Rule, Cleanup Rule Preview |
| Admin webhook add and edit | Add/Update Webhook | Add/Update System
Webhook, Add/Update Default Webhook |
| Sidebar on admin queue, admin webhook edit, user OAuth2 app edit | no
highlight | Queues, Webhooks, Applications |

Assisted-by: Claude Code:claude-opus-5-5
2026-11-17 02:41:49 +00:00

54 lines
1.5 KiB
Go

// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package setting
import (
"net/http"
"gitea.dev/models/db"
"gitea.dev/models/webhook"
"gitea.dev/modules/setting"
"gitea.dev/modules/templates"
"gitea.dev/services/audit"
"gitea.dev/services/context"
)
const (
tplSettingsHooks templates.TplName = "user/settings/hooks"
)
// Webhooks render webhook list page
func Webhooks(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings.hooks")
ctx.Data["PageIsSettingsHooks"] = true
ctx.Data["BaseLink"] = setting.AppSubURL + "/user/settings/hooks"
ctx.Data["BaseLinkNew"] = setting.AppSubURL + "/user/settings/hooks"
ctx.Data["Description"] = ctx.Tr("settings.hooks.desc")
ws, err := db.Find[webhook.Webhook](ctx, webhook.ListWebhookOptions{OwnerID: ctx.Doer.ID})
if err != nil {
ctx.ServerErrorAuto(err)
return
}
ctx.Data["Webhooks"] = ws
ctx.HTML(http.StatusOK, tplSettingsHooks)
}
// DeleteWebhook response for delete webhook
func DeleteWebhook(ctx *context.Context) {
hook, err := webhook.GetWebhookByOwnerID(ctx, ctx.Doer.ID, ctx.FormInt64("id"))
if err != nil {
ctx.Flash.Error("GetWebhookByOwnerID: " + err.Error())
} else if err := webhook.DeleteWebhookByOwnerID(ctx, ctx.Doer.ID, hook.ID); err != nil {
ctx.Flash.Error("DeleteWebhookByOwnerID: " + err.Error())
} else {
audit.RecordScoped(ctx, ctx.Doer, nil, audit.WebhookRemove, "webhook", hook.URL)
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
}
ctx.JSONRedirect(setting.AppSubURL + "/user/settings/hooks")
}