Skip to content

Commit 4d37c1d

Browse files
committed
fix
1 parent 70685a9 commit 4d37c1d

File tree

22 files changed

+96
-78
lines changed

22 files changed

+96
-78
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,6 +2355,7 @@ settings.payload_url = Target URL
23552355
settings.http_method = HTTP Method
23562356
settings.content_type = POST Content Type
23572357
settings.secret = Secret
2358+
settings.webhook_secret_desc = If the webhook server supports using secret, you can follow the webhook's manual and fill in a secret here.
23582359
settings.slack_username = Username
23592360
settings.slack_icon_url = Icon URL
23602361
settings.slack_color = Color

routers/web/repo/setting/webhook.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ type webhookParams struct {
198198

199199
URL string
200200
ContentType webhook.HookContentType
201-
Secret string
202201
HTTPMethod string
203202
WebhookForm forms.WebhookForm
204203
Meta any
@@ -237,7 +236,7 @@ func createWebhook(ctx *context.Context, params webhookParams) {
237236
URL: params.URL,
238237
HTTPMethod: params.HTTPMethod,
239238
ContentType: params.ContentType,
240-
Secret: params.Secret,
239+
Secret: params.WebhookForm.Secret,
241240
HookEvent: ParseHookEvent(params.WebhookForm),
242241
IsActive: params.WebhookForm.Active,
243242
Type: params.Type,
@@ -290,7 +289,7 @@ func editWebhook(ctx *context.Context, params webhookParams) {
290289

291290
w.URL = params.URL
292291
w.ContentType = params.ContentType
293-
w.Secret = params.Secret
292+
w.Secret = params.WebhookForm.Secret
294293
w.HookEvent = ParseHookEvent(params.WebhookForm)
295294
w.IsActive = params.WebhookForm.Active
296295
w.HTTPMethod = params.HTTPMethod
@@ -336,7 +335,6 @@ func giteaHookParams(ctx *context.Context) webhookParams {
336335
Type: webhook_module.GITEA,
337336
URL: form.PayloadURL,
338337
ContentType: contentType,
339-
Secret: form.Secret,
340338
HTTPMethod: form.HTTPMethod,
341339
WebhookForm: form.WebhookForm,
342340
}
@@ -364,7 +362,6 @@ func gogsHookParams(ctx *context.Context) webhookParams {
364362
Type: webhook_module.GOGS,
365363
URL: form.PayloadURL,
366364
ContentType: contentType,
367-
Secret: form.Secret,
368365
WebhookForm: form.WebhookForm,
369366
}
370367
}

services/forms/repo_form.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ type WebhookForm struct {
238238
Active bool
239239
BranchFilter string `binding:"GlobPattern"`
240240
AuthorizationHeader string
241+
Secret string
241242
}
242243

243244
// PushOnly if the hook will be triggered when push
@@ -260,7 +261,6 @@ type NewWebhookForm struct {
260261
PayloadURL string `binding:"Required;ValidUrl"`
261262
HTTPMethod string `binding:"Required;In(POST,GET)"`
262263
ContentType int `binding:"Required"`
263-
Secret string
264264
WebhookForm
265265
}
266266

@@ -274,7 +274,6 @@ func (f *NewWebhookForm) Validate(req *http.Request, errs binding.Errors) bindin
274274
type NewGogshookForm struct {
275275
PayloadURL string `binding:"Required;ValidUrl"`
276276
ContentType int `binding:"Required"`
277-
Secret string
278277
WebhookForm
279278
}
280279

templates/admin/hooks.tmpl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin hooks")}}
22
<div class="admin-setting-content">
3-
43
{{template "repo/settings/webhook/base_list" .SystemWebhooks}}
54
{{template "repo/settings/webhook/base_list" .DefaultWebhooks}}
6-
7-
{{template "repo/settings/webhook/delete_modal" .}}
85
</div>
96
{{template "admin/layout_footer" .}}

templates/org/settings/hooks.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings webhooks")}}
22
<div class="org-setting-content">
3-
{{template "repo/settings/webhook/list" .}}
3+
{{template "repo/settings/webhook/base_list" .}}
44
</div>
55
{{template "org/settings/layout_footer" .}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings webhooks")}}
22
<div class="repo-setting-content">
3-
{{template "repo/settings/webhook/list" .}}
3+
{{template "repo/settings/webhook/base_list" .}}
44
</div>
55
{{template "repo/settings/layout_footer" .}}

templates/repo/settings/webhook/base_list.tmpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
<a title="{{.URL}}" href="{{$.BaseLink}}/{{.ID}}">{{.URL}}</a>
1818
</div>
1919
<a class="muted tw-p-2" href="{{$.BaseLink}}/{{.ID}}">{{svg "octicon-pencil"}}</a>
20-
<a class="delete-button tw-p-2" data-url="{{$.Link}}/delete" data-id="{{.ID}}">{{svg "octicon-trash"}}</a>
20+
<a class="text red tw-p-2 link-action"
21+
data-url="{{$.Link}}/delete?id={{.ID}}"
22+
data-modal-confirm="{{ctx.Locale.Tr "repo.settings.webhook_deletion_desc"}}"
23+
>{{svg "octicon-trash"}}</a>
2124
</div>
2225
{{end}}
2326
</div>

templates/repo/settings/webhook/delete_modal.tmpl

Lines changed: 0 additions & 10 deletions
This file was deleted.

templates/repo/settings/webhook/dingtalk.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
77
<input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required>
88
</div>
9-
{{template "repo/settings/webhook/settings" .}}
9+
{{/* FIXME: support authorization header or not? */}}
10+
{{template "repo/settings/webhook/settings" dict "BaseLink" .BaseLink "Webhook" .Webhook "UseAuthorizationHeader" "optional"}}
1011
</form>
1112
{{end}}

templates/repo/settings/webhook/discord.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<label for="icon_url">{{ctx.Locale.Tr "repo.settings.discord_icon_url"}}</label>
1515
<input id="icon_url" name="icon_url" value="{{.DiscordHook.IconURL}}" placeholder="https://example.com/assets/img/logo.svg">
1616
</div>
17-
{{template "repo/settings/webhook/settings" .}}
17+
{{/* FIXME: support authorization header or not? */}}
18+
{{template "repo/settings/webhook/settings" dict "BaseLink" .BaseLink "Webhook" .Webhook "UseAuthorizationHeader" "optional"}}
1819
</form>
1920
{{end}}

0 commit comments

Comments
 (0)