Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

System-wide webhooks #10546

Merged
merged 19 commits into from
Mar 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add UI and locale changes
  • Loading branch information
jamesorlakin committed Mar 1, 2020
commit 4de383406d19dd6e84e7cbc1bd00813a82ae9fd0
5 changes: 5 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,7 @@ users = User Accounts
organizations = Organizations
repositories = Repositories
hooks = Default Webhooks
systemhooks = System Webhooks
authentication = Authentication Sources
config = Configuration
notices = System Notices
Expand Down Expand Up @@ -1844,6 +1845,10 @@ hooks.desc = Webhooks automatically make HTTP POST requests to a server when cer
hooks.add_webhook = Add Default Webhook
hooks.update_webhook = Update Default Webhook

systemhooks.desc = Webhooks automatically make HTTP POST requests to a server when certain Gitea events trigger. Webhooks defined will act on all repositories on the system, so please consider any performance implications this may have. Read more in the <a target="_blank" rel="noopener" href="https://docs.gitea.io/en-us/webhooks/">webhooks guide</a>.
systemhooks.add_webhook = Add System Webhook
systemhooks.update_webhook = Update System Webhook

auths.auth_manage_panel = Authentication Source Management
auths.new = Add Authentication Source
auths.name = Name
Expand Down
10 changes: 6 additions & 4 deletions routers/admin/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ const (

// DefaultAndSystemWebhooks renders both admin default and system webhook list pages
func DefaultAndSystemWebhooks(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("admin.hooks")
ctx.Data["Description"] = ctx.Tr("admin.hooks.desc")

// Are we looking at default webhooks?
var ws []*models.Webhook
var err error

// Are we looking at default webhooks?
if strings.Contains(ctx.Link, "/admin/hooks") {
ctx.Data["Title"] = ctx.Tr("admin.hooks")
ctx.Data["Description"] = ctx.Tr("admin.hooks.desc")
ctx.Data["PageIsAdminHooks"] = true
ctx.Data["BaseLink"] = setting.AppSubURL + "/admin/hooks"
ws, err = models.GetDefaultWebhooks()
} else {
ctx.Data["Title"] = ctx.Tr("admin.systemhooks")
ctx.Data["Description"] = ctx.Tr("admin.systemhooks.desc")
ctx.Data["PageIsAdminSystemHooks"] = true
ctx.Data["BaseLink"] = setting.AppSubURL + "/admin/system-hooks"
ws, err = models.GetSystemWebhooks()
Expand Down
5 changes: 0 additions & 5 deletions routers/repo/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,6 @@ func checkWebhook(ctx *context.Context) (*orgRepoCtx, *models.Webhook) {
}
ctx.Data["BaseLink"] = orCtx.Link

// Used to inform the admin template the difference between default and system webhooks
if orCtx.IsSystemWebhook {
ctx.Data["IsSystemWebhook"] = true
}

var w *models.Webhook
// Why different methods if only the ID matters?
if orCtx.RepoID > 0 {
Expand Down
3 changes: 3 additions & 0 deletions templates/admin/navbar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<a class="{{if .PageIsAdminHooks}}active{{end}} item" href="{{AppSubUrl}}/admin/hooks">
{{.i18n.Tr "admin.hooks"}}
</a>
<a class="{{if .PageIsAdminSystemHooks}}active{{end}} item" href="{{AppSubUrl}}/admin/system-hooks">
{{.i18n.Tr "admin.systemhooks"}}
</a>
<a class="{{if .PageIsAdminAuthentications}}active{{end}} item" href="{{AppSubUrl}}/admin/auths">
{{.i18n.Tr "admin.authentication"}}
</a>
Expand Down