From 65588b732c087e191a8f03e240fdfc5dcfc24199 Mon Sep 17 00:00:00 2001 From: Kerwin Bryant Date: Tue, 5 Sep 2023 20:00:28 +0800 Subject: [PATCH] Extract common code to new template (#26903) I noticed that the code of several new webhook pages is highly repetitive, so I pulled out the common parts to a new template, unified reference, unified maintenance --------- Co-authored-by: KN4CK3R --- templates/org/settings/hook_new.tmpl | 27 +++--------------------- templates/repo/settings/webhook/new.tmpl | 22 +------------------ templates/user/settings/hook_new.tmpl | 24 +-------------------- templates/webhook/new.tmpl | 20 ++++++++++++++++++ 4 files changed, 25 insertions(+), 68 deletions(-) create mode 100644 templates/webhook/new.tmpl diff --git a/templates/org/settings/hook_new.tmpl b/templates/org/settings/hook_new.tmpl index 4a1323568a..d4343f8c68 100644 --- a/templates/org/settings/hook_new.tmpl +++ b/templates/org/settings/hook_new.tmpl @@ -1,26 +1,5 @@ {{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings new webhook")}} -
-

- {{if .PageIsSettingsHooksNew}}{{.locale.Tr "repo.settings.add_webhook"}}{{else}}{{.locale.Tr "repo.settings.update_webhook"}}{{end}} -
- {{template "shared/webhook/icon" .}} -
-

-
- {{template "repo/settings/webhook/gitea" .}} - {{template "repo/settings/webhook/gogs" .}} - {{template "repo/settings/webhook/slack" .}} - {{template "repo/settings/webhook/discord" .}} - {{template "repo/settings/webhook/dingtalk" .}} - {{template "repo/settings/webhook/telegram" .}} - {{template "repo/settings/webhook/msteams" .}} - {{template "repo/settings/webhook/feishu" .}} - {{template "repo/settings/webhook/matrix" .}} - {{template "repo/settings/webhook/wechatwork" .}} - {{template "repo/settings/webhook/packagist" .}} -
- - {{template "repo/settings/webhook/history" .}} -
- +
+ {{template "webhook/new" .}} +
{{template "org/settings/layout_footer" .}} diff --git a/templates/repo/settings/webhook/new.tmpl b/templates/repo/settings/webhook/new.tmpl index 1b04742221..79fd4bd2ff 100644 --- a/templates/repo/settings/webhook/new.tmpl +++ b/templates/repo/settings/webhook/new.tmpl @@ -1,25 +1,5 @@ {{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings new webhook")}}
-

- {{if .PageIsSettingsHooksNew}}{{.locale.Tr "repo.settings.add_webhook"}}{{else}}{{.locale.Tr "repo.settings.update_webhook"}}{{end}} -
- {{template "shared/webhook/icon" .}} -
-

-
- {{template "repo/settings/webhook/gitea" .}} - {{template "repo/settings/webhook/gogs" .}} - {{template "repo/settings/webhook/slack" .}} - {{template "repo/settings/webhook/discord" .}} - {{template "repo/settings/webhook/dingtalk" .}} - {{template "repo/settings/webhook/telegram" .}} - {{template "repo/settings/webhook/msteams" .}} - {{template "repo/settings/webhook/feishu" .}} - {{template "repo/settings/webhook/matrix" .}} - {{template "repo/settings/webhook/wechatwork" .}} - {{template "repo/settings/webhook/packagist" .}} -
- - {{template "repo/settings/webhook/history" .}} + {{template "webhook/new" .}}
{{template "repo/settings/layout_footer" .}} diff --git a/templates/user/settings/hook_new.tmpl b/templates/user/settings/hook_new.tmpl index 83ae4801b4..4d3ddf0383 100644 --- a/templates/user/settings/hook_new.tmpl +++ b/templates/user/settings/hook_new.tmpl @@ -1,27 +1,5 @@ {{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings new webhook")}}
-
-

- {{if .PageIsSettingsHooksNew}}{{.locale.Tr "repo.settings.add_webhook"}}{{else}}{{.locale.Tr "repo.settings.update_webhook"}}{{end}} -
- {{template "shared/webhook/icon" .}} -
-

-
- {{template "repo/settings/webhook/gitea" .}} - {{template "repo/settings/webhook/gogs" .}} - {{template "repo/settings/webhook/slack" .}} - {{template "repo/settings/webhook/discord" .}} - {{template "repo/settings/webhook/dingtalk" .}} - {{template "repo/settings/webhook/telegram" .}} - {{template "repo/settings/webhook/msteams" .}} - {{template "repo/settings/webhook/feishu" .}} - {{template "repo/settings/webhook/matrix" .}} - {{template "repo/settings/webhook/wechatwork" .}} - {{template "repo/settings/webhook/packagist" .}} -
- - {{template "repo/settings/webhook/history" .}} -
+ {{template "webhook/new" .}}
{{template "user/settings/layout_footer" .}} diff --git a/templates/webhook/new.tmpl b/templates/webhook/new.tmpl new file mode 100644 index 0000000000..b5878fc930 --- /dev/null +++ b/templates/webhook/new.tmpl @@ -0,0 +1,20 @@ +

+ {{if .PageIsSettingsHooksNew}}{{.locale.Tr "repo.settings.add_webhook"}}{{else}}{{.locale.Tr "repo.settings.update_webhook"}}{{end}} +
+ {{template "shared/webhook/icon" .}} +
+

+
+ {{template "repo/settings/webhook/gitea" .}} + {{template "repo/settings/webhook/gogs" .}} + {{template "repo/settings/webhook/slack" .}} + {{template "repo/settings/webhook/discord" .}} + {{template "repo/settings/webhook/dingtalk" .}} + {{template "repo/settings/webhook/telegram" .}} + {{template "repo/settings/webhook/msteams" .}} + {{template "repo/settings/webhook/feishu" .}} + {{template "repo/settings/webhook/matrix" .}} + {{template "repo/settings/webhook/wechatwork" .}} + {{template "repo/settings/webhook/packagist" .}} +
+{{template "repo/settings/webhook/history" .}}