Merge default and system webhooks under one menu (#14244)

This commit is contained in:
Lauris BH 2021-01-15 01:24:03 +02:00 committed by GitHub
parent 84b147c7f0
commit 6eee9f0f4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 148 additions and 141 deletions

View file

@ -400,20 +400,6 @@ func GetWebhooksByOrgID(orgID int64, listOptions ListOptions) ([]*Webhook, error
return ws, sess.Find(&ws, &Webhook{OrgID: orgID}) return ws, sess.Find(&ws, &Webhook{OrgID: orgID})
} }
// GetDefaultWebhook returns admin-default webhook by given ID.
func GetDefaultWebhook(id int64) (*Webhook, error) {
webhook := &Webhook{ID: id}
has, err := x.
Where("repo_id=? AND org_id=? AND is_system_webhook=?", 0, 0, false).
Get(webhook)
if err != nil {
return nil, err
} else if !has {
return nil, ErrWebhookNotExist{id}
}
return webhook, nil
}
// GetDefaultWebhooks returns all admin-default webhooks. // GetDefaultWebhooks returns all admin-default webhooks.
func GetDefaultWebhooks() ([]*Webhook, error) { func GetDefaultWebhooks() ([]*Webhook, error) {
return getDefaultWebhooks(x) return getDefaultWebhooks(x)
@ -426,11 +412,11 @@ func getDefaultWebhooks(e Engine) ([]*Webhook, error) {
Find(&webhooks) Find(&webhooks)
} }
// GetSystemWebhook returns admin system webhook by given ID. // GetSystemOrDefaultWebhook returns admin system or default webhook by given ID.
func GetSystemWebhook(id int64) (*Webhook, error) { func GetSystemOrDefaultWebhook(id int64) (*Webhook, error) {
webhook := &Webhook{ID: id} webhook := &Webhook{ID: id}
has, err := x. has, err := x.
Where("repo_id=? AND org_id=? AND is_system_webhook=?", 0, 0, true). Where("repo_id=? AND org_id=?", 0, 0).
Get(webhook) Get(webhook)
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -2001,8 +2001,7 @@ dashboard = Dashboard
users = User Accounts users = User Accounts
organizations = Organizations organizations = Organizations
repositories = Repositories repositories = Repositories
hooks = Default Webhooks hooks = Webhooks
systemhooks = System Webhooks
authentication = Authentication Sources authentication = Authentication Sources
emails = User Emails emails = User Emails
config = Configuration config = Configuration
@ -2152,11 +2151,13 @@ repos.forks = Forks
repos.issues = Issues repos.issues = Issues
repos.size = Size repos.size = Size
hooks.desc = Webhooks automatically make HTTP POST requests to a server when certain Gitea events trigger. Webhooks defined here are defaults and will be copied into all new repositories. Read more in the <a target="_blank" rel="noopener" href="https://docs.gitea.io/en-us/webhooks/">webhooks guide</a>. defaulthooks = Default Webhooks
hooks.add_webhook = Add Default Webhook defaulthooks.desc = Webhooks automatically make HTTP POST requests to a server when certain Gitea events trigger. Webhooks defined here are defaults and will be copied into all new repositories. Read more in the <a target="_blank" rel="noopener" href="https://docs.gitea.io/en-us/webhooks/">webhooks guide</a>.
hooks.update_webhook = Update Default Webhook defaulthooks.add_webhook = Add Default Webhook
defaulthooks.update_webhook = Update Default Webhook
systemhooks.desc = Webhooks automatically make HTTP POST requests to a server when certain Gitea events trigger. Webhooks defined will act on all repositories on the system, so please consider any performance implications this may have. Read more in the <a target="_blank" rel="noopener" href="https://docs.gitea.io/en-us/webhooks/">webhooks guide</a>. systemhooks = System Webhooks
systemhooks.desc = Webhooks automatically make HTTP POST requests to a server when certain Gitea events trigger. Webhooks defined here will act on all repositories on the system, so please consider any performance implications this may have. Read more in the <a target="_blank" rel="noopener" href="https://docs.gitea.io/en-us/webhooks/">webhooks guide</a>.
systemhooks.add_webhook = Add System Webhook systemhooks.add_webhook = Add System Webhook
systemhooks.update_webhook = Update System Webhook systemhooks.update_webhook = Update System Webhook

View file

@ -18,30 +18,41 @@ const (
// DefaultOrSystemWebhooks renders both admin default and system webhook list pages // DefaultOrSystemWebhooks renders both admin default and system webhook list pages
func DefaultOrSystemWebhooks(ctx *context.Context) { func DefaultOrSystemWebhooks(ctx *context.Context) {
var ws []*models.Webhook
var err error var err error
// Are we looking at default webhooks? ctx.Data["PageIsAdminSystemHooks"] = true
if ctx.Params(":configType") == "hooks" { ctx.Data["PageIsAdminDefaultHooks"] = true
ctx.Data["Title"] = ctx.Tr("admin.hooks")
ctx.Data["Description"] = ctx.Tr("admin.hooks.desc") def := make(map[string]interface{}, len(ctx.Data))
ctx.Data["PageIsAdminHooks"] = true sys := make(map[string]interface{}, len(ctx.Data))
ctx.Data["BaseLink"] = setting.AppSubURL + "/admin/hooks" for k, v := range ctx.Data {
ws, err = models.GetDefaultWebhooks() def[k] = v
} else { sys[k] = v
ctx.Data["Title"] = ctx.Tr("admin.systemhooks")
ctx.Data["Description"] = ctx.Tr("admin.systemhooks.desc")
ctx.Data["PageIsAdminSystemHooks"] = true
ctx.Data["BaseLink"] = setting.AppSubURL + "/admin/system-hooks"
ws, err = models.GetSystemWebhooks()
} }
sys["Title"] = ctx.Tr("admin.systemhooks")
sys["Description"] = ctx.Tr("admin.systemhooks.desc")
sys["Webhooks"], err = models.GetSystemWebhooks()
sys["BaseLink"] = setting.AppSubURL + "/admin/hooks"
sys["BaseLinkNew"] = setting.AppSubURL + "/admin/system-hooks"
if err != nil { if err != nil {
ctx.ServerError("GetWebhooksAdmin", err) ctx.ServerError("GetWebhooksAdmin", err)
return return
} }
ctx.Data["Webhooks"] = ws def["Title"] = ctx.Tr("admin.defaulthooks")
def["Description"] = ctx.Tr("admin.defaulthooks.desc")
def["Webhooks"], err = models.GetDefaultWebhooks()
def["BaseLink"] = setting.AppSubURL + "/admin/hooks"
def["BaseLinkNew"] = setting.AppSubURL + "/admin/default-hooks"
if err != nil {
ctx.ServerError("GetWebhooksAdmin", err)
return
}
ctx.Data["DefaultWebhooks"] = def
ctx.Data["SystemWebhooks"] = sys
ctx.HTML(200, tplAdminHooks) ctx.HTML(200, tplAdminHooks)
} }
@ -53,14 +64,7 @@ func DeleteDefaultOrSystemWebhook(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success")) ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
} }
// Are we looking at default webhooks? ctx.JSON(200, map[string]interface{}{
if ctx.Params(":configType") == "hooks" { "redirect": setting.AppSubURL + "/admin/hooks",
ctx.JSON(200, map[string]interface{}{ })
"redirect": setting.AppSubURL + "/admin/hooks",
})
} else {
ctx.JSON(200, map[string]interface{}{
"redirect": setting.AppSubURL + "/admin/system-hooks",
})
}
} }

