From c1544754f81b56be16ab5d0dbac8e32ee7bc88ee Mon Sep 17 00:00:00 2001 From: Giteabot Date: Mon, 31 Jul 2023 18:09:13 +0800 Subject: [PATCH] Use shared template for webhook icons (#26242) (#26246) Backport #26242 by @silverwind Fixes: https://github.com/go-gitea/gitea/issues/26241 Co-authored-by: silverwind (cherry picked from commit 2517da90aacc735ce5a9d5401fe23990597139d4) --- templates/admin/hook_new.tmpl | 24 +------------- templates/org/settings/hook_new.tmpl | 24 +------------- .../repo/settings/webhook/base_list.tmpl | 33 ++++++++++++------- templates/repo/settings/webhook/new.tmpl | 24 +------------- templates/shared/webhook/icon.tmpl | 27 +++++++++++++++ templates/user/settings/hook_new.tmpl | 24 +------------- 6 files changed, 53 insertions(+), 103 deletions(-) create mode 100644 templates/shared/webhook/icon.tmpl diff --git a/templates/admin/hook_new.tmpl b/templates/admin/hook_new.tmpl index 1abdd4c813..e72e7bba62 100644 --- a/templates/admin/hook_new.tmpl +++ b/templates/admin/hook_new.tmpl @@ -11,29 +11,7 @@ {{.locale.Tr "admin.defaulthooks.update_webhook"}} {{end}}
- {{if eq .HookType "gitea"}} - - {{else if eq .HookType "gogs"}} - - {{else if eq .HookType "slack"}} - - {{else if eq .HookType "discord"}} - - {{else if eq .HookType "dingtalk"}} - - {{else if eq .HookType "telegram"}} - - {{else if eq .HookType "msteams"}} - - {{else if eq .HookType "feishu"}} - - {{else if eq .HookType "matrix"}} - {{svg "gitea-matrix" 26}} - {{else if eq .HookType "wechatwork"}} - - {{else if eq .HookType "packagist"}} - - {{end}} + {{template "shared/webhook/icon" .}}
diff --git a/templates/org/settings/hook_new.tmpl b/templates/org/settings/hook_new.tmpl index 1bf74fb7ba..4a1323568a 100644 --- a/templates/org/settings/hook_new.tmpl +++ b/templates/org/settings/hook_new.tmpl @@ -3,29 +3,7 @@

{{if .PageIsSettingsHooksNew}}{{.locale.Tr "repo.settings.add_webhook"}}{{else}}{{.locale.Tr "repo.settings.update_webhook"}}{{end}}
- {{if eq .HookType "gitea"}} - - {{else if eq .HookType "gogs"}} - - {{else if eq .HookType "slack"}} - - {{else if eq .HookType "discord"}} - - {{else if eq .HookType "dingtalk"}} - - {{else if eq .HookType "telegram"}} - - {{else if eq .HookType "msteams"}} - - {{else if eq .HookType "feishu"}} - - {{else if eq .HookType "matrix"}} - {{svg "gitea-matrix" 26}} - {{else if eq .HookType "wechatwork"}} - - {{else if eq .HookType "packagist"}} - - {{end}} + {{template "shared/webhook/icon" .}}

diff --git a/templates/repo/settings/webhook/base_list.tmpl b/templates/repo/settings/webhook/base_list.tmpl index 663fde1528..06610a2e55 100644 --- a/templates/repo/settings/webhook/base_list.tmpl +++ b/templates/repo/settings/webhook/base_list.tmpl @@ -5,37 +5,48 @@
{{.locale.Tr "repo.settings.add_webhook"}}
diff --git a/templates/repo/settings/webhook/new.tmpl b/templates/repo/settings/webhook/new.tmpl index 73d6726a57..1b04742221 100644 --- a/templates/repo/settings/webhook/new.tmpl +++ b/templates/repo/settings/webhook/new.tmpl @@ -3,29 +3,7 @@

{{if .PageIsSettingsHooksNew}}{{.locale.Tr "repo.settings.add_webhook"}}{{else}}{{.locale.Tr "repo.settings.update_webhook"}}{{end}}
- {{if eq .HookType "gitea"}} - - {{else if eq .HookType "gogs"}} - - {{else if eq .HookType "slack"}} - - {{else if eq .HookType "discord"}} - - {{else if eq .HookType "dingtalk"}} - - {{else if eq .HookType "telegram"}} - - {{else if eq .HookType "msteams"}} - - {{else if eq .HookType "feishu"}} - - {{else if eq .HookType "matrix"}} - {{svg "gitea-matrix" 26}} - {{else if eq .HookType "wechatwork"}} - - {{else if eq .HookType "packagist"}} - - {{end}} + {{template "shared/webhook/icon" .}}

diff --git a/templates/shared/webhook/icon.tmpl b/templates/shared/webhook/icon.tmpl new file mode 100644 index 0000000000..84f9de266f --- /dev/null +++ b/templates/shared/webhook/icon.tmpl @@ -0,0 +1,27 @@ +{{$size := 26}} +{{if .Size}} + {{$size = .Size}} +{{end}} +{{if eq .HookType "gitea"}} + +{{else if eq .HookType "gogs"}} + +{{else if eq .HookType "slack"}} + +{{else if eq .HookType "discord"}} + +{{else if eq .HookType "dingtalk"}} + +{{else if eq .HookType "telegram"}} + +{{else if eq .HookType "msteams"}} + +{{else if eq .HookType "feishu"}} + +{{else if eq .HookType "matrix"}} + {{svg "gitea-matrix" $size "img"}} +{{else if eq .HookType "wechatwork"}} + +{{else if eq .HookType "packagist"}} + +{{end}} diff --git a/templates/user/settings/hook_new.tmpl b/templates/user/settings/hook_new.tmpl index ac32cdd8c8..83ae4801b4 100644 --- a/templates/user/settings/hook_new.tmpl +++ b/templates/user/settings/hook_new.tmpl @@ -4,29 +4,7 @@

{{if .PageIsSettingsHooksNew}}{{.locale.Tr "repo.settings.add_webhook"}}{{else}}{{.locale.Tr "repo.settings.update_webhook"}}{{end}}
- {{if eq .HookType "gitea"}} - - {{else if eq .HookType "gogs"}} - - {{else if eq .HookType "slack"}} - - {{else if eq .HookType "discord"}} - - {{else if eq .HookType "dingtalk"}} - - {{else if eq .HookType "telegram"}} - - {{else if eq .HookType "msteams"}} - - {{else if eq .HookType "feishu"}} - - {{else if eq .HookType "matrix"}} - - {{else if eq .HookType "wechatwork"}} - - {{else if eq .HookType "packagist"}} - - {{end}} + {{template "shared/webhook/icon" .}}