From 9b0743ae33e8342e00a7ad3a6ba8af81b4c7019e Mon Sep 17 00:00:00 2001 From: Kerwin Bryant Date: Wed, 6 Sep 2023 18:11:06 +0800 Subject: [PATCH] Extract common code to new template (#26933) Same as #26903 --- templates/admin/hook_new.tmpl | 38 ++++++------------------ templates/org/settings/hook_new.tmpl | 4 ++- templates/repo/settings/webhook/new.tmpl | 4 ++- templates/user/settings/hook_new.tmpl | 4 ++- templates/webhook/new.tmpl | 28 ++++++++--------- 5 files changed, 32 insertions(+), 46 deletions(-) diff --git a/templates/admin/hook_new.tmpl b/templates/admin/hook_new.tmpl index e72e7bba6..f565318b8 100644 --- a/templates/admin/hook_new.tmpl +++ b/templates/admin/hook_new.tmpl @@ -1,33 +1,13 @@ {{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin settings new webhook")}}
-

- {{if .PageIsAdminDefaultHooksNew}} - {{.locale.Tr "admin.defaulthooks.add_webhook"}} - {{else if .PageIsAdminSystemHooksNew}} - {{.locale.Tr "admin.systemhooks.add_webhook"}} - {{else if .Webhook.IsSystemWebhook}} - {{.locale.Tr "admin.systemhooks.update_webhook"}} - {{else}} - {{.locale.Tr "admin.defaulthooks.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" .}} + {{$CustomHeaderTitle := .locale.Tr "admin.defaulthooks.update_webhook"}} + {{if .PageIsAdminDefaultHooksNew}} + {{$CustomHeaderTitle = .locale.Tr "admin.defaulthooks.add_webhook"}} + {{else if .PageIsAdminSystemHooksNew}} + {{$CustomHeaderTitle = .locale.Tr "admin.systemhooks.add_webhook"}} + {{else if .Webhook.IsSystemWebhook}} + {{$CustomHeaderTitle = .locale.Tr "admin.systemhooks.update_webhook"}} + {{end}} + {{template "webhook/new" (dict "ctxData" . "CustomHeaderTitle" $CustomHeaderTitle)}}
{{template "admin/layout_footer" .}} diff --git a/templates/org/settings/hook_new.tmpl b/templates/org/settings/hook_new.tmpl index d4343f8c6..ea477c997 100644 --- a/templates/org/settings/hook_new.tmpl +++ b/templates/org/settings/hook_new.tmpl @@ -1,5 +1,7 @@ {{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings new webhook")}}
- {{template "webhook/new" .}} + {{$CustomHeaderTitle := .locale.Tr "repo.settings.update_webhook"}} + {{if .PageIsSettingsHooksNew}}{{$CustomHeaderTitle = .locale.Tr "repo.settings.add_webhook"}}{{end}} + {{template "webhook/new" (dict "ctxData" . "CustomHeaderTitle" $CustomHeaderTitle)}}
{{template "org/settings/layout_footer" .}} diff --git a/templates/repo/settings/webhook/new.tmpl b/templates/repo/settings/webhook/new.tmpl index 79fd4bd2f..67a5f7296 100644 --- a/templates/repo/settings/webhook/new.tmpl +++ b/templates/repo/settings/webhook/new.tmpl @@ -1,5 +1,7 @@ {{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings new webhook")}}
- {{template "webhook/new" .}} + {{$CustomHeaderTitle := .locale.Tr "repo.settings.update_webhook"}} + {{if .PageIsSettingsHooksNew}}{{$CustomHeaderTitle = .locale.Tr "repo.settings.add_webhook"}}{{end}} + {{template "webhook/new" (dict "ctxData" . "CustomHeaderTitle" $CustomHeaderTitle)}}
{{template "repo/settings/layout_footer" .}} diff --git a/templates/user/settings/hook_new.tmpl b/templates/user/settings/hook_new.tmpl index 4d3ddf038..9a857db85 100644 --- a/templates/user/settings/hook_new.tmpl +++ b/templates/user/settings/hook_new.tmpl @@ -1,5 +1,7 @@ {{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings new webhook")}}
- {{template "webhook/new" .}} + {{$CustomHeaderTitle := .locale.Tr "repo.settings.update_webhook"}} + {{if .PageIsSettingsHooksNew}}{{$CustomHeaderTitle = .locale.Tr "repo.settings.add_webhook"}}{{end}} + {{template "webhook/new" (dict "ctxData" . "CustomHeaderTitle" $CustomHeaderTitle)}}
{{template "user/settings/layout_footer" .}} diff --git a/templates/webhook/new.tmpl b/templates/webhook/new.tmpl index b5878fc93..a185c42b5 100644 --- a/templates/webhook/new.tmpl +++ b/templates/webhook/new.tmpl @@ -1,20 +1,20 @@

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

- {{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/gitea" .ctxData}} + {{template "repo/settings/webhook/gogs" .ctxData}} + {{template "repo/settings/webhook/slack" .ctxData}} + {{template "repo/settings/webhook/discord" .ctxData}} + {{template "repo/settings/webhook/dingtalk" .ctxData}} + {{template "repo/settings/webhook/telegram" .ctxData}} + {{template "repo/settings/webhook/msteams" .ctxData}} + {{template "repo/settings/webhook/feishu" .ctxData}} + {{template "repo/settings/webhook/matrix" .ctxData}} + {{template "repo/settings/webhook/wechatwork" .ctxData}} + {{template "repo/settings/webhook/packagist" .ctxData}}
-{{template "repo/settings/webhook/history" .}} +{{template "repo/settings/webhook/history" .ctxData}}