diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-10-11 10:27:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-10-11 10:27:00 +0000 |
commit | 65aa53fc52ff15efe54df4147564828d535837f8 (patch) | |
tree | 31c51dad04fdcca80e6d3043c8bd49d2f1a51f83 /templates/webhook | |
parent | Initial commit. (diff) | |
download | forgejo-65aa53fc52ff15efe54df4147564828d535837f8.tar.xz forgejo-65aa53fc52ff15efe54df4147564828d535837f8.zip |
Adding upstream version 8.0.3.HEADupstream/8.0.3upstreamdebian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | templates/webhook/new.tmpl | 44 | ||||
-rw-r--r-- | templates/webhook/new/dingtalk.tmpl | 9 | ||||
-rw-r--r-- | templates/webhook/new/discord.tmpl | 17 | ||||
-rw-r--r-- | templates/webhook/new/feishu.tmpl | 10 | ||||
-rw-r--r-- | templates/webhook/new/forgejo.tmpl | 38 | ||||
-rw-r--r-- | templates/webhook/new/gitea.tmpl | 38 | ||||
-rw-r--r-- | templates/webhook/new/gogs.tmpl | 26 | ||||
-rw-r--r-- | templates/webhook/new/matrix.tmpl | 32 | ||||
-rw-r--r-- | templates/webhook/new/msteams.tmpl | 9 | ||||
-rw-r--r-- | templates/webhook/new/packagist.tmpl | 17 | ||||
-rw-r--r-- | templates/webhook/new/slack.tmpl | 26 | ||||
-rw-r--r-- | templates/webhook/new/sourcehut_builds.tmpl | 39 | ||||
-rw-r--r-- | templates/webhook/new/telegram.tmpl | 17 | ||||
-rw-r--r-- | templates/webhook/new/wechatwork.tmpl | 9 | ||||
-rw-r--r-- | templates/webhook/shared-settings.tmpl | 289 |
15 files changed, 620 insertions, 0 deletions
diff --git a/templates/webhook/new.tmpl b/templates/webhook/new.tmpl new file mode 100644 index 00000000..a3fd8965 --- /dev/null +++ b/templates/webhook/new.tmpl @@ -0,0 +1,44 @@ +<h4 class="ui top attached header"> + {{.CustomHeaderTitle}} + <div class="ui right type dropdown"> + <div class="text tw-flex tw-items-center"> + {{.ctxData.WebhookHandler.Icon 20}} + {{ctx.Locale.Tr (print "repo.settings.web_hook_name_" .ctxData.HookType)}} + </div> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + {{template "repo/settings/webhook/link_menu" .ctxData}} + </div> +</h4> +<div class="ui attached segment"> + {{with .ctxData}} + <!-- the template argument cannot be dynamic --> + {{if eq .HookType "forgejo"}} + {{template "webhook/new/forgejo" .}} + {{else if eq .HookType "gitea"}} + {{template "webhook/new/gitea" .}} + {{else if eq .HookType "gogs"}} + {{template "webhook/new/gogs" .}} + {{else if eq .HookType "slack"}} + {{template "webhook/new/slack" .}} + {{else if eq .HookType "discord"}} + {{template "webhook/new/discord" .}} + {{else if eq .HookType "dingtalk"}} + {{template "webhook/new/dingtalk" .}} + {{else if eq .HookType "telegram"}} + {{template "webhook/new/telegram" .}} + {{else if eq .HookType "msteams"}} + {{template "webhook/new/msteams" .}} + {{else if eq .HookType "feishu"}} + {{template "webhook/new/feishu" .}} + {{else if eq .HookType "matrix"}} + {{template "webhook/new/matrix" .}} + {{else if eq .HookType "wechatwork"}} + {{template "webhook/new/wechatwork" .}} + {{else if eq .HookType "packagist"}} + {{template "webhook/new/packagist" .}} + {{else if eq .HookType "sourcehut_builds"}} + {{template "webhook/new/sourcehut_builds" .}} + {{end}} + {{end}} +</div> +{{template "repo/settings/webhook/history" .ctxData}} diff --git a/templates/webhook/new/dingtalk.tmpl b/templates/webhook/new/dingtalk.tmpl new file mode 100644 index 00000000..e805eadc --- /dev/null +++ b/templates/webhook/new/dingtalk.tmpl @@ -0,0 +1,9 @@ +<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://dingtalk.com" (ctx.Locale.Tr "repo.settings.web_hook_name_dingtalk")}}</p> +<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "dingtalk/new"}}" method="post"> + {{.CsrfTokenHtml}} + <div class="required field {{if .Err_PayloadURL}}error{{end}}"> + <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label> + <input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> + </div> + {{template "webhook/shared-settings" .}} +</form> diff --git a/templates/webhook/new/discord.tmpl b/templates/webhook/new/discord.tmpl new file mode 100644 index 00000000..48ac84fc --- /dev/null +++ b/templates/webhook/new/discord.tmpl @@ -0,0 +1,17 @@ +<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://discord.com" (ctx.Locale.Tr "repo.settings.web_hook_name_discord")}}</p> +<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "discord/new"}}" method="post"> + {{.CsrfTokenHtml}} + <div class="required field {{if .Err_PayloadURL}}error{{end}}"> + <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label> + <input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> + </div> + <div class="field"> + <label for="username">{{ctx.Locale.Tr "repo.settings.discord_username"}}</label> + <input id="username" name="username" value="{{.HookMetadata.Username}}" placeholder="Forgejo"> + </div> + <div class="field"> + <label for="icon_url">{{ctx.Locale.Tr "repo.settings.discord_icon_url"}}</label> + <input id="icon_url" name="icon_url" value="{{.HookMetadata.IconURL}}" placeholder="https://example.com/assets/img/logo.svg"> + </div> + {{template "webhook/shared-settings" .}} +</form> diff --git a/templates/webhook/new/feishu.tmpl b/templates/webhook/new/feishu.tmpl new file mode 100644 index 00000000..10c2827d --- /dev/null +++ b/templates/webhook/new/feishu.tmpl @@ -0,0 +1,10 @@ +<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}}"> + <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label> + <input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> + </div> + {{template "webhook/shared-settings" .}} +</form> diff --git a/templates/webhook/new/forgejo.tmpl b/templates/webhook/new/forgejo.tmpl new file mode 100644 index 00000000..cdb33346 --- /dev/null +++ b/templates/webhook/new/forgejo.tmpl @@ -0,0 +1,38 @@ +<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://forgejo.org/docs/latest/user/webhooks/" (ctx.Locale.Tr "repo.settings.web_hook_name_forgejo")}}</p> +<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "forgejo/new"}}" method="post"> + {{template "base/disable_form_autofill"}} + {{.CsrfTokenHtml}} + <div class="required field {{if .Err_PayloadURL}}error{{end}}"> + <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label> + <input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> + </div> + <div class="field"> + <label>{{ctx.Locale.Tr "repo.settings.http_method"}}</label> + <div class="ui selection dropdown"> + <input type="hidden" id="http_method" name="http_method" value="{{if .Webhook.HTTPMethod}}{{.Webhook.HTTPMethod}}{{else}}POST{{end}}"> + <div class="default text"></div> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item" data-value="POST">POST</div> + <div class="item" data-value="GET">GET</div> + </div> + </div> + </div> + <div class="field"> + <label>{{ctx.Locale.Tr "repo.settings.content_type"}}</label> + <div class="ui selection dropdown"> + <input type="hidden" id="content_type" name="content_type" value="{{if .Webhook.ContentType}}{{.Webhook.ContentType}}{{else}}1{{end}}"> + <div class="default text"></div> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item" data-value="1">application/json</div> + <div class="item" data-value="2">application/x-www-form-urlencoded</div> + </div> + </div> + </div> + <div class="field {{if .Err_Secret}}error{{end}}"> + <label for="secret">{{ctx.Locale.Tr "repo.settings.secret"}}</label> + <input id="secret" name="secret" type="password" value="{{.Webhook.Secret}}" autocomplete="off"> + </div> + {{template "webhook/shared-settings" .}} +</form> diff --git a/templates/webhook/new/gitea.tmpl b/templates/webhook/new/gitea.tmpl new file mode 100644 index 00000000..3926370b --- /dev/null +++ b/templates/webhook/new/gitea.tmpl @@ -0,0 +1,38 @@ +<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://forgejo.org/docs/latest/user/webhooks/" (ctx.Locale.Tr "repo.settings.web_hook_name_gitea")}}</p> +<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "gitea/new"}}" method="post"> + {{template "base/disable_form_autofill"}} + {{.CsrfTokenHtml}} + <div class="required field {{if .Err_PayloadURL}}error{{end}}"> + <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label> + <input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> + </div> + <div class="field"> + <label>{{ctx.Locale.Tr "repo.settings.http_method"}}</label> + <div class="ui selection dropdown"> + <input type="hidden" id="http_method" name="http_method" value="{{if .Webhook.HTTPMethod}}{{.Webhook.HTTPMethod}}{{else}}POST{{end}}"> + <div class="default text"></div> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item" data-value="POST">POST</div> + <div class="item" data-value="GET">GET</div> + </div> + </div> + </div> + <div class="field"> + <label>{{ctx.Locale.Tr "repo.settings.content_type"}}</label> + <div class="ui selection dropdown"> + <input type="hidden" id="content_type" name="content_type" value="{{if .Webhook.ContentType}}{{.Webhook.ContentType}}{{else}}1{{end}}"> + <div class="default text"></div> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item" data-value="1">application/json</div> + <div class="item" data-value="2">application/x-www-form-urlencoded</div> + </div> + </div> + </div> + <div class="field {{if .Err_Secret}}error{{end}}"> + <label for="secret">{{ctx.Locale.Tr "repo.settings.secret"}}</label> + <input id="secret" name="secret" type="password" value="{{.Webhook.Secret}}" autocomplete="off"> + </div> + {{template "webhook/shared-settings" .}} +</form> diff --git a/templates/webhook/new/gogs.tmpl b/templates/webhook/new/gogs.tmpl new file mode 100644 index 00000000..5b6cd723 --- /dev/null +++ b/templates/webhook/new/gogs.tmpl @@ -0,0 +1,26 @@ +<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://forgejo.org/docs/latest/user/webhooks/" (ctx.Locale.Tr "repo.settings.web_hook_name_gogs")}}</p> +<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "gogs/new"}}" method="post"> + {{template "base/disable_form_autofill"}} + {{.CsrfTokenHtml}} + <div class="required field {{if .Err_PayloadURL}}error{{end}}"> + <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label> + <input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> + </div> + <div class="field"> + <label>{{ctx.Locale.Tr "repo.settings.content_type"}}</label> + <div class="ui selection dropdown"> + <input type="hidden" id="content_type" name="content_type" value="{{if .Webhook.ContentType}}{{.Webhook.ContentType}}{{else}}1{{end}}"> + <div class="default text"></div> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item" data-value="1">application/json</div> + <div class="item" data-value="2">application/x-www-form-urlencoded</div> + </div> + </div> + </div> + <div class="field {{if .Err_Secret}}error{{end}}"> + <label for="secret">{{ctx.Locale.Tr "repo.settings.secret"}}</label> + <input id="secret" name="secret" type="password" value="{{.Webhook.Secret}}" autocomplete="off"> + </div> + {{template "webhook/shared-settings" .}} +</form> diff --git a/templates/webhook/new/matrix.tmpl b/templates/webhook/new/matrix.tmpl new file mode 100644 index 00000000..920180d4 --- /dev/null +++ b/templates/webhook/new/matrix.tmpl @@ -0,0 +1,32 @@ +<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://matrix.org/" (ctx.Locale.Tr "repo.settings.web_hook_name_matrix")}}</p> +<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "matrix/new"}}" method="post"> + {{.CsrfTokenHtml}} + <div class="required field {{if .Err_HomeserverURL}}error{{end}}"> + <label for="homeserver_url">{{ctx.Locale.Tr "repo.settings.matrix.homeserver_url"}}</label> + <input id="homeserver_url" name="homeserver_url" type="url" value="{{.HookMetadata.HomeserverURL}}" autofocus required> + </div> + <!-- Access Token --> + <div class="field required {{if .Err_AccessToken}}error{{end}}"> + <label for="access_token">{{ctx.Locale.Tr "form.AccessToken"}}</label> + <input id="access_token" name="access_token" type="password" value="{{.Webhook.HeaderAuthorizationTrimPrefix "Bearer "}}" required> + <span class="help">{{ctx.Locale.Tr "repo.settings.matrix.access_token_helper"}}</span> + </div> + <div class="required field {{if .Err_Room}}error{{end}}"> + <label for="room_id">{{ctx.Locale.Tr "repo.settings.matrix.room_id"}}</label> + <input id="room_id" name="room_id" type="text" value="{{.HookMetadata.Room}}" placeholder="!opaque_id:domain" pattern="^!.+:.+$" maxlength="255" required> + <span class="help">{{ctx.Locale.Tr "repo.settings.matrix.room_id_helper" ("<code>!opaque_id:example.org</code>"|SafeHTML)}}</span> + </div> + <div class="field"> + <label>{{ctx.Locale.Tr "repo.settings.matrix.message_type"}}</label> + <div class="ui selection dropdown"> + <input type="hidden" id="message_type" name="message_type" value="{{if .HookMetadata.MessageType}}{{.HookMetadata.MessageType}}{{else}}1{{end}}"> + <div class="default text"></div> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item" data-value="1">m.notice</div> + <div class="item" data-value="2">m.text</div> + </div> + </div> + </div> + {{template "webhook/shared-settings" .}} +</form> diff --git a/templates/webhook/new/msteams.tmpl b/templates/webhook/new/msteams.tmpl new file mode 100644 index 00000000..535d0fc3 --- /dev/null +++ b/templates/webhook/new/msteams.tmpl @@ -0,0 +1,9 @@ +<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://teams.microsoft.com" (ctx.Locale.Tr "repo.settings.web_hook_name_msteams")}}</p> +<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "msteams/new"}}" method="post"> + {{.CsrfTokenHtml}} + <div class="required field {{if .Err_PayloadURL}}error{{end}}"> + <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label> + <input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> + </div> + {{template "webhook/shared-settings" .}} +</form> diff --git a/templates/webhook/new/packagist.tmpl b/templates/webhook/new/packagist.tmpl new file mode 100644 index 00000000..04240bbf --- /dev/null +++ b/templates/webhook/new/packagist.tmpl @@ -0,0 +1,17 @@ +<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://packagist.org" (ctx.Locale.Tr "repo.settings.web_hook_name_packagist")}}</p> +<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "packagist/new"}}" method="post"> + {{.CsrfTokenHtml}} + <div class="required field {{if .Err_Username}}error{{end}}"> + <label for="username">{{ctx.Locale.Tr "repo.settings.packagist_username"}}</label> + <input id="username" name="username" value="{{.HookMetadata.Username}}" placeholder="Forgejo" autofocus required> + </div> + <div class="required field {{if .Err_APIToken}}error{{end}}"> + <label for="api_token">{{ctx.Locale.Tr "repo.settings.packagist_api_token"}}</label> + <input id="api_token" name="api_token" value="{{.HookMetadata.APIToken}}" placeholder="X5F_tZ-Wj3c1vqaU2Rky" required> + </div> + <div class="required field {{if .Err_PackageURL}}error{{end}}"> + <label for="package_url">{{ctx.Locale.Tr "repo.settings.packagist_package_url"}}</label> + <input id="package_url" name="package_url" value="{{.HookMetadata.PackageURL}}" placeholder="https://packagist.org/packages/laravel/framework" required> + </div> + {{template "webhook/shared-settings" .}} +</form> diff --git a/templates/webhook/new/slack.tmpl b/templates/webhook/new/slack.tmpl new file mode 100644 index 00000000..cfaeb41f --- /dev/null +++ b/templates/webhook/new/slack.tmpl @@ -0,0 +1,26 @@ +<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://slack.com" (ctx.Locale.Tr "repo.settings.web_hook_name_slack")}}</p> +<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "slack/new"}}" method="post"> + {{.CsrfTokenHtml}} + <div class="required field {{if .Err_PayloadURL}}error{{end}}"> + <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label> + <input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> + </div> + <div class="required field {{if .Err_Channel}}error{{end}}"> + <label for="channel">{{ctx.Locale.Tr "repo.settings.slack_channel"}}</label> + <input id="channel" name="channel" value="{{.HookMetadata.Channel}}" placeholder="#general" required> + </div> + + <div class="field"> + <label for="username">{{ctx.Locale.Tr "repo.settings.slack_username"}}</label> + <input id="username" name="username" value="{{.HookMetadata.Username}}" placeholder="Forgejo"> + </div> + <div class="field"> + <label for="icon_url">{{ctx.Locale.Tr "repo.settings.slack_icon_url"}}</label> + <input id="icon_url" name="icon_url" value="{{.HookMetadata.IconURL}}" placeholder="https://example.com/img/favicon.png"> + </div> + <div class="field"> + <label for="color">{{ctx.Locale.Tr "repo.settings.slack_color"}}</label> + <input id="color" name="color" value="{{.HookMetadata.Color}}" placeholder="#dd4b39, good, warning, danger"> + </div> + {{template "webhook/shared-settings" .}} +</form> diff --git a/templates/webhook/new/sourcehut_builds.tmpl b/templates/webhook/new/sourcehut_builds.tmpl new file mode 100644 index 00000000..3bcbe1bf --- /dev/null +++ b/templates/webhook/new/sourcehut_builds.tmpl @@ -0,0 +1,39 @@ +<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://sourcehut.org/" (ctx.Locale.Tr "repo.settings.web_hook_name_sourcehut_builds")}}</p> +<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "sourcehut_builds/new"}}" method="post"> + {{.CsrfTokenHtml}} + <div class="required field {{if .Err_PayloadURL}}error{{end}}"> + <label for="payload_url">{{ctx.Locale.Tr "repo.settings.graphql_url"}}</label> + <input id="payload_url" name="payload_url" type="url" value="{{or .Webhook.URL "https://builds.sr.ht/query"}}" autofocus required> + </div> + <div class="required field {{if .Err_ManifestPath}}error{{end}}"> + <label for="manifest_path">{{ctx.Locale.Tr "repo.settings.sourcehut_builds.manifest_path"}}</label> + <input id="manifest_path" name="manifest_path" type="text" value="{{or .HookMetadata.ManifestPath ".build.yml"}}" required> + </div> + <div class="field"> + <label>{{ctx.Locale.Tr "repo.settings.sourcehut_builds.visibility"}}</label> + <div class="ui selection dropdown"> + <input type="hidden" id="visibility" name="visibility" value="{{if .HookMetadata.Visibility}}{{.HookMetadata.Visibility}}{{else}}PRIVATE{{end}}"> + <div class="default text"></div> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item" data-value="PUBLIC">PUBLIC</div> + <div class="item" data-value="UNLISTED">UNLISTED</div> + <div class="item" data-value="PRIVATE">PRIVATE</div> + </div> + </div> + </div> + <div class="field"> + <div class="ui checkbox"> + <input name="secrets" type="checkbox" {{if .HookMetadata.Secrets}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.sourcehut_builds.secrets"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.sourcehut_builds.secrets_helper"}}</span> + </div> + </div> + <!-- Access Token --> + <div class="field required {{if .Err_AccessToken}}error{{end}}"> + <label for="access_token">{{ctx.Locale.Tr "form.AccessToken"}}</label> + <input id="access_token" name="access_token" type="password" value="{{.Webhook.HeaderAuthorizationTrimPrefix "Bearer "}}" required> + <span class="help">{{ctx.Locale.Tr "repo.settings.sourcehut_builds.access_token_helper" "https://meta.sr.ht/oauth2/personal-token?grants=builds.sr.ht/JOBS:RW" "https://meta.sr.ht/oauth2/personal-token?grants=builds.sr.ht/JOBS:RW+builds.sr.ht/SECRETS:RO"}}</span> + </div> + {{template "webhook/shared-settings" .}} +</form> diff --git a/templates/webhook/new/telegram.tmpl b/templates/webhook/new/telegram.tmpl new file mode 100644 index 00000000..3627dff3 --- /dev/null +++ b/templates/webhook/new/telegram.tmpl @@ -0,0 +1,17 @@ +<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://core.telegram.org/bots" (ctx.Locale.Tr "repo.settings.web_hook_name_telegram")}}</p> +<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "telegram/new"}}" method="post"> + {{.CsrfTokenHtml}} + <div class="required field {{if .Err_BotToken}}error{{end}}"> + <label for="bot_token">{{ctx.Locale.Tr "repo.settings.bot_token"}}</label> + <input id="bot_token" name="bot_token" type="text" value="{{.HookMetadata.BotToken}}" autofocus required> + </div> + <div class="required field {{if .Err_ChatID}}error{{end}}"> + <label for="chat_id">{{ctx.Locale.Tr "repo.settings.chat_id"}}</label> + <input id="chat_id" name="chat_id" type="text" value="{{.HookMetadata.ChatID}}" required> + </div> + <div class="field {{if .Err_ThreadID}}error{{end}}"> + <label for="thread_id">{{ctx.Locale.Tr "repo.settings.thread_id"}}</label> + <input id="thread_id" name="thread_id" type="text" value="{{.HookMetadata.ThreadID}}"> + </div> + {{template "webhook/shared-settings" .}} +</form> diff --git a/templates/webhook/new/wechatwork.tmpl b/templates/webhook/new/wechatwork.tmpl new file mode 100644 index 00000000..ae9d36a7 --- /dev/null +++ b/templates/webhook/new/wechatwork.tmpl @@ -0,0 +1,9 @@ +<p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://work.weixin.qq.com" (ctx.Locale.Tr "repo.settings.web_hook_name_wechatwork")}}</p> +<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "wechatwork/new"}}" method="post"> + {{.CsrfTokenHtml}} + <div class="required field {{if .Err_PayloadURL}}error{{end}}"> + <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label> + <input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> + </div> + {{template "webhook/shared-settings" .}} +</form> diff --git a/templates/webhook/shared-settings.tmpl b/templates/webhook/shared-settings.tmpl new file mode 100644 index 00000000..80caad72 --- /dev/null +++ b/templates/webhook/shared-settings.tmpl @@ -0,0 +1,289 @@ +{{$isNew:=or .PageIsSettingsHooksNew .PageIsAdminDefaultHooksNew .PageIsAdminSystemHooksNew}} +<div class="field"> + <h4>{{ctx.Locale.Tr "repo.settings.event_desc"}}</h4> + <div class="grouped event type fields"> + <div class="field"> + <div class="ui radio non-events checkbox"> + <input name="events" type="radio" value="push_only" {{if or $isNew .Webhook.PushOnly}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_push_only"}}</label> + </div> + </div> + <div class="field"> + <div class="ui radio non-events checkbox"> + <input name="events" type="radio" value="send_everything" {{if .Webhook.SendEverything}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_send_everything"}}</label> + </div> + </div> + <div class="field"> + <div class="ui radio events checkbox"> + <input name="events" type="radio" value="choose_events" {{if .Webhook.ChooseEvents}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_choose"}}</label> + </div> + </div> + </div> + + <div class="events fields ui grid {{if not .Webhook.ChooseEvents}}tw-hidden{{end}}"> + <!-- Repository Events --> + <div class="fourteen wide column"> + <label>{{ctx.Locale.Tr "repo.settings.event_header_repository"}}</label> + </div> + <!-- Create --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="create" type="checkbox" {{if .Webhook.Create}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_create"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_create_desc"}}</span> + </div> + </div> + </div> + <!-- Delete --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="delete" type="checkbox" {{if .Webhook.Delete}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_delete"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_delete_desc"}}</span> + </div> + </div> + </div> + <!-- Fork --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="fork" type="checkbox" {{if .Webhook.Fork}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_fork"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_fork_desc"}}</span> + </div> + </div> + </div> + <!-- Push --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="push" type="checkbox" {{if .Webhook.Push}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_push"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_push_desc"}}</span> + </div> + </div> + </div> + <!-- Repository --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="repository" type="checkbox" {{if .Webhook.Repository}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_repository"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_repository_desc"}}</span> + </div> + </div> + </div> + <!-- Release --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="release" type="checkbox" {{if .Webhook.Release}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_release"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_release_desc"}}</span> + </div> + </div> + </div> + <!-- Package --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="package" type="checkbox" {{if .Webhook.Package}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_package"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_package_desc"}}</span> + </div> + </div> + </div> + + <!-- Wiki --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="wiki" type="checkbox" {{if .Webhook.Wiki}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_wiki"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_wiki_desc"}}</span> + </div> + </div> + </div> + + <!-- Issue Events --> + <div class="fourteen wide column"> + <label>{{ctx.Locale.Tr "repo.settings.event_header_issue"}}</label> + </div> + <!-- Issues --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="issues" type="checkbox" {{if .Webhook.Issues}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_issues"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_issues_desc"}}</span> + </div> + </div> + </div> + <!-- Issue Assign --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="issue_assign" type="checkbox" {{if .Webhook.IssueAssign}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_issue_assign"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_issue_assign_desc"}}</span> + </div> + </div> + </div> + <!-- Issue Label --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="issue_label" type="checkbox" {{if .Webhook.IssueLabel}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_issue_label"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_issue_label_desc"}}</span> + </div> + </div> + </div> + <!-- Issue Milestone --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="issue_milestone" type="checkbox" {{if .Webhook.IssueMilestone}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_issue_milestone"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_issue_milestone_desc"}}</span> + </div> + </div> + </div> + <!-- Issue Comment --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="issue_comment" type="checkbox" {{if .Webhook.IssueComment}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_issue_comment"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_issue_comment_desc"}}</span> + </div> + </div> + </div> + + <!-- Pull Request Events --> + <div class="fourteen wide column"> + <label>{{ctx.Locale.Tr "repo.settings.event_header_pull_request"}}</label> + </div> + <!-- Pull Request --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="pull_request" type="checkbox" {{if .Webhook.PullRequest}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_pull_request"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_desc"}}</span> + </div> + </div> + </div> + <!-- Pull Request Assign --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="pull_request_assign" type="checkbox" {{if .Webhook.PullRequestAssign}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_pull_request_assign"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_assign_desc"}}</span> + </div> + </div> + </div> + <!-- Pull Request Label --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="pull_request_label" type="checkbox" {{if .Webhook.PullRequestLabel}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_pull_request_label"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_label_desc"}}</span> + </div> + </div> + </div> + <!-- Pull Request Milestone --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="pull_request_milestone" type="checkbox" {{if .Webhook.PullRequestMilestone}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_pull_request_milestone"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_milestone_desc"}}</span> + </div> + </div> + </div> + <!-- Pull Request Comment --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="pull_request_comment" type="checkbox" {{if .Webhook.PullRequestComment}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_pull_request_comment"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_comment_desc"}}</span> + </div> + </div> + </div> + <!-- Pull Request Review --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="pull_request_review" type="checkbox" {{if .Webhook.PullRequestReview}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_pull_request_review"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_review_desc"}}</span> + </div> + </div> + </div> + <!-- Pull Request Sync --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="pull_request_sync" type="checkbox" {{if .Webhook.PullRequestSync}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_pull_request_sync"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_sync_desc"}}</span> + </div> + </div> + </div> + <!-- Pull Request Review Request --> + <div class="seven wide column"> + <div class="field"> + <div class="ui checkbox"> + <input name="pull_request_review_request" type="checkbox" {{if .Webhook.PullRequestReviewRequest}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.event_pull_request_review_request"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.event_pull_request_review_request_desc"}}</span> + </div> + </div> + </div> + </div> +</div> + +<!-- Branch filter --> +<div class="field"> + <label for="branch_filter">{{ctx.Locale.Tr "repo.settings.branch_filter"}}</label> + <input id="branch_filter" name="branch_filter" type="text" value="{{or .Webhook.BranchFilter "*"}}"> + <span class="help">{{ctx.Locale.Tr "repo.settings.branch_filter_desc"}}</span> +</div> + +{{$skipAuthorizationHeader := or (eq .HookType "sourcehut_builds") (eq .HookType "matrix")}} +{{if not $skipAuthorizationHeader}} + <!-- Authorization Header --> + <div class="field {{if .Err_AuthorizationHeader}}error{{end}}"> + <label for="authorization_header">{{ctx.Locale.Tr "repo.settings.authorization_header"}}</label> + <input id="authorization_header" name="authorization_header" type="text" value="{{.Webhook.HeaderAuthorization}}"> + <span class="help">{{ctx.Locale.Tr "repo.settings.authorization_header_desc" ("<code>Bearer token123456</code>, <code>Basic YWxhZGRpbjpvcGVuc2VzYW1l</code>" | SafeHTML)}}</span> + </div> +{{end}} + +<div class="divider"></div> + +<div class="inline field"> + <div class="ui checkbox"> + <input name="active" type="checkbox" {{if or $isNew .Webhook.IsActive}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.active"}}</label> + <span class="help">{{ctx.Locale.Tr "repo.settings.active_helper"}}</span> + </div> +</div> +<div class="field"> + {{if $isNew}} + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.add_webhook"}}</button> + {{else}} + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_webhook"}}</button> + <a class="ui red delete-button button" data-url="{{.BaseLink}}/delete" data-id="{{.Webhook.ID}}">{{ctx.Locale.Tr "repo.settings.delete_webhook"}}</a> + {{end}} +</div> + +{{template "repo/settings/webhook/delete_modal" .}} |