[REFACTOR] webhook/new remove redundant if

This commit is contained in:
oliverpool 2024-03-22 11:52:39 +01:00
parent 9558b18d22
commit be6434662a
12 changed files with 228 additions and 252 deletions

View file

@ -1,11 +1,9 @@
{{if eq .HookType "dingtalk"}} <p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://dingtalk.com" (ctx.Locale.Tr "repo.settings.web_hook_name_dingtalk")}}</p>
<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">
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "dingtalk/new"}}" method="post"> {{.CsrfTokenHtml}}
{{.CsrfTokenHtml}} <div class="required field {{if .Err_PayloadURL}}error{{end}}">
<div class="required field {{if .Err_PayloadURL}}error{{end}}"> <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
<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>
<input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> </div>
</div> {{template "repo/settings/webhook/settings" .}}
{{template "repo/settings/webhook/settings" .}} </form>
</form>
{{end}}

View file

@ -1,19 +1,17 @@
{{if eq .HookType "discord"}} <p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://discord.com" (ctx.Locale.Tr "repo.settings.web_hook_name_discord")}}</p>
<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">
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "discord/new"}}" method="post"> {{.CsrfTokenHtml}}
{{.CsrfTokenHtml}} <div class="required field {{if .Err_PayloadURL}}error{{end}}">
<div class="required field {{if .Err_PayloadURL}}error{{end}}"> <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
<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>
<input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> </div>
</div> <div class="field">
<div class="field"> <label for="username">{{ctx.Locale.Tr "repo.settings.discord_username"}}</label>
<label for="username">{{ctx.Locale.Tr "repo.settings.discord_username"}}</label> <input id="username" name="username" value="{{.HookMetadata.Username}}" placeholder="Forgejo">
<input id="username" name="username" value="{{.HookMetadata.Username}}" placeholder="Forgejo"> </div>
</div> <div class="field">
<div class="field"> <label for="icon_url">{{ctx.Locale.Tr "repo.settings.discord_icon_url"}}</label>
<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">
<input id="icon_url" name="icon_url" value="{{.HookMetadata.IconURL}}" placeholder="https://example.com/assets/img/logo.svg"> </div>
</div> {{template "repo/settings/webhook/settings" .}}
{{template "repo/settings/webhook/settings" .}} </form>
</form>
{{end}}

View file

@ -1,12 +1,10 @@
{{if eq .HookType "feishu"}} <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://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://larksuite.com" (ctx.Locale.Tr "repo.settings.web_hook_name_larksuite")}}</p> <form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "feishu/new"}}" method="post">
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "feishu/new"}}" method="post"> {{.CsrfTokenHtml}}
{{.CsrfTokenHtml}} <div class="required field {{if .Err_PayloadURL}}error{{end}}">
<div class="required field {{if .Err_PayloadURL}}error{{end}}"> <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
<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>
<input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> </div>
</div> {{template "repo/settings/webhook/settings" .}}
{{template "repo/settings/webhook/settings" .}} </form>
</form>
{{end}}

View file

