Skip to content

Commit c428a4f

Browse files
zokkissilverwindGiteaBot
committed
Change webhook-type in create-view (go-gitea#29114)
It's now possible to change webhook-type in create-view. before: ![image](https://github.com/go-gitea/gitea/assets/72873130/9ee1b9fb-843b-4f28-b8d6-6361e5d184f1) after: ![image](https://github.com/go-gitea/gitea/assets/72873130/9dbf058f-5912-43af-9acd-487271212f2d) --------- Co-authored-by: silverwind <[email protected]> Co-authored-by: Giteabot <[email protected]>
1 parent 909a53a commit c428a4f

File tree

6 files changed

+67
-49
lines changed

6 files changed

+67
-49
lines changed

routers/web/repo/setting/webhook.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ func WebhooksNew(ctx *context.Context) {
151151
}
152152
}
153153
ctx.Data["BaseLink"] = orCtx.LinkNew
154+
ctx.Data["BaseLinkNew"] = orCtx.LinkNew
154155

155156
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
156157
}

templates/repo/settings/webhook/base_list.tmpl

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,7 @@
33
<div class="ui right">
44
<div class="ui jump dropdown">
55
<div class="ui primary tiny button">{{ctx.Locale.Tr "repo.settings.add_webhook"}}</div>
6-
<div class="menu">
7-
<a class="item" href="{{.BaseLinkNew}}/gitea/new">
8-
{{template "shared/webhook/icon" (dict "HookType" "gitea" "Size" 20)}}
9-
{{ctx.Locale.Tr "repo.settings.web_hook_name_gitea"}}
10-
</a>
11-
<a class="item" href="{{.BaseLinkNew}}/gogs/new">
12-
{{template "shared/webhook/icon" (dict "HookType" "gogs" "Size" 20)}}
13-
{{ctx.Locale.Tr "repo.settings.web_hook_name_gogs"}}
14-
</a>
15-
<a class="item" href="{{.BaseLinkNew}}/slack/new">
16-
{{template "shared/webhook/icon" (dict "HookType" "slack" "Size" 20)}}
17-
{{ctx.Locale.Tr "repo.settings.web_hook_name_slack"}}
18-
</a>
19-
<a class="item" href="{{.BaseLinkNew}}/discord/new">
20-
{{template "shared/webhook/icon" (dict "HookType" "discord" "Size" 20)}}
21-
{{ctx.Locale.Tr "repo.settings.web_hook_name_discord"}}
22-
</a>
23-
<a class="item" href="{{.BaseLinkNew}}/dingtalk/new">
24-
{{template "shared/webhook/icon" (dict "HookType" "dingtalk" "Size" 20)}}
25-
{{ctx.Locale.Tr "repo.settings.web_hook_name_dingtalk"}}
26-
</a>
27-
<a class="item" href="{{.BaseLinkNew}}/telegram/new">
28-
{{template "shared/webhook/icon" (dict "HookType" "telegram" "Size" 20)}}
29-
{{ctx.Locale.Tr "repo.settings.web_hook_name_telegram"}}
30-
</a>
31-
<a class="item" href="{{.BaseLinkNew}}/msteams/new">
32-
{{template "shared/webhook/icon" (dict "HookType" "msteams" "Size" 20)}}
33-
{{ctx.Locale.Tr "repo.settings.web_hook_name_msteams"}}
34-
</a>
35-
<a class="item" href="{{.BaseLinkNew}}/feishu/new">
36-
{{template "shared/webhook/icon" (dict "HookType" "feishu" "Size" 20)}}
37-
{{ctx.Locale.Tr "repo.settings.web_hook_name_feishu_or_larksuite"}}
38-
</a>
39-
<a class="item" href="{{.BaseLinkNew}}/matrix/new">
40-
{{template "shared/webhook/icon" (dict "HookType" "matrix" "Size" 20)}}
41-
{{ctx.Locale.Tr "repo.settings.web_hook_name_matrix"}}
42-
</a>
43-
<a class="item" href="{{.BaseLinkNew}}/wechatwork/new">
44-
{{template "shared/webhook/icon" (dict "HookType" "wechatwork" "Size" 20)}}
45-
{{ctx.Locale.Tr "repo.settings.web_hook_name_wechatwork"}}
46-
</a>
47-
<a class="item" href="{{.BaseLinkNew}}/packagist/new">
48-
{{template "shared/webhook/icon" (dict "HookType" "packagist" "Size" 20)}}
49-
{{ctx.Locale.Tr "repo.settings.web_hook_name_packagist"}}
50-
</a>
51-
</div>
6+
{{template "repo/settings/webhook/link_menu" .}}
527
</div>
538
</div>
549
</h4>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{{$size := 20}}
2+
{{if .Size}}
3+
{{$size = .Size}}
4+
{{end}}
5+
<div class="menu">
6+
<a class="item" href="{{.BaseLinkNew}}/gitea/new">
7+
{{template "shared/webhook/icon" (dict "HookType" "gitea" "Size" $size)}}
8+
{{ctx.Locale.Tr "repo.settings.web_hook_name_gitea"}}
9+
</a>
10+
<a class="item" href="{{.BaseLinkNew}}/gogs/new">
11+
{{template "shared/webhook/icon" (dict "HookType" "gogs" "Size" $size)}}
12+
{{ctx.Locale.Tr "repo.settings.web_hook_name_gogs"}}
13+
</a>
14+
<a class="item" href="{{.BaseLinkNew}}/slack/new">
15+
{{template "shared/webhook/icon" (dict "HookType" "slack" "Size" $size)}}
16+
{{ctx.Locale.Tr "repo.settings.web_hook_name_slack"}}
17+
</a>
18+
<a class="item" href="{{.BaseLinkNew}}/discord/new">
19+
{{template "shared/webhook/icon" (dict "HookType" "discord" "Size" $size)}}
20+
{{ctx.Locale.Tr "repo.settings.web_hook_name_discord"}}
21+
</a>
22+
<a class="item" href="{{.BaseLinkNew}}/dingtalk/new">
23+
{{template "shared/webhook/icon" (dict "HookType" "dingtalk" "Size" $size)}}
24+
{{ctx.Locale.Tr "repo.settings.web_hook_name_dingtalk"}}
25+
</a>
26+
<a class="item" href="{{.BaseLinkNew}}/telegram/new">
27+
{{template "shared/webhook/icon" (dict "HookType" "telegram" "Size" $size)}}
28+
{{ctx.Locale.Tr "repo.settings.web_hook_name_telegram"}}
29+
</a>
30+
<a class="item" href="{{.BaseLinkNew}}/msteams/new">
31+
{{template "shared/webhook/icon" (dict "HookType" "msteams" "Size" $size)}}
32+
{{ctx.Locale.Tr "repo.settings.web_hook_name_msteams"}}
33+
</a>
34+
<a class="item" href="{{.BaseLinkNew}}/feishu/new">
35+
{{template "shared/webhook/icon" (dict "HookType" "feishu" "Size" $size)}}
36+
{{ctx.Locale.Tr "repo.settings.web_hook_name_feishu_or_larksuite"}}
37+
</a>
38+
<a class="item" href="{{.BaseLinkNew}}/matrix/new">
39+
{{template "shared/webhook/icon" (dict "HookType" "matrix" "Size" $size)}}
40+
{{ctx.Locale.Tr "repo.settings.web_hook_name_matrix"}}
41+
</a>
42+
<a class="item" href="{{.BaseLinkNew}}/wechatwork/new">
43+
{{template "shared/webhook/icon" (dict "HookType" "wechatwork" "Size" $size)}}
44+
{{ctx.Locale.Tr "repo.settings.web_hook_name_wechatwork"}}
45+
</a>
46+
<a class="item" href="{{.BaseLinkNew}}/packagist/new">
47+
{{template "shared/webhook/icon" (dict "HookType" "packagist" "Size" $size)}}
48+
{{ctx.Locale.Tr "repo.settings.web_hook_name_packagist"}}
49+
</a>
50+
</div>