View file

@ -173,6 +173,7 @@ func Webhooks(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("org.settings") ctx.Data["Title"] = ctx.Tr("org.settings")
ctx.Data["PageIsSettingsHooks"] = true ctx.Data["PageIsSettingsHooks"] = true
ctx.Data["BaseLink"] = ctx.Org.OrgLink + "/settings/hooks" ctx.Data["BaseLink"] = ctx.Org.OrgLink + "/settings/hooks"
ctx.Data["BaseLinkNew"] = ctx.Org.OrgLink + "/settings/hooks"
ctx.Data["Description"] = ctx.Tr("org.settings.hooks_desc") ctx.Data["Description"] = ctx.Tr("org.settings.hooks_desc")
ws, err := models.GetWebhooksByOrgID(ctx.Org.Organization.ID, models.ListOptions{}) ws, err := models.GetWebhooksByOrgID(ctx.Org.Organization.ID, models.ListOptions{})

View file

@ -36,6 +36,7 @@ func Webhooks(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings.hooks") ctx.Data["Title"] = ctx.Tr("repo.settings.hooks")
ctx.Data["PageIsSettingsHooks"] = true ctx.Data["PageIsSettingsHooks"] = true
ctx.Data["BaseLink"] = ctx.Repo.RepoLink + "/settings/hooks" ctx.Data["BaseLink"] = ctx.Repo.RepoLink + "/settings/hooks"
ctx.Data["BaseLinkNew"] = ctx.Repo.RepoLink + "/settings/hooks"
ctx.Data["Description"] = ctx.Tr("repo.settings.hooks_desc", "https://docs.gitea.io/en-us/webhooks/") ctx.Data["Description"] = ctx.Tr("repo.settings.hooks_desc", "https://docs.gitea.io/en-us/webhooks/")
ws, err := models.GetWebhooksByRepoID(ctx.Repo.Repository.ID, models.ListOptions{}) ws, err := models.GetWebhooksByRepoID(ctx.Repo.Repository.ID, models.ListOptions{})
@ -54,6 +55,7 @@ type orgRepoCtx struct {
IsAdmin bool IsAdmin bool
IsSystemWebhook bool IsSystemWebhook bool
Link string Link string
LinkNew string
NewTemplate base.TplName NewTemplate base.TplName
} }
@ -63,6 +65,7 @@ func getOrgRepoCtx(ctx *context.Context) (*orgRepoCtx, error) {
return &orgRepoCtx{ return &orgRepoCtx{
RepoID: ctx.Repo.Repository.ID, RepoID: ctx.Repo.Repository.ID,
Link: path.Join(ctx.Repo.RepoLink, "settings/hooks"), Link: path.Join(ctx.Repo.RepoLink, "settings/hooks"),
LinkNew: path.Join(ctx.Repo.RepoLink, "settings/hooks"),
NewTemplate: tplHookNew, NewTemplate: tplHookNew,
}, nil }, nil
} }
@ -71,16 +74,18 @@ func getOrgRepoCtx(ctx *context.Context) (*orgRepoCtx, error) {
return &orgRepoCtx{ return &orgRepoCtx{
OrgID: ctx.Org.Organization.ID, OrgID: ctx.Org.Organization.ID,
Link: path.Join(ctx.Org.OrgLink, "settings/hooks"), Link: path.Join(ctx.Org.OrgLink, "settings/hooks"),
LinkNew: path.Join(ctx.Org.OrgLink, "settings/hooks"),
NewTemplate: tplOrgHookNew, NewTemplate: tplOrgHookNew,
}, nil }, nil
} }
if ctx.User.IsAdmin { if ctx.User.IsAdmin {
// Are we looking at default webhooks? // Are we looking at default webhooks?
if ctx.Params(":configType") == "hooks" { if ctx.Params(":configType") == "default-hooks" {
return &orgRepoCtx{ return &orgRepoCtx{
IsAdmin: true, IsAdmin: true,
Link: path.Join(setting.AppSubURL, "/admin/hooks"), Link: path.Join(setting.AppSubURL, "/admin/hooks"),
LinkNew: path.Join(setting.AppSubURL, "/admin/default-hooks"),
NewTemplate: tplAdminHookNew, NewTemplate: tplAdminHookNew,
}, nil }, nil
} }
@ -89,7 +94,8 @@ func getOrgRepoCtx(ctx *context.Context) (*orgRepoCtx, error) {
return &orgRepoCtx{ return &orgRepoCtx{
IsAdmin: true, IsAdmin: true,
IsSystemWebhook: true, IsSystemWebhook: true,
Link: path.Join(setting.AppSubURL, "/admin/system-hooks"), Link: path.Join(setting.AppSubURL, "/admin/hooks"),
LinkNew: path.Join(setting.AppSubURL, "/admin/system-hooks"),
NewTemplate: tplAdminHookNew, NewTemplate: tplAdminHookNew,
}, nil }, nil
} }
@ -121,8 +127,8 @@ func WebhooksNew(ctx *context.Context) {
ctx.Data["PageIsAdminSystemHooks"] = true ctx.Data["PageIsAdminSystemHooks"] = true
ctx.Data["PageIsAdminSystemHooksNew"] = true ctx.Data["PageIsAdminSystemHooksNew"] = true
} else if orCtx.IsAdmin { } else if orCtx.IsAdmin {
ctx.Data["PageIsAdminHooks"] = true ctx.Data["PageIsAdminDefaultHooks"] = true
ctx.Data["PageIsAdminHooksNew"] = true ctx.Data["PageIsAdminDefaultHooksNew"] = true
} else { } else {
ctx.Data["PageIsSettingsHooks"] = true ctx.Data["PageIsSettingsHooks"] = true
ctx.Data["PageIsSettingsHooksNew"] = true ctx.Data["PageIsSettingsHooksNew"] = true
@ -139,7 +145,7 @@ func WebhooksNew(ctx *context.Context) {
"IconURL": setting.AppURL + "img/favicon.png", "IconURL": setting.AppURL + "img/favicon.png",
} }
} }
ctx.Data["BaseLink"] = orCtx.Link ctx.Data["BaseLink"] = orCtx.LinkNew
ctx.HTML(200, orCtx.NewTemplate) ctx.HTML(200, orCtx.NewTemplate)
} }
@ -187,7 +193,7 @@ func GiteaHooksNewPost(ctx *context.Context, form auth.NewWebhookForm) {
ctx.ServerError("getOrgRepoCtx", err) ctx.ServerError("getOrgRepoCtx", err)
return return
} }
ctx.Data["BaseLink"] = orCtx.Link ctx.Data["BaseLink"] = orCtx.LinkNew
if ctx.HasError() { if ctx.HasError() {
ctx.HTML(200, orCtx.NewTemplate) ctx.HTML(200, orCtx.NewTemplate)
@ -241,7 +247,7 @@ func newGogsWebhookPost(ctx *context.Context, form auth.NewGogshookForm, kind mo
ctx.ServerError("getOrgRepoCtx", err) ctx.ServerError("getOrgRepoCtx", err)
return return
} }
ctx.Data["BaseLink"] = orCtx.Link ctx.Data["BaseLink"] = orCtx.LinkNew
if ctx.HasError() { if ctx.HasError() {
ctx.HTML(200, orCtx.NewTemplate) ctx.HTML(200, orCtx.NewTemplate)
@ -537,7 +543,7 @@ func SlackHooksNewPost(ctx *context.Context, form auth.NewSlackHookForm) {
if form.HasInvalidChannel() { if form.HasInvalidChannel() {
ctx.Flash.Error(ctx.Tr("repo.settings.add_webhook.invalid_channel_name")) ctx.Flash.Error(ctx.Tr("repo.settings.add_webhook.invalid_channel_name"))
ctx.Redirect(orCtx.Link + "/slack/new") ctx.Redirect(orCtx.LinkNew + "/slack/new")
return return
} }
@ -632,12 +638,10 @@ func checkWebhook(ctx *context.Context) (*orgRepoCtx, *models.Webhook) {
w, err = models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) w, err = models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
} else if orCtx.OrgID > 0 { } else if orCtx.OrgID > 0 {
w, err = models.GetWebhookByOrgID(ctx.Org.Organization.ID, ctx.ParamsInt64(":id")) w, err = models.GetWebhookByOrgID(ctx.Org.Organization.ID, ctx.ParamsInt64(":id"))
} else if orCtx.IsSystemWebhook { } else if orCtx.IsAdmin {
w, err = models.GetSystemWebhook(ctx.ParamsInt64(":id")) w, err = models.GetSystemOrDefaultWebhook(ctx.ParamsInt64(":id"))
} else {
w, err = models.GetDefaultWebhook(ctx.ParamsInt64(":id"))
} }
if err != nil { if err != nil || w == nil {
if models.IsErrWebhookNotExist(err) { if models.IsErrWebhookNotExist(err) {
ctx.NotFound("GetWebhookByID", nil) ctx.NotFound("GetWebhookByID", nil)
} else { } else {

View file

@ -370,19 +370,9 @@ func RegisterMacaronRoutes(m *macaron.Macaron) {
m.Post("/delete", admin.DeleteRepo) m.Post("/delete", admin.DeleteRepo)
}) })
m.Group("/^:configType(hooks|system-hooks)$", func() { m.Group("/hooks", func() {
m.Get("", admin.DefaultOrSystemWebhooks) m.Get("", admin.DefaultOrSystemWebhooks)
m.Post("/delete", admin.DeleteDefaultOrSystemWebhook) m.Post("/delete", admin.DeleteDefaultOrSystemWebhook)
m.Get("/:type/new", repo.WebhooksNew)
m.Post("/gitea/new", bindIgnErr(auth.NewWebhookForm{}), repo.GiteaHooksNewPost)
m.Post("/gogs/new", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksNewPost)
m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
m.Post("/discord/new", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksNewPost)
m.Post("/dingtalk/new", bindIgnErr(auth.NewDingtalkHookForm{}), repo.DingtalkHooksNewPost)
m.Post("/telegram/new", bindIgnErr(auth.NewTelegramHookForm{}), repo.TelegramHooksNewPost)
m.Post("/matrix/new", bindIgnErr(auth.NewMatrixHookForm{}), repo.MatrixHooksNewPost)
m.Post("/msteams/new", bindIgnErr(auth.NewMSTeamsHookForm{}), repo.MSTeamsHooksNewPost)
m.Post("/feishu/new", bindIgnErr(auth.NewFeishuHookForm{}), repo.FeishuHooksNewPost)
m.Get("/:id", repo.WebHooksEdit) m.Get("/:id", repo.WebHooksEdit)
m.Post("/gitea/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost) m.Post("/gitea/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost)
m.Post("/gogs/:id", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksEditPost) m.Post("/gogs/:id", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksEditPost)
@ -395,6 +385,19 @@ func RegisterMacaronRoutes(m *macaron.Macaron) {
m.Post("/feishu/:id", bindIgnErr(auth.NewFeishuHookForm{}), repo.FeishuHooksEditPost) m.Post("/feishu/:id", bindIgnErr(auth.NewFeishuHookForm{}), repo.FeishuHooksEditPost)
}) })
m.Group("/^:configType(default-hooks|system-hooks)$", func() {
m.Get("/:type/new", repo.WebhooksNew)
m.Post("/gitea/new", bindIgnErr(auth.NewWebhookForm{}), repo.GiteaHooksNewPost)
m.Post("/gogs/new", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksNewPost)
m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
m.Post("/discord/new", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksNewPost)
m.Post("/dingtalk/new", bindIgnErr(auth.NewDingtalkHookForm{}), repo.DingtalkHooksNewPost)
m.Post("/telegram/new", bindIgnErr(auth.NewTelegramHookForm{}), repo.TelegramHooksNewPost)
m.Post("/matrix/new", bindIgnErr(auth.NewMatrixHookForm{}), repo.MatrixHooksNewPost)
m.Post("/msteams/new", bindIgnErr(auth.NewMSTeamsHookForm{}), repo.MSTeamsHooksNewPost)
m.Post("/feishu/new", bindIgnErr(auth.NewFeishuHookForm{}), repo.FeishuHooksNewPost)
})
m.Group("/auths", func() { m.Group("/auths", func() {
m.Get("", admin.Authentications) m.Get("", admin.Authentications)
m.Combo("/new").Get(admin.NewAuthSource).Post(bindIgnErr(auth.AuthenticationForm{}), admin.NewAuthSourcePost) m.Combo("/new").Get(admin.NewAuthSource).Post(bindIgnErr(auth.AuthenticationForm{}), admin.NewAuthSourcePost)

View file

@ -4,10 +4,14 @@
<div class="ui container"> <div class="ui container">
{{template "base/alert" .}} {{template "base/alert" .}}
<h4 class="ui top attached header"> <h4 class="ui top attached header">
{{if .PageIsAdminHooksNew}} {{if .PageIsAdminDefaultHooksNew}}
{{.i18n.Tr "admin.hooks.add_webhook"}} {{.i18n.Tr "admin.defaulthooks.add_webhook"}}
{{else if .PageIsAdminSystemHooksNew}}
{{.i18n.Tr "admin.systemhooks.add_webhook"}}
{{else if .Webhook.IsSystemWebhook}}
{{.i18n.Tr "admin.systemhooks.update_webhook"}}
{{else}} {{else}}
{{.i18n.Tr "admin.hooks.update_webhook"}} {{.i18n.Tr "admin.defaulthooks.update_webhook"}}
{{end}} {{end}}
<div class="ui right"> <div class="ui right">
{{if eq .HookType "gitea"}} {{if eq .HookType "gitea"}}

View file

@ -2,7 +2,12 @@
<div class="page-content admin hooks"> <div class="page-content admin hooks">
{{template "admin/navbar" .}} {{template "admin/navbar" .}}
<div class="ui container"> <div class="ui container">
{{template "repo/settings/webhook/list" .}} {{template "base/alert" .}}
{{template "repo/settings/webhook/base_list" .SystemWebhooks}}
{{template "repo/settings/webhook/base_list" .DefaultWebhooks}}
{{template "repo/settings/webhook/delete_modal" .}}
</div> </div>
</div> </div>
{{template "base/footer" .}} {{template "base/footer" .}}

View file

@ -12,12 +12,9 @@
<a class="{{if .PageIsAdminRepositories}}active{{end}} item" href="{{AppSubUrl}}/admin/repos"> <a class="{{if .PageIsAdminRepositories}}active{{end}} item" href="{{AppSubUrl}}/admin/repos">
{{.i18n.Tr "admin.repositories"}} {{.i18n.Tr "admin.repositories"}}
</a> </a>
<a class="{{if .PageIsAdminHooks}}active{{end}} item" href="{{AppSubUrl}}/admin/hooks"> <a class="{{if or .PageIsAdminDefaultHooks .PageIsAdminSystemHooks}}active{{end}} item" href="{{AppSubUrl}}/admin/hooks">
{{.i18n.Tr "admin.hooks"}} {{.i18n.Tr "admin.hooks"}}
</a> </a>
<a class="{{if .PageIsAdminSystemHooks}}active{{end}} item" href="{{AppSubUrl}}/admin/system-hooks">
{{.i18n.Tr "admin.systemhooks"}}
</a>
<a class="{{if .PageIsAdminAuthentications}}active{{end}} item" href="{{AppSubUrl}}/admin/auths"> <a class="{{if .PageIsAdminAuthentications}}active{{end}} item" href="{{AppSubUrl}}/admin/auths">
{{.i18n.Tr "admin.authentication"}} {{.i18n.Tr "admin.authentication"}}
</a> </a>

View file

@ -0,0 +1,60 @@
<h4 class="ui top attached header">
{{.Title}}
<div class="ui right">
<div class="ui floating1 jump dropdown">
<div class="ui blue tiny button">{{.i18n.Tr "repo.settings.add_webhook"}}</div>
<div class="menu">
<a class="item" href="{{.BaseLinkNew}}/gitea/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/gitea.svg">Gitea
</a>
<a class="item" href="{{.BaseLinkNew}}/gogs/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/gogs.ico">Gogs
</a>
<a class="item" href="{{.BaseLinkNew}}/slack/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/slack.png">Slack
</a>
<a class="item" href="{{.BaseLinkNew}}/discord/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/discord.png">Discord
</a>
<a class="item" href="{{.BaseLinkNew}}/dingtalk/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/dingtalk.ico">Dingtalk
</a>
<a class="item" href="{{.BaseLinkNew}}/telegram/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/telegram.png">Telegram
</a>
<a class="item" href="{{.BaseLinkNew}}/msteams/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/msteams.png">Microsoft Teams
</a>
<a class="item" href="{{.BaseLinkNew}}/feishu/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/feishu.png">Feishu
</a>
<a class="item" href="{{.BaseLinkNew}}/matrix/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/matrix.svg">Matrix
</a>
</div>
</div>
</div>
</h4>
<div class="ui attached segment">
<div class="ui list">
<div class="item">
{{.Description | Str2html}}
</div>
{{range .Webhooks}}
<div class="item">
{{if eq .LastStatus 1}}
<span class="text green mr-3">{{svg "octicon-check"}}</span>
{{else if eq .LastStatus 2}}
<span class="text red mr-3">{{svg "octicon-alert"}}</span>
{{else}}
<span class="text grey mr-3">{{svg "octicon-dot-fill"}}</span>
{{end}}
<a class="dont-break-out" href="{{$.BaseLink}}/{{.ID}}">{{.URL}}</a>
<div class="ui right">
<span class="text blue px-2"><a href="{{$.BaseLink}}/{{.ID}}">{{svg "octicon-pencil"}}</a></span>
<span class="text red px-2"><a class="delete-button" data-url="{{$.Link}}/delete" data-id="{{.ID}}">{{svg "octicon-trashcan"}}</a></span>
</div>
</div>
{{end}}
</div>
</div>

View file

@ -1,63 +1,5 @@
{{template "base/alert" .}} {{template "base/alert" .}}
<h4 class="ui top attached header">
{{.i18n.Tr "repo.settings.hooks"}} {{template "repo/settings/webhook/base_list" .}}
<div class="ui right">
<div class="ui floating1 jump dropdown">
<div class="ui blue tiny button">{{.i18n.Tr "repo.settings.add_webhook"}}</div>
<div class="menu">
<a class="item" href="{{.BaseLink}}/gitea/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/gitea.svg">Gitea
</a>
<a class="item" href="{{.BaseLink}}/gogs/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/gogs.ico">Gogs
</a>
<a class="item" href="{{.BaseLink}}/slack/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/slack.png">Slack
</a>
<a class="item" href="{{.BaseLink}}/discord/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/discord.png">Discord
</a>
<a class="item" href="{{.BaseLink}}/dingtalk/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/dingtalk.ico">Dingtalk
</a>
<a class="item" href="{{.BaseLink}}/telegram/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/telegram.png">Telegram
</a>
<a class="item" href="{{.BaseLink}}/msteams/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/msteams.png">Microsoft Teams
</a>
<a class="item" href="{{.BaseLink}}/feishu/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/feishu.png">Feishu
</a>
<a class="item" href="{{.BaseLink}}/matrix/new">
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/matrix.svg">Matrix
</a>
</div>
</div>
</div>
</h4>
<div class="ui attached segment">
<div class="ui list">
<div class="item">
{{.Description | Str2html}}
</div>
{{range .Webhooks}}
<div class="item">
{{if eq .LastStatus 1}}
<span class="text green mr-3">{{svg "octicon-check"}}</span>
{{else if eq .LastStatus 2}}
<span class="text red mr-3">{{svg "octicon-alert"}}</span>
{{else}}
<span class="text grey mr-3">{{svg "octicon-dot-fill"}}</span>
{{end}}
<a class="dont-break-out" href="{{$.BaseLink}}/{{.ID}}">{{.URL}}</a>
<div class="ui right">
<span class="text blue px-2"><a href="{{$.BaseLink}}/{{.ID}}">{{svg "octicon-pencil"}}</a></span>
<span class="text red px-2"><a class="delete-button" data-url="{{$.Link}}/delete" data-id="{{.ID}}">{{svg "octicon-trashcan"}}</a></span>
</div>
</div>
{{end}}
</div>
</div>
{{template "repo/settings/webhook/delete_modal" .}} {{template "repo/settings/webhook/delete_modal" .}}

View file

@ -1,4 +1,4 @@
{{$isNew:=or .PageIsSettingsHooksNew .PageIsAdminHooksNew}} {{$isNew:=or .PageIsSettingsHooksNew .PageIsAdminDefaultHooksNew .PageIsAdminSystemHooksNew}}
<div class="field"> <div class="field">
<h4>{{.i18n.Tr "repo.settings.event_desc"}}</h4> <h4>{{.i18n.Tr "repo.settings.event_desc"}}</h4>
<div class="grouped event type fields"> <div class="grouped event type fields">