Skip to content

Commit 09a7a4e

Browse files
committed
move hooks templates to standalone dir and add more webhooks ui
1 parent 5c30c63 commit 09a7a4e

File tree

14 files changed

+97
-27
lines changed

14 files changed

+97
-27
lines changed

modules/auth/repo_form.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,17 @@ func (f *ProtectBranchForm) Validate(ctx *macaron.Context, errs binding.Errors)
155155

156156
// WebhookForm form for changing web hook
157157
type WebhookForm struct {
158-
Events string
159-
Create bool
160-
Push bool
161-
PullRequest bool
162-
Repository bool
163-
Active bool
158+
Events string
159+
Create bool
160+
Delete bool
161+
Fork bool
162+
Issues bool
163+
IssueComment bool
164+
Release bool
165+
Push bool
166+
PullRequest bool
167+
Repository bool
168+
Active bool
164169
}
165170

166171
// PushOnly if the hook will be triggered when push

options/locale/locale_en-US.ini

+10
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,16 @@ settings.event_send_everything = All Events
999999
settings.event_choose = Custom Events…
10001000
settings.event_create = Create
10011001
settings.event_create_desc = Branch or tag created.
1002+
settings.event_delete = Delete
1003+
settings.event_delete_desc = Branch or tag deleted
1004+
settings.event_fork = Fork
1005+
settings.event_fork_desc = Repository forked
1006+
settings.event_issues = Issues
1007+
settings.event_issues_desc = Issue opened, closed, reopened, edited, assigned, unassigned, label updated, label cleared, milestoned, or demilestoned.
1008+
settings.event_issue_comment = Issue Comment
1009+
settings.event_issue_comment_desc = Issue comment created, edited, or deleted.
1010+
settings.event_release = Release
1011+
settings.event_release_desc = Release published in a repository.
10021012
settings.event_pull_request = Pull Request
10031013
settings.event_pull_request_desc = Pull request opened, closed, reopened, edited, assigned, unassigned, label updated, label cleared or synchronized.
10041014
settings.event_push = Push

routers/repo/webhook.go

+12-7
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import (
2323
)
2424

2525
const (
26-
tplHooks base.TplName = "repo/settings/hooks"
27-
tplHookNew base.TplName = "repo/settings/hook_new"
28-
tplOrgHookNew base.TplName = "org/settings/hook_new"
26+
tplHooks base.TplName = "repo/settings/webhook/base"
27+
tplHookNew base.TplName = "repo/settings/webhook/new"
28+
tplOrgHookNew base.TplName = "org/settings/webhook/new"
2929
)
3030

3131
// Webhooks render web hooks list page
@@ -118,10 +118,15 @@ func ParseHookEvent(form auth.WebhookForm) *models.HookEvent {
118118
SendEverything: form.SendEverything(),
119119
ChooseEvents: form.ChooseEvents(),
120120
HookEvents: models.HookEvents{
121-
Create: form.Create,
122-
Push: form.Push,
123-
PullRequest: form.PullRequest,
124-
Repository: form.Repository,
121+
Create: form.Create,
122+
Delete: form.Delete,
123+
Fork: form.Fork,
124+
Issues: form.Issues,
125+
IssueComment: form.IssueComment,
126+
Release: form.Release,
127+
Push: form.Push,
128+
PullRequest: form.PullRequest,
129+
Repository: form.Repository,
125130
},
126131
}
127132
}

templates/repo/settings/hooks.tmpl renamed to templates/repo/settings/webhook/base.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{{template "repo/header" .}}
44
{{template "repo/settings/navbar" .}}
55
<div class="ui container">
6-
{{template "repo/settings/hook_list" .}}
6+
{{template "repo/settings/webhook/list" .}}
77
</div>
88
</div>
99
{{template "base/footer" .}}

