diff --git a/appview/pages/funcmap.go b/appview/pages/funcmap.go --- a/appview/pages/funcmap.go +++ b/appview/pages/funcmap.go @@ -466,6 +466,7 @@ {"Name": "general", "Icon": "sliders-horizontal"}, {"Name": "access", "Icon": "users"}, {"Name": "pipelines", "Icon": "layers-2"}, + {"Name": "hooks", "Icon": "webhook"}, }, } }, diff --git a/appview/pages/pages.go b/appview/pages/pages.go --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -964,6 +964,20 @@ return p.executeRepo("repo/settings/pipelines", w, params) } +type RepoWebhooksSettingsParams struct { + LoggedInUser *oauth.MultiAccountUser + RepoInfo repoinfo.RepoInfo + Active string + Tab string + Webhooks []models.Webhook +} + +func (p *Pages) RepoWebhooksSettings(w io.Writer, params RepoWebhooksSettingsParams) error { + params.Active = "settings" + params.Tab = "hooks" + return p.executeRepo("repo/settings/hooks", w, params) +} + type RepoIssuesParams struct { LoggedInUser *oauth.MultiAccountUser RepoInfo repoinfo.RepoInfo diff --git a/appview/pages/templates/repo/settings/hooks.html b/appview/pages/templates/repo/settings/hooks.html new file mode 100644 --- /dev/null +++ b/appview/pages/templates/repo/settings/hooks.html @@ -0,0 +1,261 @@ +{{ define "title" }}{{ .Tab }} settings · {{ .RepoInfo.FullName }}{{ end }} + +{{ define "repoContent" }} +
+
+ {{ template "repo/settings/fragments/sidebar" . }} +
+
+ {{ template "webhooksSettings" . }} +
+
+
+{{ end }} + +{{ define "webhooksSettings" }} +
+
+

Webhooks

+

+ Webhooks allow external services to be notified when certain events happen. + When the specified events happen, we'll send a POST request to each of the URLs you provide. +

+
+
+ +
+ {{ template "addWebhookModal" . }} +
+
+
+
+ {{ range .Webhooks }} +
+
+
+
+ {{ .Url }} + {{ if .Active }} + + {{ i "circle-check" "size-4" }} + active + + {{ else }} + + {{ i "circle" "size-4" }} + inactive + + {{ end }} +
+
+ Events: {{ range $i, $e := .Events }}{{ if $i }}, {{ end }}{{ $e }}{{ end }} +
+
+ {{ if $.RepoInfo.Roles.IsOwner }} +
+ + +
+ {{ end }} +
+ {{ if $.RepoInfo.Roles.IsOwner }} +
+ +
+
+ {{ template "editWebhookModal" (list $ .) }} +
+ {{ end }} +
+ {{ else }} +
+ no webhooks configured yet +
+ {{ end }} +
+{{ end }} + +{{ define "addWebhookModal" }} +
+

New Webhook

+ +
+ + +

+ The URL that will receive the webhook POST requests. +

+
+ +
+ + +

+ If provided, webhook payloads will be signed with HMAC-SHA256. Leave blank to send unsigned webhooks. +

+
+ +
+ +
+
+ + Push events +
+

+ Additional event types (pull requests, issues) will be available in future updates. +

+
+
+ +
+ + +
+ +
+ + +
+
+
+{{ end }} + +{{ define "editWebhookModal" }} +{{ $ctx := index . 0 }} +{{ $webhook := index . 1 }} +
+

Edit Webhook

+ +
+ + +
+ +
+ + +

+ Leave blank to keep the existing secret. Remove value to disable signing. +

+
+ +
+ +
+ {{ $hasPush := false }} + {{ range $webhook.Events }} + {{ if eq . "push" }}{{ $hasPush = true }}{{ end }} + {{ end }} +
+ + Push events +
+

+ Additional event types (pull requests, issues) will be available in future updates. +

+
+
+ +
+ + Enable +
+ +
+ + +
+
+
+{{ end }}