[REFACTOR] use Icon from interface in webhook list

This commit is contained in:
oliverpool 2024-03-23 21:28:30 +01:00 committed by GitHub
parent 6b2d02528f
commit 7f03fdf9f9
25 changed files with 70 additions and 105 deletions

View file

@ -341,5 +341,4 @@ package "code.gitea.io/gitea/services/repository/files"
package "code.gitea.io/gitea/services/webhook"
func NewNotifier
func List

View file

@ -935,9 +935,9 @@ settings.web_hook_name_discord = Discord
settings.web_hook_name_telegram = Telegram
settings.web_hook_name_matrix = Matrix
settings.web_hook_name_gogs = Gogs
settings.web_hook_name_feishu_or_larksuite = Feishu / Lark Suite
settings.web_hook_name_feishu = Feishu
settings.web_hook_name_larksuite = Lark Suite
settings.web_hook_name_feishu = Feishu / Lark Suite
settings.web_hook_name_feishu_only = Feishu
settings.web_hook_name_larksuite_only = Lark Suite
settings.web_hook_name_wechatwork = WeCom (Wechat Work)
settings.web_hook_name_packagist = Packagist
diff.file_byte_size = Размер

View file

@ -2308,9 +2308,9 @@ settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=Feishu / Lark Suite
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=Feishu / Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=WeCom (Wechat Work)
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Uživatelské jméno pro Packagist

View file

@ -2304,9 +2304,9 @@ settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=Feishu / Lark Suite
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=Feishu / Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=WeCom (Wechat Work)
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Benutzername für Packagist

View file

@ -2293,9 +2293,9 @@ settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=Feishu / Lark Suite
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=Feishu / Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=WeCom (Wechat Work)
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Όνομα χρήστη Packagist

View file

@ -2372,9 +2372,9 @@ settings.web_hook_name_dingtalk = DingTalk
settings.web_hook_name_telegram = Telegram
settings.web_hook_name_matrix = Matrix
settings.web_hook_name_msteams = Microsoft Teams
settings.web_hook_name_feishu_or_larksuite = Feishu / Lark Suite
settings.web_hook_name_feishu = Feishu
settings.web_hook_name_larksuite = Lark Suite
settings.web_hook_name_feishu = Feishu / Lark Suite
settings.web_hook_name_feishu_only = Feishu
settings.web_hook_name_larksuite_only = Lark Suite
settings.web_hook_name_wechatwork = WeCom (Wechat Work)
settings.web_hook_name_packagist = Packagist
settings.packagist_username = Packagist username

View file

@ -2267,9 +2267,9 @@ settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=Feishu / Lark Suite
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=Feishu / Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=WeCom (Wechat Work)
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Nombre de usuario Packagist

View file

@ -1184,8 +1184,8 @@ settings.web_hook_name_discord=Discord
settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_packagist=Packagist
settings.deploy_keys=Julkaisuavaimet
settings.add_deploy_key=Lisää julkaisuavain

View file

@ -2317,9 +2317,9 @@ settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=Feishu / Lark Suite
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=Feishu / Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=WeCom (Wechat Work)
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Nom d'utilisateur Packagist

View file

@ -1065,7 +1065,7 @@ settings.web_hook_name_discord=Discord
settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_feishu_only =Feishu
settings.title=Heiti
settings.deploy_key_content=Innihald
settings.branches=Greinar

View file

@ -2085,9 +2085,9 @@ settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=Feishu / Lark Suite
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=Feishu / Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=WeCom (Wechat Work)
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Nome utente Packagist

View file

@ -2303,9 +2303,9 @@ settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=Feishu / Lark Suite
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=Feishu / Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=WeCom (Wechat Work)
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Packagist ユーザー名

View file

@ -2253,9 +2253,9 @@ settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=Feishu / Lark Suite
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=Feishu / Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=WeCom (Wechat Work)
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Packagist lietotājvārds

View file

@ -2032,9 +2032,9 @@ settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=Feishu / Lark Suite
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=Feishu / Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=WeCom (Wechat Work)
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Packagist gebruikersnaam

View file

@ -2236,9 +2236,9 @@ settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=Feishu / Lark Suite
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=Feishu / Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=WeCom (Wechat Work)
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Nome de usuário no Packagist

View file