templates/repo/settings/hook_dingtalk.tmpl renamed to templates/repo/settings/webhook/dingtalk.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
<label for="payload_url">{{.i18n.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/hook_settings" .}}
9+
{{template "repo/settings/webhook/settings" .}}
1010
</form>
1111
{{end}}

templates/repo/settings/hook_discord.tmpl renamed to templates/repo/settings/webhook/discord.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
<label for="icon_url">{{.i18n.Tr "repo.settings.discord_icon_url"}}</label>
1515
<input id="icon_url" name="icon_url" value="{{.DiscordHook.IconURL}}" placeholder="e.g. https://example.com/img/favicon.png">
1616
</div>
17-
{{template "repo/settings/hook_settings" .}}
17+
{{template "repo/settings/webhook/settings" .}}
1818
</form>
1919
{{end}}

templates/repo/settings/hook_gitea.tmpl renamed to templates/repo/settings/webhook/gitea.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
<label for="secret">{{.i18n.Tr "repo.settings.secret"}}</label>
2424
<input id="secret" name="secret" type="password" value="{{.Webhook.Secret}}" autocomplete="off">
2525
</div>
26-
{{template "repo/settings/hook_settings" .}}
26+
{{template "repo/settings/webhook/settings" .}}
2727
</form>
2828
{{end}}

templates/repo/settings/hook_gogs.tmpl renamed to templates/repo/settings/webhook/gogs.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
<label for="secret">{{.i18n.Tr "repo.settings.secret"}}</label>
2424
<input id="secret" name="secret" type="password" value="{{.Webhook.Secret}}" autocomplete="off">
2525
</div>
26-
{{template "repo/settings/hook_settings" .}}
26+
{{template "repo/settings/webhook/settings" .}}
2727
</form>
2828
{{end}}

templates/repo/settings/hook_list.tmpl renamed to templates/repo/settings/webhook/list.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@
4848
</div>
4949
</div>
5050

51-
{{template "repo/settings/hook_delete_modal" .}}
51+
{{template "repo/settings/webhook/delete_modal" .}}

templates/repo/settings/hook_new.tmpl renamed to templates/repo/settings/webhook/new.tmpl

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
</div>
2222
</h4>
2323
<div class="ui attached segment">
24-
{{template "repo/settings/hook_gitea" .}}
25-
{{template "repo/settings/hook_gogs" .}}
26-
{{template "repo/settings/hook_slack" .}}
27-
{{template "repo/settings/hook_discord" .}}
28-
{{template "repo/settings/hook_dingtalk" .}}
24+
{{template "repo/settings/webhook/gitea" .}}
25+
{{template "repo/settings/webhook/gogs" .}}
26+
{{template "repo/settings/webhook/slack" .}}
27+
{{template "repo/settings/webhook/discord" .}}
28+
{{template "repo/settings/webhook/dingtalk" .}}
2929
</div>
3030

31-
{{template "repo/settings/hook_history" .}}
31+
{{template "repo/settings/webhook/history" .}}
3232
</div>
3333
</div>
3434
{{template "base/footer" .}}

templates/repo/settings/hook_settings.tmpl renamed to templates/repo/settings/webhook/settings.tmpl

+51-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@
3232
</div>
3333
</div>
3434
</div>
35+
<!-- Delete -->
36+
<div class="seven wide column">
37+
<div class="field">
38+
<div class="ui checkbox">
39+
<input class="hidden" name="delete" type="checkbox" tabindex="0" {{if .Webhook.Delete}}checked{{end}}>
40+
<label>{{.i18n.Tr "repo.settings.event_delete"}}</label>
41+
<span class="help">{{.i18n.Tr "repo.settings.event_delete_desc"}}</span>
42+
</div>
43+
</div>
44+
</div>
45+
<!-- Fork -->
46+
<div class="seven wide column">
47+
<div class="field">
48+
<div class="ui checkbox">
49+
<input class="hidden" name="fork" type="checkbox" tabindex="0" {{if .Webhook.Fork}}checked{{end}}>
50+
<label>{{.i18n.Tr "repo.settings.event_fork"}}</label>
51+
<span class="help">{{.i18n.Tr "repo.settings.event_fork_desc"}}</span>
52+
</div>
53+
</div>
54+
</div>
3555
<!-- Push -->
3656
<div class="seven wide column">
3757
<div class="field">
@@ -42,6 +62,26 @@
4262
</div>
4363
</div>
4464
</div>
65+
<!-- Issues -->
66+
<div class="seven wide column">
67+
<div class="field">
68+
<div class="ui checkbox">
69+
<input class="hidden" name="issues" type="checkbox" tabindex="0" {{if .Webhook.Issues}}checked{{end}}>
70+
<label>{{.i18n.Tr "repo.settings.event_issues"}}</label>
71+
<span class="help">{{.i18n.Tr "repo.settings.event_issues_desc"}}</span>
72+
</div>
73+
</div>
74+
</div>
75+
<!-- Issue Comment -->
76+
<div class="seven wide column">
77+
<div class="field">
78+
<div class="ui checkbox">
79+
<input class="hidden" name="issue_comment" type="checkbox" tabindex="0" {{if .Webhook.IssueComment}}checked{{end}}>
80+
<label>{{.i18n.Tr "repo.settings.event_issue_comment"}}</label>
81+
<span class="help">{{.i18n.Tr "repo.settings.event_issue_comment_desc"}}</span>
82+
</div>
83+
</div>
84+
</div>
4585
<!-- Pull Request -->
4686
<div class="seven wide column">
4787
<div class="field">
@@ -62,6 +102,16 @@
62102
</div>
63103
</div>
64104
</div>
105+
<!-- Release -->
106+
<div class="seven wide column">
107+
<div class="field">
108+
<div class="ui checkbox">
109+
<input class="hidden" name="release" type="checkbox" tabindex="0" {{if .Webhook.Release}}checked{{end}}>
110+
<label>{{.i18n.Tr "repo.settings.event_release"}}</label>
111+
<span class="help">{{.i18n.Tr "repo.settings.event_release_desc"}}</span>
112+
</div>
113+
</div>
114+
</div>
65115
</div>
66116
</div>
67117

@@ -83,4 +133,4 @@
83133
{{end}}
84134
</div>
85135

86-
{{template "repo/settings/hook_delete_modal" .}}
136+
{{template "repo/settings/webhook/delete_modal" .}}

templates/repo/settings/hook_slack.tmpl renamed to templates/repo/settings/webhook/slack.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
<label for="color">{{.i18n.Tr "repo.settings.slack_color"}}</label>
2424
<input id="color" name="color" value="{{.SlackHook.Color}}" placeholder="e.g. #dd4b39, good, warning, danger">
2525
</div>
26-
{{template "repo/settings/hook_settings" .}}
26+
{{template "repo/settings/webhook/settings" .}}
2727
</form>
2828
{{end}}

0 commit comments

Comments
 (0)