templates/shared/webhook/icon.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{{$size = .Size}}
44
{{end}}
55
{{if eq .HookType "gitea"}}
6-
<img width="{{$size}}" height="{{$size}}" src="{{AssetUrlPrefix}}/img/gitea.svg">
6+
{{svg "gitea-gitea" $size "img"}}
77
{{else if eq .HookType "gogs"}}
88
<img width="{{$size}}" height="{{$size}}" src="{{AssetUrlPrefix}}/img/gogs.ico">
99
{{else if eq .HookType "slack"}}

templates/webhook/new.tmpl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<h4 class="ui top attached header">
22
{{.CustomHeaderTitle}}
3-
<div class="ui right">
4-
{{template "shared/webhook/icon" .ctxData}}
3+
<div class="ui right type dropdown">
4+
<div class="text gt-df gt-ac">
5+
{{template "shared/webhook/icon" (dict "Size" 20 "HookType" .ctxData.HookType)}}
6+
{{ctx.Locale.Tr (print "repo.settings.web_hook_name_" .ctxData.HookType)}}
7+
</div>
8+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
9+
{{template "repo/settings/webhook/link_menu" .ctxData}}
510
</div>
611
</h4>
712
<div class="ui attached segment">

web_src/css/base.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,13 @@ ol.ui.list li,
413413
color: var(--color-text-light-2);
414414
}
415415

416+
/* extend fomantic style '.ui.dropdown > .text > img' to include svg.img */
417+
.ui.dropdown > .text > .img {
418+
margin-left: 0;
419+
float: none;
420+
margin-right: 0.78571429rem;
421+
}
422+
416423
.ui.dropdown > .text > .description,
417424
.ui.dropdown .menu > .item > .description {
418425
color: var(--color-text-light-2);

0 commit comments

Comments
 (0)