@ -2269,9 +2269,9 @@ settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=Feishu / Lark Suite
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=Feishu / Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=WeCom (Wechat Work)
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Nome de utilizador no Packagist

View file

@ -2278,9 +2278,9 @@ settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=Feishu или Lark Suite
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=Feishu или Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=WeCom (Wechat Work)
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Имя пользователя Packagist

View file

@ -2252,9 +2252,9 @@ settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=Feishu / Lark Suite
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=Feishu / Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=WeCom (Wechat Work)
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Packagist kullanıcı adı

View file

@ -2318,9 +2318,9 @@ settings.web_hook_name_dingtalk=钉钉
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=飞书 / Lark Suite
settings.web_hook_name_feishu=飞书
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=飞书 / Lark Suite
settings.web_hook_name_feishu_only =飞书
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=企业微信
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Packagist 用户名

View file

@ -2071,9 +2071,9 @@ settings.web_hook_name_dingtalk=DingTalk
settings.web_hook_name_telegram=Telegram
settings.web_hook_name_matrix=Matrix
settings.web_hook_name_msteams=Microsoft Teams
settings.web_hook_name_feishu_or_larksuite=Feishu / Lark Suite
settings.web_hook_name_feishu=Feishu
settings.web_hook_name_larksuite=Lark Suite
settings.web_hook_name_feishu=Feishu / Lark Suite
settings.web_hook_name_feishu_only =Feishu
settings.web_hook_name_larksuite_only =Lark Suite
settings.web_hook_name_wechatwork=WeCom (Wechat Work)
settings.web_hook_name_packagist=Packagist
settings.packagist_username=Packagist 帳號

View file