@ -1,40 +1,38 @@
{{if eq .HookType "forgejo"}} <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>
<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">
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "forgejo/new"}}" method="post"> {{template "base/disable_form_autofill"}}
{{template "base/disable_form_autofill"}} {{.CsrfTokenHtml}}
{{.CsrfTokenHtml}} <div class="required field {{if .Err_PayloadURL}}error{{end}}">
<div class="required field {{if .Err_PayloadURL}}error{{end}}"> <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
<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>
<input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> </div>
</div> <div class="field">
<div class="field"> <label>{{ctx.Locale.Tr "repo.settings.http_method"}}</label>
<label>{{ctx.Locale.Tr "repo.settings.http_method"}}</label> <div class="ui selection dropdown">
<div class="ui selection dropdown"> <input type="hidden" id="http_method" name="http_method" value="{{if .Webhook.HTTPMethod}}{{.Webhook.HTTPMethod}}{{else}}POST{{end}}">
<input type="hidden" id="http_method" name="http_method" value="{{if .Webhook.HTTPMethod}}{{.Webhook.HTTPMethod}}{{else}}POST{{end}}"> <div class="default text"></div>
<div class="default text"></div> {{svg "octicon-triangle-down" 14 "dropdown icon"}}
{{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu">
<div class="menu"> <div class="item" data-value="POST">POST</div>
<div class="item" data-value="POST">POST</div> <div class="item" data-value="GET">GET</div>
<div class="item" data-value="GET">GET</div>
</div>
</div> </div>
</div> </div>
<div class="field"> </div>
<label>{{ctx.Locale.Tr "repo.settings.content_type"}}</label> <div class="field">
<div class="ui selection dropdown"> <label>{{ctx.Locale.Tr "repo.settings.content_type"}}</label>
<input type="hidden" id="content_type" name="content_type" value="{{if .Webhook.ContentType}}{{.Webhook.ContentType}}{{else}}1{{end}}"> <div class="ui selection dropdown">
<div class="default text"></div> <input type="hidden" id="content_type" name="content_type" value="{{if .Webhook.ContentType}}{{.Webhook.ContentType}}{{else}}1{{end}}">
{{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="default text"></div>
<div class="menu"> {{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="item" data-value="1">application/json</div> <div class="menu">
<div class="item" data-value="2">application/x-www-form-urlencoded</div> <div class="item" data-value="1">application/json</div>
</div> <div class="item" data-value="2">application/x-www-form-urlencoded</div>
</div> </div>
</div> </div>
<div class="field {{if .Err_Secret}}error{{end}}"> </div>
<label for="secret">{{ctx.Locale.Tr "repo.settings.secret"}}</label> <div class="field {{if .Err_Secret}}error{{end}}">
<input id="secret" name="secret" type="password" value="{{.Webhook.Secret}}" autocomplete="off"> <label for="secret">{{ctx.Locale.Tr "repo.settings.secret"}}</label>
</div> <input id="secret" name="secret" type="password" value="{{.Webhook.Secret}}" autocomplete="off">
{{template "repo/settings/webhook/settings" .}} </div>
</form> {{template "repo/settings/webhook/settings" .}}
{{end}} </form>

View file

@ -1,40 +1,38 @@
{{if eq .HookType "gitea"}} <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>
<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">
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "gitea/new"}}" method="post"> {{template "base/disable_form_autofill"}}
{{template "base/disable_form_autofill"}} {{.CsrfTokenHtml}}
{{.CsrfTokenHtml}} <div class="required field {{if .Err_PayloadURL}}error{{end}}">
<div class="required field {{if .Err_PayloadURL}}error{{end}}"> <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
<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>
<input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> </div>
</div> <div class="field">
<div class="field"> <label>{{ctx.Locale.Tr "repo.settings.http_method"}}</label>
<label>{{ctx.Locale.Tr "repo.settings.http_method"}}</label> <div class="ui selection dropdown">
<div class="ui selection dropdown"> <input type="hidden" id="http_method" name="http_method" value="{{if .Webhook.HTTPMethod}}{{.Webhook.HTTPMethod}}{{else}}POST{{end}}">
<input type="hidden" id="http_method" name="http_method" value="{{if .Webhook.HTTPMethod}}{{.Webhook.HTTPMethod}}{{else}}POST{{end}}"> <div class="default text"></div>
<div class="default text"></div> {{svg "octicon-triangle-down" 14 "dropdown icon"}}
{{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu">
<div class="menu"> <div class="item" data-value="POST">POST</div>
<div class="item" data-value="POST">POST</div> <div class="item" data-value="GET">GET</div>
<div class="item" data-value="GET">GET</div>
</div>
</div> </div>
</div> </div>
<div class="field"> </div>
<label>{{ctx.Locale.Tr "repo.settings.content_type"}}</label> <div class="field">
<div class="ui selection dropdown"> <label>{{ctx.Locale.Tr "repo.settings.content_type"}}</label>
<input type="hidden" id="content_type" name="content_type" value="{{if .Webhook.ContentType}}{{.Webhook.ContentType}}{{else}}1{{end}}"> <div class="ui selection dropdown">
<div class="default text"></div> <input type="hidden" id="content_type" name="content_type" value="{{if .Webhook.ContentType}}{{.Webhook.ContentType}}{{else}}1{{end}}">
{{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="default text"></div>
<div class="menu"> {{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="item" data-value="1">application/json</div> <div class="menu">
<div class="item" data-value="2">application/x-www-form-urlencoded</div> <div class="item" data-value="1">application/json</div>
</div> <div class="item" data-value="2">application/x-www-form-urlencoded</div>
</div> </div>
</div> </div>
<div class="field {{if .Err_Secret}}error{{end}}"> </div>
<label for="secret">{{ctx.Locale.Tr "repo.settings.secret"}}</label> <div class="field {{if .Err_Secret}}error{{end}}">
<input id="secret" name="secret" type="password" value="{{.Webhook.Secret}}" autocomplete="off"> <label for="secret">{{ctx.Locale.Tr "repo.settings.secret"}}</label>
</div> <input id="secret" name="secret" type="password" value="{{.Webhook.Secret}}" autocomplete="off">
{{template "repo/settings/webhook/settings" .}} </div>
</form> {{template "repo/settings/webhook/settings" .}}
{{end}} </form>

View file

@ -1,28 +1,26 @@
{{if eq .HookType "gogs"}} <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>
<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">
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "gogs/new"}}" method="post"> {{template "base/disable_form_autofill"}}
{{template "base/disable_form_autofill"}} {{.CsrfTokenHtml}}
{{.CsrfTokenHtml}} <div class="required field {{if .Err_PayloadURL}}error{{end}}">
<div class="required field {{if .Err_PayloadURL}}error{{end}}"> <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
<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>
<input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> </div>
</div> <div class="field">
<div class="field"> <label>{{ctx.Locale.Tr "repo.settings.content_type"}}</label>
<label>{{ctx.Locale.Tr "repo.settings.content_type"}}</label> <div class="ui selection dropdown">
<div class="ui selection dropdown"> <input type="hidden" id="content_type" name="content_type" value="{{if .Webhook.ContentType}}{{.Webhook.ContentType}}{{else}}1{{end}}">
<input type="hidden" id="content_type" name="content_type" value="{{if .Webhook.ContentType}}{{.Webhook.ContentType}}{{else}}1{{end}}"> <div class="default text"></div>
<div class="default text"></div> {{svg "octicon-triangle-down" 14 "dropdown icon"}}
{{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu">
<div class="menu"> <div class="item" data-value="1">application/json</div>
<div class="item" data-value="1">application/json</div> <div class="item" data-value="2">application/x-www-form-urlencoded</div>
<div class="item" data-value="2">application/x-www-form-urlencoded</div>
</div>
</div> </div>
</div> </div>
<div class="field {{if .Err_Secret}}error{{end}}"> </div>
<label for="secret">{{ctx.Locale.Tr "repo.settings.secret"}}</label> <div class="field {{if .Err_Secret}}error{{end}}">
<input id="secret" name="secret" type="password" value="{{.Webhook.Secret}}" autocomplete="off"> <label for="secret">{{ctx.Locale.Tr "repo.settings.secret"}}</label>
</div> <input id="secret" name="secret" type="password" value="{{.Webhook.Secret}}" autocomplete="off">
{{template "repo/settings/webhook/settings" .}} </div>
</form> {{template "repo/settings/webhook/settings" .}}
{{end}} </form>

View file

@ -1,27 +1,25 @@
{{if eq .HookType "matrix"}} <p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://matrix.org/" (ctx.Locale.Tr "repo.settings.web_hook_name_matrix")}}</p>
<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">
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "matrix/new"}}" method="post"> {{.CsrfTokenHtml}}
{{.CsrfTokenHtml}} <div class="required field {{if .Err_HomeserverURL}}error{{end}}">
<div class="required field {{if .Err_HomeserverURL}}error{{end}}"> <label for="homeserver_url">{{ctx.Locale.Tr "repo.settings.matrix.homeserver_url"}}</label>
<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>
<input id="homeserver_url" name="homeserver_url" type="url" value="{{.HookMetadata.HomeserverURL}}" autofocus required> </div>
</div> <div class="required field {{if .Err_Room}}error{{end}}">
<div class="required field {{if .Err_Room}}error{{end}}"> <label for="room_id">{{ctx.Locale.Tr "repo.settings.matrix.room_id"}}</label>
<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}}" required>
<input id="room_id" name="room_id" type="text" value="{{.HookMetadata.Room}}" required> </div>
</div> <div class="field">
<div class="field"> <label>{{ctx.Locale.Tr "repo.settings.matrix.message_type"}}</label>
<label>{{ctx.Locale.Tr "repo.settings.matrix.message_type"}}</label> <div class="ui selection dropdown">
<div class="ui selection dropdown"> <input type="hidden" id="message_type" name="message_type" value="{{if .HookMetadata.MessageType}}{{.HookMetadata.MessageType}}{{else}}1{{end}}">
<input type="hidden" id="message_type" name="message_type" value="{{if .HookMetadata.MessageType}}{{.HookMetadata.MessageType}}{{else}}1{{end}}"> <div class="default text"></div>
<div class="default text"></div> {{svg "octicon-triangle-down" 14 "dropdown icon"}}
{{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu">
<div class="menu"> <div class="item" data-value="1">m.notice</div>
<div class="item" data-value="1">m.notice</div> <div class="item" data-value="2">m.text</div>
<div class="item" data-value="2">m.text</div>
</div>
</div> </div>
</div> </div>
{{template "repo/settings/webhook/settings" .}} </div>
</form> {{template "repo/settings/webhook/settings" .}}
{{end}} </form>

View file

@ -1,11 +1,9 @@
{{if eq .HookType "msteams"}} <p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://teams.microsoft.com" (ctx.Locale.Tr "repo.settings.web_hook_name_msteams")}}</p>
<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">
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "msteams/new"}}" method="post"> {{.CsrfTokenHtml}}
{{.CsrfTokenHtml}} <div class="required field {{if .Err_PayloadURL}}error{{end}}">
<div class="required field {{if .Err_PayloadURL}}error{{end}}"> <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
<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>
<input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> </div>
</div> {{template "repo/settings/webhook/settings" .}}
{{template "repo/settings/webhook/settings" .}} </form>
</form>
{{end}}

View file

@ -1,19 +1,17 @@
{{if eq .HookType "packagist"}} <p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://packagist.org" (ctx.Locale.Tr "repo.settings.web_hook_name_packagist")}}</p>
<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">
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "packagist/new"}}" method="post"> {{.CsrfTokenHtml}}
{{.CsrfTokenHtml}} <div class="required field {{if .Err_Username}}error{{end}}">
<div class="required field {{if .Err_Username}}error{{end}}"> <label for="username">{{ctx.Locale.Tr "repo.settings.packagist_username"}}</label>
<label for="username">{{ctx.Locale.Tr "repo.settings.packagist_username"}}</label> <input id="username" name="username" value="{{.HookMetadata.Username}}" placeholder="Forgejo" autofocus required>
<input id="username" name="username" value="{{.HookMetadata.Username}}" placeholder="Forgejo" autofocus required> </div>
</div> <div class="required field {{if .Err_APIToken}}error{{end}}">
<div class="required field {{if .Err_APIToken}}error{{end}}"> <label for="api_token">{{ctx.Locale.Tr "repo.settings.packagist_api_token"}}</label>
<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>
<input id="api_token" name="api_token" value="{{.HookMetadata.APIToken}}" placeholder="X5F_tZ-Wj3c1vqaU2Rky" required> </div>
</div> <div class="required field {{if .Err_PackageURL}}error{{end}}">
<div class="required field {{if .Err_PackageURL}}error{{end}}"> <label for="package_url">{{ctx.Locale.Tr "repo.settings.packagist_package_url"}}</label>
<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>
<input id="package_url" name="package_url" value="{{.HookMetadata.PackageURL}}" placeholder="https://packagist.org/packages/laravel/framework" required> </div>
</div> {{template "repo/settings/webhook/settings" .}}
{{template "repo/settings/webhook/settings" .}} </form>
</form>
{{end}}

View file

@ -1,28 +1,26 @@
{{if eq .HookType "slack"}} <p>{{ctx.Locale.Tr "repo.settings.add_web_hook_desc" "https://slack.com" (ctx.Locale.Tr "repo.settings.web_hook_name_slack")}}</p>
<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">
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "slack/new"}}" method="post"> {{.CsrfTokenHtml}}
{{.CsrfTokenHtml}} <div class="required field {{if .Err_PayloadURL}}error{{end}}">
<div class="required field {{if .Err_PayloadURL}}error{{end}}"> <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
<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>
<input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> </div>
</div> <div class="required field {{if .Err_Channel}}error{{end}}">
<div class="required field {{if .Err_Channel}}error{{end}}"> <label for="channel">{{ctx.Locale.Tr "repo.settings.slack_channel"}}</label>
<label for="channel">{{ctx.Locale.Tr "repo.settings.slack_channel"}}</label> <input id="channel" name="channel" value="{{.HookMetadata.Channel}}" placeholder="#general" required>
<input id="channel" name="channel" value="{{.HookMetadata.Channel}}" placeholder="#general" required> </div>
</div>
<div class="field"> <div class="field">
<label for="username">{{ctx.Locale.Tr "repo.settings.slack_username"}}</label> <label for="username">{{ctx.Locale.Tr "repo.settings.slack_username"}}</label>
<input id="username" name="username" value="{{.HookMetadata.Username}}" placeholder="Forgejo"> <input id="username" name="username" value="{{.HookMetadata.Username}}" placeholder="Forgejo">
</div> </div>
<div class="field"> <div class="field">
<label for="icon_url">{{ctx.Locale.Tr "repo.settings.slack_icon_url"}}</label> <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"> <input id="icon_url" name="icon_url" value="{{.HookMetadata.IconURL}}" placeholder="https://example.com/img/favicon.png">
</div> </div>
<div class="field"> <div class="field">
<label for="color">{{ctx.Locale.Tr "repo.settings.slack_color"}}</label> <label for="color">{{ctx.Locale.Tr "repo.settings.slack_color"}}</label>
<input id="color" name="color" value="{{.HookMetadata.Color}}" placeholder="#dd4b39, good, warning, danger"> <input id="color" name="color" value="{{.HookMetadata.Color}}" placeholder="#dd4b39, good, warning, danger">
</div> </div>
{{template "repo/settings/webhook/settings" .}} {{template "repo/settings/webhook/settings" .}}
</form> </form>
{{end}}

View file

@ -1,19 +1,17 @@
{{if eq .HookType "telegram"}} <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>
<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">
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "telegram/new"}}" method="post"> {{.CsrfTokenHtml}}
{{.CsrfTokenHtml}} <div class="required field {{if .Err_BotToken}}error{{end}}">
<div class="required field {{if .Err_BotToken}}error{{end}}"> <label for="bot_token">{{ctx.Locale.Tr "repo.settings.bot_token"}}</label>
<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>
<input id="bot_token" name="bot_token" type="text" value="{{.HookMetadata.BotToken}}" autofocus required> </div>
</div> <div class="required field {{if .Err_ChatID}}error{{end}}">
<div class="required field {{if .Err_ChatID}}error{{end}}"> <label for="chat_id">{{ctx.Locale.Tr "repo.settings.chat_id"}}</label>
<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>
<input id="chat_id" name="chat_id" type="text" value="{{.HookMetadata.ChatID}}" required> </div>
</div> <div class="field {{if .Err_ThreadID}}error{{end}}">
<div class="field {{if .Err_ThreadID}}error{{end}}"> <label for="thread_id">{{ctx.Locale.Tr "repo.settings.thread_id"}}</label>
<label for="thread_id">{{ctx.Locale.Tr "repo.settings.thread_id"}}</label> <input id="thread_id" name="thread_id" type="text" value="{{.HookMetadata.ThreadID}}">
<input id="thread_id" name="thread_id" type="text" value="{{.HookMetadata.ThreadID}}"> </div>
</div> {{template "repo/settings/webhook/settings" .}}
{{template "repo/settings/webhook/settings" .}} </form>
</form>
{{end}}

View file

@ -1,11 +1,9 @@
{{if eq .HookType "wechatwork"}} <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>
<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">
<form class="ui form" action="{{.BaseLink}}/{{or .Webhook.ID "wechatwork/new"}}" method="post"> {{.CsrfTokenHtml}}
{{.CsrfTokenHtml}} <div class="required field {{if .Err_PayloadURL}}error{{end}}">
<div class="required field {{if .Err_PayloadURL}}error{{end}}"> <label for="payload_url">{{ctx.Locale.Tr "repo.settings.payload_url"}}</label>
<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>
<input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required> </div>
</div> {{template "repo/settings/webhook/settings" .}}
{{template "repo/settings/webhook/settings" .}} </form>
</form>
{{end}}