@ -26,6 +26,7 @@ import (
org_service "code.gitea.io/gitea/services/org"
repo_service "code.gitea.io/gitea/services/repository"
user_service "code.gitea.io/gitea/services/user"
webhook_service "code.gitea.io/gitea/services/webhook"
)
const (
@ -210,6 +211,7 @@ func Webhooks(ctx *context.Context) {
ctx.Data["PageIsSettingsHooks"] = true
ctx.Data["BaseLink"] = ctx.Org.OrgLink + "/settings/hooks"
ctx.Data["BaseLinkNew"] = ctx.Org.OrgLink + "/settings/hooks"
ctx.Data["WebhookList"] = webhook_service.List()
ctx.Data["Description"] = ctx.Tr("org.settings.hooks_desc")
ws, err := db.Find[webhook.Webhook](ctx, webhook.ListWebhookOptions{OwnerID: ctx.Org.Organization.ID})

View file

@ -45,6 +45,7 @@ func WebhookList(ctx *context.Context) {
ctx.Data["PageIsSettingsHooks"] = true
ctx.Data["BaseLink"] = ctx.Repo.RepoLink + "/settings/hooks"
ctx.Data["BaseLinkNew"] = ctx.Repo.RepoLink + "/settings/hooks"
ctx.Data["WebhookList"] = webhook_service.List()
ctx.Data["Description"] = ctx.Tr("repo.settings.hooks_desc", "https://forgejo.org/docs/latest/user/webhooks/")
ws, err := db.Find[webhook.Webhook](ctx, webhook.ListWebhookOptions{RepoID: ctx.Repo.Repository.ID})
@ -139,6 +140,7 @@ func WebhookNew(ctx *context.Context) {
ctx.Data["HookType"] = hookType
ctx.Data["BaseLink"] = orCtx.LinkNew
ctx.Data["BaseLinkNew"] = orCtx.LinkNew
ctx.Data["WebhookList"] = webhook_service.List()
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
}
@ -202,6 +204,7 @@ func WebhookCreate(ctx *context.Context) {
}
ctx.Data["BaseLink"] = orCtx.LinkNew
ctx.Data["BaseLinkNew"] = orCtx.LinkNew
ctx.Data["WebhookList"] = webhook_service.List()
if ctx.HasError() {
// pre-fill the form with the submitted data
@ -336,6 +339,7 @@ func checkWebhook(ctx *context.Context) (*ownerRepoCtx, *webhook.Webhook) {
}
ctx.Data["BaseLink"] = orCtx.Link
ctx.Data["BaseLinkNew"] = orCtx.LinkNew
ctx.Data["WebhookList"] = webhook_service.List()
var w *webhook.Webhook
if orCtx.RepoID > 0 {

View file

@ -11,6 +11,7 @@ import (
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/services/context"
webhook_service "code.gitea.io/gitea/services/webhook"
)
const (
@ -23,6 +24,7 @@ func Webhooks(ctx *context.Context) {
ctx.Data["PageIsSettingsHooks"] = true
ctx.Data["BaseLink"] = setting.AppSubURL + "/user/settings/hooks"
ctx.Data["BaseLinkNew"] = setting.AppSubURL + "/user/settings/hooks"
ctx.Data["WebhookList"] = webhook_service.List()
ctx.Data["Description"] = ctx.Tr("settings.hooks.desc")
ws, err := db.Find[webhook.Webhook](ctx, webhook.ListWebhookOptions{OwnerID: ctx.Doer.ID})

View file

@ -3,52 +3,10 @@
{{$size = .Size}}
{{end}}
<div class="menu">
<a class="item" href="{{.BaseLinkNew}}/forgejo/new">
{{template "shared/webhook/icon" (dict "HookType" "forgejo" "Size" $size)}}
{{ctx.Locale.Tr "repo.settings.web_hook_name_forgejo"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/gitea/new">
{{template "shared/webhook/icon" (dict "HookType" "gitea" "Size" $size)}}
{{ctx.Locale.Tr "repo.settings.web_hook_name_gitea"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/gogs/new">
{{template "shared/webhook/icon" (dict "HookType" "gogs" "Size" $size)}}
{{ctx.Locale.Tr "repo.settings.web_hook_name_gogs"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/slack/new">
{{template "shared/webhook/icon" (dict "HookType" "slack" "Size" $size)}}
{{ctx.Locale.Tr "repo.settings.web_hook_name_slack"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/discord/new">
{{template "shared/webhook/icon" (dict "HookType" "discord" "Size" $size)}}
{{ctx.Locale.Tr "repo.settings.web_hook_name_discord"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/dingtalk/new">
{{template "shared/webhook/icon" (dict "HookType" "dingtalk" "Size" $size)}}
{{ctx.Locale.Tr "repo.settings.web_hook_name_dingtalk"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/telegram/new">
{{template "shared/webhook/icon" (dict "HookType" "telegram" "Size" $size)}}
{{ctx.Locale.Tr "repo.settings.web_hook_name_telegram"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/msteams/new">
{{template "shared/webhook/icon" (dict "HookType" "msteams" "Size" $size)}}
{{ctx.Locale.Tr "repo.settings.web_hook_name_msteams"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/feishu/new">
{{template "shared/webhook/icon" (dict "HookType" "feishu" "Size" $size)}}
{{ctx.Locale.Tr "repo.settings.web_hook_name_feishu_or_larksuite"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/matrix/new">
{{template "shared/webhook/icon" (dict "HookType" "matrix" "Size" $size)}}
{{ctx.Locale.Tr "repo.settings.web_hook_name_matrix"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/wechatwork/new">
{{template "shared/webhook/icon" (dict "HookType" "wechatwork" "Size" $size)}}
{{ctx.Locale.Tr "repo.settings.web_hook_name_wechatwork"}}
</a>
<a class="item" href="{{.BaseLinkNew}}/packagist/new">
{{template "shared/webhook/icon" (dict "HookType" "packagist" "Size" $size)}}
{{ctx.Locale.Tr "repo.settings.web_hook_name_packagist"}}
{{range .WebhookList}}
<a class="item" href="{{$.BaseLinkNew}}/{{.Type}}/new">
{{.Icon $size}}
{{ctx.Locale.Tr (print "repo.settings.web_hook_name_" .Type)}}
</a>
{{end}}
</div>

View file

@ -1,5 +1,5 @@
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://feishu.cn" (ctx.Locale.Tr "repo.settings.web_hook_name_feishu")}}</p>
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://larksuite.com" (ctx.Locale.Tr "repo.settings.web_hook_name_larksuite")}}</p>
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://feishu.cn" (ctx.Locale.Tr "repo.settings.web_hook_name_feishu_only")}}</p>
<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://larksuite.com" (ctx.Locale.Tr "repo.settings.web_hook_name_larksuite_only")}}</p>
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "feishu/new"}}" method="post">
{{.CsrfTokenHtml}}
<div class="required field {{if .Err_PayloadURL}}error{{end}}">