new create webhook UI
This commit is contained in:
parent
2881456421
commit
4217c2333c
21 changed files with 307 additions and 273 deletions
13
cmd/web.go
13
cmd/web.go
|
@ -411,11 +411,11 @@ func runWeb(ctx *cli.Context) {
|
||||||
m.Group("/hooks", func() {
|
m.Group("/hooks", func() {
|
||||||
m.Get("", org.Webhooks)
|
m.Get("", org.Webhooks)
|
||||||
m.Post("/delete", org.DeleteWebhook)
|
m.Post("/delete", org.DeleteWebhook)
|
||||||
|
m.Get("/:type/new", repo.WebhooksNew)
|
||||||
|
m.Post("/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost)
|
||||||
|
m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
|
||||||
})
|
})
|
||||||
|
|
||||||
m.Get("/hooks/new", repo.WebHooksNew)
|
|
||||||
m.Post("/hooks/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost)
|
|
||||||
m.Post("/hooks/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
|
|
||||||
m.Get("/hooks/:id", repo.WebHooksEdit)
|
m.Get("/hooks/:id", repo.WebHooksEdit)
|
||||||
m.Post("/hooks/gogs/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost)
|
m.Post("/hooks/gogs/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost)
|
||||||
m.Post("/hooks/slack/:id", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksEditPost)
|
m.Post("/hooks/slack/:id", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksEditPost)
|
||||||
|
@ -449,10 +449,11 @@ func runWeb(ctx *cli.Context) {
|
||||||
m.Group("/hooks", func() {
|
m.Group("/hooks", func() {
|
||||||
m.Get("", repo.Webhooks)
|
m.Get("", repo.Webhooks)
|
||||||
m.Post("/delete", repo.DeleteWebhook)
|
m.Post("/delete", repo.DeleteWebhook)
|
||||||
|
m.Get("/:type/new", repo.WebhooksNew)
|
||||||
|
m.Post("/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost)
|
||||||
|
m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
|
||||||
})
|
})
|
||||||
m.Get("/hooks/new", repo.WebHooksNew)
|
|
||||||
m.Post("/hooks/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost)
|
|
||||||
m.Post("/hooks/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
|
|
||||||
m.Get("/hooks/:id", repo.WebHooksEdit)
|
m.Get("/hooks/:id", repo.WebHooksEdit)
|
||||||
m.Post("/hooks/gogs/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost)
|
m.Post("/hooks/gogs/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost)
|
||||||
m.Post("/hooks/slack/:id", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksEditPost)
|
m.Post("/hooks/slack/:id", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksEditPost)
|
||||||
|
|
|
@ -235,6 +235,17 @@
|
||||||
"outputPathIsSetByUser": 0,
|
"outputPathIsSetByUser": 0,
|
||||||
"processed": 1
|
"processed": 1
|
||||||
},
|
},
|
||||||
|
"\/public\/img\/slack.png": {
|
||||||
|
"fileType": 32768,
|
||||||
|
"ignore": 0,
|
||||||
|
"ignoreWasSetByUser": 0,
|
||||||
|
"initialSize": 1633,
|
||||||
|
"inputAbbreviatedPath": "\/public\/img\/slack.png",
|
||||||
|
"outputAbbreviatedPath": "\/public\/img\/slack.png",
|
||||||
|
"outputPathIsOutsideProject": 0,
|
||||||
|
"outputPathIsSetByUser": 0,
|
||||||
|
"processed": 0
|
||||||
|
},
|
||||||
"\/public\/less\/_admin.less": {
|
"\/public\/less\/_admin.less": {
|
||||||
"allowInsecureImports": 0,
|
"allowInsecureImports": 0,
|
||||||
"createSourceMap": 0,
|
"createSourceMap": 0,
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.6.6.0826 Beta"
|
const APP_VER = "0.6.6.0827 Beta"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -65,13 +65,17 @@ func (f *RepoSettingForm) Validate(ctx *macaron.Context, errs binding.Errors) bi
|
||||||
// \__/\ / \___ >___ /___| /___| /\____/|__|_ \
|
// \__/\ / \___ >___ /___| /___| /\____/|__|_ \
|
||||||
// \/ \/ \/ \/ \/ \/
|
// \/ \/ \/ \/ \/ \/
|
||||||
|
|
||||||
|
type WebhookForm struct {
|
||||||
|
HookType string `binding:"Required"`
|
||||||
|
PushOnly bool
|
||||||
|
Active bool
|
||||||
|
}
|
||||||
|
|
||||||
type NewWebhookForm struct {
|
type NewWebhookForm struct {
|
||||||
HookTaskType string `form:"hook_type" binding:"Required"`
|
PayloadURL string `binding:"Required;Url"`
|
||||||
PayloadUrl string `form:"payload_url" binding:"Required;Url"`
|
ContentType int `binding:"Required"`
|
||||||
ContentType string `form:"content_type" binding:"Required"`
|
Secret string
|
||||||
Secret string `form:"secret"`
|
WebhookForm
|
||||||
PushOnly bool `form:"push_only"`
|
|
||||||
Active bool `form:"active"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *NewWebhookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
func (f *NewWebhookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||||
|
@ -79,11 +83,9 @@ func (f *NewWebhookForm) Validate(ctx *macaron.Context, errs binding.Errors) bin
|
||||||
}
|
}
|
||||||
|
|
||||||
type NewSlackHookForm struct {
|
type NewSlackHookForm struct {
|
||||||
HookTaskType string `form:"hook_type" binding:"Required"`
|
PayloadURL string `binding:"Required`
|
||||||
PayloadUrl string `form:"payload_url" binding:"Required`
|
Channel string `binding:"Required"`
|
||||||
Channel string `form:"channel" binding:"Required"`
|
WebhookForm
|
||||||
PushOnly bool `form:"push_only"`
|
|
||||||
Active bool `form:"active"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *NewSlackHookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
func (f *NewSlackHookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||||
|
|
|
@ -26,6 +26,27 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type RepoContext struct {
|
||||||
|
AccessMode models.AccessMode
|
||||||
|
IsWatching bool
|
||||||
|
IsBranch bool
|
||||||
|
IsTag bool
|
||||||
|
IsCommit bool
|
||||||
|
Repository *models.Repository
|
||||||
|
Owner *models.User
|
||||||
|
Commit *git.Commit
|
||||||
|
Tag *git.Tag
|
||||||
|
GitRepo *git.Repository
|
||||||
|
BranchName string
|
||||||
|
TagName string
|
||||||
|
TreeName string
|
||||||
|
CommitId string
|
||||||
|
RepoLink string
|
||||||
|
CloneLink models.CloneLink
|
||||||
|
CommitsCount int
|
||||||
|
Mirror *models.Mirror
|
||||||
|
}
|
||||||
|
|
||||||
// Context represents context of a request.
|
// Context represents context of a request.
|
||||||
type Context struct {
|
type Context struct {
|
||||||
*macaron.Context
|
*macaron.Context
|
||||||
|
@ -51,27 +72,6 @@ type Context struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type RepoContext struct {
|
|
||||||
AccessMode models.AccessMode
|
|
||||||
IsWatching bool
|
|
||||||
IsBranch bool
|
|
||||||
IsTag bool
|
|
||||||
IsCommit bool
|
|
||||||
Repository *models.Repository
|
|
||||||
Owner *models.User
|
|
||||||
Commit *git.Commit
|
|
||||||
Tag *git.Tag
|
|
||||||
GitRepo *git.Repository
|
|
||||||
BranchName string
|
|
||||||
TagName string
|
|
||||||
TreeName string
|
|
||||||
CommitId string
|
|
||||||
RepoLink string
|
|
||||||
CloneLink models.CloneLink
|
|
||||||
CommitsCount int
|
|
||||||
Mirror *models.Mirror
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsOwner returns true if current user is the owner of repository.
|
// IsOwner returns true if current user is the owner of repository.
|
||||||
func (r RepoContext) IsOwner() bool {
|
func (r RepoContext) IsOwner() bool {
|
||||||
return r.AccessMode >= models.ACCESS_MODE_OWNER
|
return r.AccessMode >= models.ACCESS_MODE_OWNER
|
||||||
|
|
|
@ -81,6 +81,7 @@ var (
|
||||||
QueueLength int
|
QueueLength int
|
||||||
DeliverTimeout int
|
DeliverTimeout int
|
||||||
SkipTLSVerify bool
|
SkipTLSVerify bool
|
||||||
|
Types []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Repository settings.
|
// Repository settings.
|
||||||
|
@ -599,6 +600,7 @@ func newWebhookService() {
|
||||||
Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000)
|
Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000)
|
||||||
Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
|
Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
|
||||||
Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
|
Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
|
||||||
|
Webhook.Types = []string{"gogs", "slack"}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServices() {
|
func NewServices() {
|
||||||
|
|
2
public/css/gogs.min.css
vendored
2
public/css/gogs.min.css
vendored
File diff suppressed because one or more lines are too long
BIN
public/img/slack.png
Normal file
BIN
public/img/slack.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
|
@ -80,3 +80,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.new.webhook {
|
||||||
|
form {
|
||||||
|
.help {
|
||||||
|
margin-left: 25px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -247,7 +247,7 @@ func Collaboration(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Webhooks(ctx *middleware.Context) {
|
func Webhooks(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
ctx.Data["Title"] = ctx.Tr("repo.settings.hooks")
|
||||||
ctx.Data["PageIsSettingsHooks"] = true
|
ctx.Data["PageIsSettingsHooks"] = true
|
||||||
ctx.Data["BaseLink"] = ctx.Repo.RepoLink
|
ctx.Data["BaseLink"] = ctx.Repo.RepoLink
|
||||||
ctx.Data["Description"] = ctx.Tr("repo.settings.hooks_desc", "http://gogs.io/docs/features/webhook.html")
|
ctx.Data["Description"] = ctx.Tr("repo.settings.hooks_desc", "http://gogs.io/docs/features/webhook.html")
|
||||||
|
@ -262,65 +262,100 @@ func Webhooks(ctx *middleware.Context) {
|
||||||
ctx.HTML(200, HOOKS)
|
ctx.HTML(200, HOOKS)
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderHookTypes(ctx *middleware.Context) {
|
type OrgRepoCtx struct {
|
||||||
ctx.Data["HookTypes"] = []string{"Gogs", "Slack"}
|
OrgID int64
|
||||||
ctx.Data["HookType"] = "Gogs"
|
RepoID int64
|
||||||
|
Link string
|
||||||
|
NewTemplate base.TplName
|
||||||
}
|
}
|
||||||
|
|
||||||
func WebHooksNew(ctx *middleware.Context) {
|
// getOrgRepoCtx determines whether this is a repo context or organization context.
|
||||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
func getOrgRepoCtx(ctx *middleware.Context) (*OrgRepoCtx, error) {
|
||||||
|
if len(ctx.Repo.RepoLink) > 0 {
|
||||||
|
return &OrgRepoCtx{
|
||||||
|
RepoID: ctx.Repo.Repository.ID,
|
||||||
|
Link: ctx.Repo.RepoLink,
|
||||||
|
NewTemplate: HOOK_NEW,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(ctx.Org.OrgLink) > 0 {
|
||||||
|
return &OrgRepoCtx{
|
||||||
|
OrgID: ctx.Org.Organization.Id,
|
||||||
|
Link: ctx.Org.OrgLink,
|
||||||
|
NewTemplate: ORG_HOOK_NEW,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errors.New("Unable to set OrgRepo context")
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkHookType(ctx *middleware.Context) string {
|
||||||
|
hookType := strings.ToLower(ctx.Params(":type"))
|
||||||
|
if !com.IsSliceContainsStr(setting.Webhook.Types, hookType) {
|
||||||
|
ctx.Handle(404, "checkHookType", nil)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return hookType
|
||||||
|
}
|
||||||
|
|
||||||
|
func WebhooksNew(ctx *middleware.Context) {
|
||||||
|
ctx.Data["Title"] = ctx.Tr("repo.settings.add_webhook")
|
||||||
ctx.Data["PageIsSettingsHooks"] = true
|
ctx.Data["PageIsSettingsHooks"] = true
|
||||||
ctx.Data["PageIsSettingsHooksNew"] = true
|
ctx.Data["PageIsSettingsHooksNew"] = true
|
||||||
ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}}
|
ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}}
|
||||||
renderHookTypes(ctx)
|
|
||||||
|
|
||||||
orCtx, err := getOrgRepoCtx(ctx)
|
orCtx, err := getOrgRepoCtx(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "WebHooksNew(getOrgRepoCtx)", err)
|
ctx.Handle(500, "getOrgRepoCtx", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.Data["HookType"] = checkHookType(ctx)
|
||||||
|
if ctx.Written() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.Data["BaseLink"] = orCtx.Link
|
||||||
|
|
||||||
ctx.HTML(200, orCtx.NewTemplate)
|
ctx.HTML(200, orCtx.NewTemplate)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
||||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
ctx.Data["Title"] = ctx.Tr("repo.settings.add_webhook")
|
||||||
ctx.Data["PageIsSettingsHooks"] = true
|
ctx.Data["PageIsSettingsHooks"] = true
|
||||||
ctx.Data["PageIsSettingsHooksNew"] = true
|
ctx.Data["PageIsSettingsHooksNew"] = true
|
||||||
ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}}
|
ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}}
|
||||||
renderHookTypes(ctx)
|
ctx.Data["HookType"] = "gogs"
|
||||||
|
|
||||||
orCtx, err := getOrgRepoCtx(ctx)
|
orCtx, err := getOrgRepoCtx(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "WebHooksNewPost(getOrgRepoCtx)", err)
|
ctx.Handle(500, "getOrgRepoCtx", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ctx.Data["BaseLink"] = orCtx.Link
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, orCtx.NewTemplate)
|
ctx.HTML(200, orCtx.NewTemplate)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: code too old here, sync with APIs
|
contentType := models.JSON
|
||||||
ct := models.JSON
|
if models.HookContentType(form.ContentType) == models.FORM {
|
||||||
if form.ContentType == "2" {
|
contentType = models.FORM
|
||||||
ct = models.FORM
|
|
||||||
}
|
}
|
||||||
|
|
||||||
w := &models.Webhook{
|
w := &models.Webhook{
|
||||||
RepoID: orCtx.RepoId,
|
RepoID: orCtx.RepoID,
|
||||||
URL: form.PayloadUrl,
|
URL: form.PayloadURL,
|
||||||
ContentType: ct,
|
ContentType: contentType,
|
||||||
Secret: form.Secret,
|
Secret: form.Secret,
|
||||||
HookEvent: &models.HookEvent{
|
HookEvent: &models.HookEvent{
|
||||||
PushOnly: form.PushOnly,
|
PushOnly: form.PushOnly,
|
||||||
},
|
},
|
||||||
IsActive: form.Active,
|
IsActive: form.Active,
|
||||||
HookTaskType: models.GOGS,
|
HookTaskType: models.GOGS,
|
||||||
Meta: "",
|
OrgID: orCtx.OrgID,
|
||||||
OrgID: orCtx.OrgId,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := w.UpdateEvent(); err != nil {
|
if err := w.UpdateEvent(); err != nil {
|
||||||
ctx.Handle(500, "UpdateEvent", err)
|
ctx.Handle(500, "UpdateEvent", err)
|
||||||
return
|
return
|
||||||
|
@ -334,17 +369,18 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func WebHooksEdit(ctx *middleware.Context) {
|
func WebHooksEdit(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
ctx.Data["Title"] = ctx.Tr("repo.settings.update_webhook")
|
||||||
ctx.Data["PageIsSettingsHooks"] = true
|
ctx.Data["PageIsSettingsHooks"] = true
|
||||||
ctx.Data["PageIsSettingsHooksEdit"] = true
|
ctx.Data["PageIsSettingsHooksEdit"] = true
|
||||||
|
|
||||||
hookId := com.StrTo(ctx.Params(":id")).MustInt64()
|
orCtx, err := getOrgRepoCtx(ctx)
|
||||||
if hookId == 0 {
|
if err != nil {
|
||||||
ctx.Handle(404, "setting.WebHooksEdit", nil)
|
ctx.Handle(500, "getOrgRepoCtx", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ctx.Data["BaseLink"] = orCtx.Link
|
||||||
|
|
||||||
w, err := models.GetWebhookById(hookId)
|
w, err := models.GetWebhookById(ctx.ParamsInt64(":id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrWebhookNotExist {
|
if err == models.ErrWebhookNotExist {
|
||||||
ctx.Handle(404, "GetWebhookById", nil)
|
ctx.Handle(404, "GetWebhookById", nil)
|
||||||
|
@ -354,36 +390,25 @@ func WebHooksEdit(ctx *middleware.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// set data per HookTaskType
|
|
||||||
switch w.HookTaskType {
|
switch w.HookTaskType {
|
||||||
case models.SLACK:
|
case models.SLACK:
|
||||||
ctx.Data["SlackHook"] = w.GetSlackHook()
|
ctx.Data["SlackHook"] = w.GetSlackHook()
|
||||||
ctx.Data["HookType"] = "Slack"
|
ctx.Data["HookType"] = "slack"
|
||||||
default:
|
default:
|
||||||
ctx.Data["HookType"] = "Gogs"
|
ctx.Data["HookType"] = "gogs"
|
||||||
}
|
}
|
||||||
w.GetEvent()
|
w.GetEvent()
|
||||||
ctx.Data["Webhook"] = w
|
ctx.Data["Webhook"] = w
|
||||||
orCtx, err := getOrgRepoCtx(ctx)
|
|
||||||
if err != nil {
|
|
||||||
ctx.Handle(500, "WebHooksEdit(getOrgRepoCtx)", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ctx.HTML(200, orCtx.NewTemplate)
|
ctx.HTML(200, orCtx.NewTemplate)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
||||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
ctx.Data["Title"] = ctx.Tr("repo.settings.update_webhook")
|
||||||
ctx.Data["PageIsSettingsHooks"] = true
|
ctx.Data["PageIsSettingsHooks"] = true
|
||||||
ctx.Data["PageIsSettingsHooksEdit"] = true
|
ctx.Data["PageIsSettingsHooksEdit"] = true
|
||||||
|
|
||||||
hookId := com.StrTo(ctx.Params(":id")).MustInt64()
|
w, err := models.GetWebhookById(ctx.ParamsInt64(":id"))
|
||||||
if hookId == 0 {
|
|
||||||
ctx.Handle(404, "setting.WebHooksEditPost", nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
w, err := models.GetWebhookById(hookId)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrWebhookNotExist {
|
if err == models.ErrWebhookNotExist {
|
||||||
ctx.Handle(404, "GetWebhookById", nil)
|
ctx.Handle(404, "GetWebhookById", nil)
|
||||||
|
@ -406,20 +431,22 @@ func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
||||||
|
|
||||||
orCtx, err := getOrgRepoCtx(ctx)
|
orCtx, err := getOrgRepoCtx(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "WebHooksEditPost(getOrgRepoCtx)", err)
|
ctx.Handle(500, "getOrgRepoCtx", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ctx.Data["BaseLink"] = orCtx.Link
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, orCtx.NewTemplate)
|
ctx.HTML(200, orCtx.NewTemplate)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ct := models.JSON
|
ct := models.JSON
|
||||||
if form.ContentType == "2" {
|
if models.HookContentType(form.ContentType) == models.FORM {
|
||||||
ct = models.FORM
|
ct = models.FORM
|
||||||
}
|
}
|
||||||
|
|
||||||
w.URL = form.PayloadUrl
|
w.URL = form.PayloadURL
|
||||||
w.ContentType = ct
|
w.ContentType = ct
|
||||||
w.Secret = form.Secret
|
w.Secret = form.Secret
|
||||||
w.HookEvent = &models.HookEvent{
|
w.HookEvent = &models.HookEvent{
|
||||||
|
@ -435,7 +462,7 @@ func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Flash.Success(ctx.Tr("repo.settings.update_hook_success"))
|
ctx.Flash.Success(ctx.Tr("repo.settings.update_hook_success"))
|
||||||
ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", orCtx.Link, hookId))
|
ctx.Redirect(orCtx.Link + "/settings/hooks")
|
||||||
}
|
}
|
||||||
|
|
||||||
func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) {
|
func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) {
|
||||||
|
@ -464,8 +491,8 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
w := &models.Webhook{
|
w := &models.Webhook{
|
||||||
RepoID: orCtx.RepoId,
|
RepoID: orCtx.RepoID,
|
||||||
URL: form.PayloadUrl,
|
URL: form.PayloadURL,
|
||||||
ContentType: models.JSON,
|
ContentType: models.JSON,
|
||||||
Secret: "",
|
Secret: "",
|
||||||
HookEvent: &models.HookEvent{
|
HookEvent: &models.HookEvent{
|
||||||
|
@ -474,7 +501,7 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) {
|
||||||
IsActive: form.Active,
|
IsActive: form.Active,
|
||||||
HookTaskType: models.SLACK,
|
HookTaskType: models.SLACK,
|
||||||
Meta: string(meta),
|
Meta: string(meta),
|
||||||
OrgID: orCtx.OrgId,
|
OrgID: orCtx.OrgID,
|
||||||
}
|
}
|
||||||
if err := w.UpdateEvent(); err != nil {
|
if err := w.UpdateEvent(); err != nil {
|
||||||
ctx.Handle(500, "UpdateEvent", err)
|
ctx.Handle(500, "UpdateEvent", err)
|
||||||
|
@ -529,7 +556,7 @@ func SlackHooksEditPost(ctx *middleware.Context, form auth.NewSlackHookForm) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.URL = form.PayloadUrl
|
w.URL = form.PayloadURL
|
||||||
w.Meta = string(meta)
|
w.Meta = string(meta)
|
||||||
w.HookEvent = &models.HookEvent{
|
w.HookEvent = &models.HookEvent{
|
||||||
PushOnly: form.PushOnly,
|
PushOnly: form.PushOnly,
|
||||||
|
@ -559,34 +586,6 @@ func DeleteWebhook(ctx *middleware.Context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type OrgRepoCtx struct {
|
|
||||||
OrgId int64
|
|
||||||
RepoId int64
|
|
||||||
Link string
|
|
||||||
NewTemplate base.TplName
|
|
||||||
}
|
|
||||||
|
|
||||||
// determines whether this is a repo context or organization context
|
|
||||||
func getOrgRepoCtx(ctx *middleware.Context) (*OrgRepoCtx, error) {
|
|
||||||
if _, ok := ctx.Data["RepoLink"]; ok {
|
|
||||||
return &OrgRepoCtx{
|
|
||||||
OrgId: int64(0),
|
|
||||||
RepoId: ctx.Repo.Repository.ID,
|
|
||||||
Link: ctx.Repo.RepoLink,
|
|
||||||
NewTemplate: HOOK_NEW,
|
|
||||||
}, nil
|
|
||||||
} else if _, ok := ctx.Data["OrgLink"]; ok {
|
|
||||||
return &OrgRepoCtx{
|
|
||||||
OrgId: ctx.Org.Organization.Id,
|
|
||||||
RepoId: int64(0),
|
|
||||||
Link: ctx.Org.OrgLink,
|
|
||||||
NewTemplate: ORG_HOOK_NEW,
|
|
||||||
}, nil
|
|
||||||
} else {
|
|
||||||
return &OrgRepoCtx{}, errors.New("Unable to set OrgRepo context")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TriggerHook(ctx *middleware.Context) {
|
func TriggerHook(ctx *middleware.Context) {
|
||||||
u, err := models.GetUserByName(ctx.Params(":username"))
|
u, err := models.GetUserByName(ctx.Params(":username"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -611,7 +610,7 @@ func TriggerHook(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GitHooks(ctx *middleware.Context) {
|
func GitHooks(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
ctx.Data["Title"] = ctx.Tr("repo.settings.githooks")
|
||||||
ctx.Data["PageIsSettingsGitHooks"] = true
|
ctx.Data["PageIsSettingsGitHooks"] = true
|
||||||
|
|
||||||
hooks, err := ctx.Repo.GitRepo.Hooks()
|
hooks, err := ctx.Repo.GitRepo.Hooks()
|
||||||
|
@ -625,7 +624,7 @@ func GitHooks(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GitHooksEdit(ctx *middleware.Context) {
|
func GitHooksEdit(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
ctx.Data["Title"] = ctx.Tr("repo.settings.githooks")
|
||||||
ctx.Data["PageIsSettingsGitHooks"] = true
|
ctx.Data["PageIsSettingsGitHooks"] = true
|
||||||
|
|
||||||
name := ctx.Params(":name")
|
name := ctx.Params(":name")
|
||||||
|
@ -662,7 +661,7 @@ func GitHooksEditPost(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeployKeys(ctx *middleware.Context) {
|
func DeployKeys(ctx *middleware.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
ctx.Data["Title"] = ctx.Tr("repo.settings.deploy_keys")
|
||||||
ctx.Data["PageIsSettingsKeys"] = true
|
ctx.Data["PageIsSettingsKeys"] = true
|
||||||
|
|
||||||
keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID)
|
keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID)
|
||||||
|
@ -676,7 +675,7 @@ func DeployKeys(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeployKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
func DeployKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
||||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
ctx.Data["Title"] = ctx.Tr("repo.settings.deploy_keys")
|
||||||
ctx.Data["PageIsSettingsKeys"] = true
|
ctx.Data["PageIsSettingsKeys"] = true
|
||||||
|
|
||||||
keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID)
|
keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.6.6.0826 Beta
|
0.6.6.0827 Beta
|
|
@ -1,37 +1,29 @@
|
||||||
{{template "ng/base/head" .}}
|
{{template "base/head" .}}
|
||||||
{{template "ng/base/header" .}}
|
<div class="organization settings new webhook">
|
||||||
{{template "org/base/header" .}}
|
{{template "org/header" .}}
|
||||||
<div id="setting-wrapper" class="main-wrapper">
|
<div class="ui container">
|
||||||
<div id="org-setting" class="container clear">
|
<div class="ui grid">
|
||||||
{{template "org/settings/nav" .}}
|
{{template "org/settings/navbar" .}}
|
||||||
<div class="grid-4-5 left">
|
<div class="twelve wide column content">
|
||||||
<div class="setting-content">
|
{{template "base/alert" .}}
|
||||||
{{template "ng/base/alert" .}}
|
<h4 class="ui top attached header">
|
||||||
<div id="setting-content">
|
{{if .PageIsSettingsHooksNew}}{{.i18n.Tr "repo.settings.add_webhook"}}{{else}}{{.i18n.Tr "repo.settings.update_webhook"}}{{end}}
|
||||||
<div id="repo-hooks-panel" class="panel panel-radius">
|
<div class="ui right">
|
||||||
<div class="panel-header">
|
{{if eq .HookType "gogs"}}
|
||||||
<strong>{{if .PageIsSettingsHooksNew}}{{.i18n.Tr "repo.settings.add_webhook"}}{{else}}{{.i18n.Tr "repo.settings.update_webhook"}}{{end}}</strong>
|
<img class="img-13" src="{{AppSubUrl}}/img/favicon.png">
|
||||||
|
{{else if eq .HookType "slack"}}
|
||||||
|
<img class="img-13" src="{{AppSubUrl}}/img/slack.png">
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{template "repo/settings/hook_types" .}}
|
</h4>
|
||||||
|
<div class="ui attached segment">
|
||||||
{{template "repo/settings/hook_gogs" .}}
|
{{template "repo/settings/hook_gogs" .}}
|
||||||
{{template "repo/settings/hook_slack" .}}
|
{{template "repo/settings/hook_slack" .}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{{if .PageIsSettingsHooksEdit}}
|
{{template "repo/settings/hook_history" .}}
|
||||||
<br>
|
|
||||||
<div id="setting-content">
|
|
||||||
<div id="repo-hooks-history-panel" class="panel panel-radius">
|
|
||||||
<div class="panel-header">
|
|
||||||
<strong>{{.i18n.Tr "repo.settings.recent_deliveries"}}</strong>
|
|
||||||
</div>
|
|
||||||
<ul class="panel-body setting-list">
|
|
||||||
<li>Coming soon!</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{template "ng/base/footer" .}}
|
{{template "base/footer" .}}
|
||||||
|
|
19
templates/repo/settings/hook_delete_modal.tmpl
Normal file
19
templates/repo/settings/hook_delete_modal.tmpl
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<div class="ui small basic delete modal">
|
||||||
|
<div class="ui icon header">
|
||||||
|
<i class="trash icon"></i>
|
||||||
|
{{.i18n.Tr "repo.settings.webhook_deletion"}}
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<p>{{.i18n.Tr "repo.settings.webhook_deletion_desc"}}</p>
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<div class="ui red basic inverted cancel button">
|
||||||
|
<i class="remove icon"></i>
|
||||||
|
{{.i18n.Tr "modal.no"}}
|
||||||
|
</div>
|
||||||
|
<div class="ui green basic inverted ok button">
|
||||||
|
<i class="checkmark icon"></i>
|
||||||
|
{{.i18n.Tr "modal.yes"}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -1,23 +1,28 @@
|
||||||
<div id="gogs" class="{{if (and .PageIsSettingsHooksEdit (not (eq .HookType "Gogs")))}}hidden{{end}}">
|
{{if eq .HookType "gogs"}}
|
||||||
<form class="form form-align panel-body repo-setting-form" id="repo-setting-form-gogs" action="{{if .RepoLink}}{{.RepoLink}}{{else if .OrgLink}}{{.OrgLink}}{{end}}/settings/hooks/gogs/{{if .PageIsSettingsHooksNew}}new{{else}}{{.Webhook.ID}}{{end}}" method="post">
|
<p>{{.i18n.Tr "repo.settings.add_webhook_desc" "http://gogs.io/docs/features/webhook.html" | Str2html}}</p>
|
||||||
|
<form class="ui form" action="{{.BaseLink}}/settings/hooks/{{if .PageIsSettingsHooksNew}}gogs/new{{else}}{{.Webhook.ID}}{{end}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<input type="hidden" name="hook_type" value="gogs">
|
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
||||||
<div class="text-center panel-desc">{{.i18n.Tr "repo.settings.add_webhook_desc" "http://gogs.io/docs/features/webhook.html" | Str2html}}</div>
|
<label for="payload_url">{{.i18n.Tr "repo.settings.payload_url"}}</label>
|
||||||
<div class="field">
|
<input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required>
|
||||||
<label class="req" for="payload-url">{{.i18n.Tr "repo.settings.payload_url"}}</label>
|
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_UserName}}ipt-error{{end}}" id="payload-url" name="payload_url" type="url" value="{{.Webhook.URL}}" required />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="req">{{.i18n.Tr "repo.settings.content_type"}}</label>
|
<label>{{.i18n.Tr "repo.settings.content_type"}}</label>
|
||||||
<select name="content_type">
|
<div class="ui selection dropdown">
|
||||||
<option value="1" {{if or .PageIsSettingsHooksNew (eq .Webhook.ContentType 1)}}selected{{end}}>application/json</option>
|
<input type="hidden" id="content_type" name="content_type" value="{{if .Webhook.ContentType}}{{.Webhook.ContentType}}{{else}}application/json{{end}}">
|
||||||
<option value="2" {{if eq .Webhook.ContentType 2}}selected{{end}}>application/x-www-form-urlencoded</option>
|
<div class="default text"></div>
|
||||||
</select>
|
<i class="dropdown icon"></i>
|
||||||
|
<div class="menu">
|
||||||
|
<div class="item" data-value="1">application/json</div>
|
||||||
|
<div class="item" data-value="2">application/x-www-form-urlencoded</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
</div>
|
||||||
|
</div>
|
||||||
|
<input class="fake" type="password">
|
||||||
|
<div class="field {{if .Err_Secret}}error{{end}}">
|
||||||
<label for="secret">{{.i18n.Tr "repo.settings.secret"}}</label>
|
<label for="secret">{{.i18n.Tr "repo.settings.secret"}}</label>
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_UserName}}ipt-error{{end}}" id="secret" name="secret" type="password" value="{{.Webhook.Secret}}" autocomplete="off" />
|
<input id="secret" name="secret" type="password" value="{{.Webhook.Secret}}" autocomplete="off">
|
||||||
</div>
|
</div>
|
||||||
{{template "repo/settings/hook_settings" .}}
|
{{template "repo/settings/hook_settings" .}}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
{{end}}
|
||||||
|
|
12
templates/repo/settings/hook_history.tmpl
Normal file
12
templates/repo/settings/hook_history.tmpl
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{{if .PageIsSettingsHooksEdit}}
|
||||||
|
<div id="setting-content">
|
||||||
|
<div id="repo-hooks-history-panel" class="panel panel-radius">
|
||||||
|
<div class="panel-header">
|
||||||
|
<strong>{{.i18n.Tr "repo.settings.recent_deliveries"}}</strong>
|
||||||
|
</div>
|
||||||
|
<ul class="panel-body setting-list">
|
||||||
|
<li>Coming soon!</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
|
@ -3,7 +3,17 @@
|
||||||
<h4 class="ui top attached header">
|
<h4 class="ui top attached header">
|
||||||
{{.i18n.Tr "repo.settings.hooks"}}
|
{{.i18n.Tr "repo.settings.hooks"}}
|
||||||
<div class="ui right">
|
<div class="ui right">
|
||||||
<a class="ui blue tiny button" href="{{.BaseLink}}/settings/hooks/new">{{.i18n.Tr "repo.settings.add_webhook"}}</a>
|
<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}}/settings/hooks/gogs/new">
|
||||||
|
<img class="img-10" src="{{AppSubUrl}}/img/favicon.png">Gogs
|
||||||
|
</a>
|
||||||
|
<a class="item" href="{{.BaseLink}}/settings/hooks/slack/new">
|
||||||
|
<img class="img-10" src="{{AppSubUrl}}/img/slack.png">Slack
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</h4>
|
</h4>
|
||||||
<div class="ui attached table segment">
|
<div class="ui attached table segment">
|
||||||
|
@ -31,22 +41,4 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ui small basic delete modal">
|
{{template "repo/settings/hook_delete_modal" .}}
|
||||||
<div class="ui icon header">
|
|
||||||
<i class="trash icon"></i>
|
|
||||||
{{.i18n.Tr "repo.settings.webhook_deletion"}}
|
|
||||||
</div>
|
|
||||||
<div class="content">
|
|
||||||
<p>{{.i18n.Tr "repo.settings.webhook_deletion_desc"}}</p>
|
|
||||||
</div>
|
|
||||||
<div class="actions">
|
|
||||||
<div class="ui red basic inverted cancel button">
|
|
||||||
<i class="remove icon"></i>
|
|
||||||
{{.i18n.Tr "modal.no"}}
|
|
||||||
</div>
|
|
||||||
<div class="ui green basic inverted ok button">
|
|
||||||
<i class="checkmark icon"></i>
|
|
||||||
{{.i18n.Tr "modal.yes"}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
|
@ -1,39 +1,29 @@
|
||||||
{{template "ng/base/head" .}}
|
{{template "base/head" .}}
|
||||||
{{template "ng/base/header" .}}
|
<div class="repository settings new webhook">
|
||||||
<div id="repo-wrapper">
|
{{template "repo/header" .}}
|
||||||
{{template "repo/header_old" .}}
|
<div class="ui container">
|
||||||
<div id="setting-wrapper" class="main-wrapper">
|
<div class="ui grid">
|
||||||
<div id="repo-setting" class="container clear">
|
{{template "repo/settings/navbar" .}}
|
||||||
{{template "repo/settings/nav" .}}
|
<div class="twelve wide column content">
|
||||||
<div class="grid-4-5 left">
|
{{template "base/alert" .}}
|
||||||
<div class="setting-content">
|
<h4 class="ui top attached header">
|
||||||
{{template "ng/base/alert" .}}
|
{{if .PageIsSettingsHooksNew}}{{.i18n.Tr "repo.settings.add_webhook"}}{{else}}{{.i18n.Tr "repo.settings.update_webhook"}}{{end}}
|
||||||
<div id="setting-content">
|
<div class="ui right">
|
||||||
<div id="repo-hooks-panel" class="panel panel-radius">
|
{{if eq .HookType "gogs"}}
|
||||||
<div class="panel-header">
|
<img class="img-13" src="{{AppSubUrl}}/img/favicon.png">
|
||||||
<strong>{{if .PageIsSettingsHooksNew}}{{.i18n.Tr "repo.settings.add_webhook"}}{{else}}{{.i18n.Tr "repo.settings.update_webhook"}}{{end}}</strong>
|
{{else if eq .HookType "slack"}}
|
||||||
|
<img class="img-13" src="{{AppSubUrl}}/img/slack.png">
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{template "repo/settings/hook_types" .}}
|
</h4>
|
||||||
|
<div class="ui attached segment">
|
||||||
{{template "repo/settings/hook_gogs" .}}
|
{{template "repo/settings/hook_gogs" .}}
|
||||||
{{template "repo/settings/hook_slack" .}}
|
{{template "repo/settings/hook_slack" .}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{{if .PageIsSettingsHooksEdit}}
|
{{template "repo/settings/hook_history" .}}
|
||||||
<br>
|
|
||||||
<div id="setting-content">
|
|
||||||
<div id="repo-hooks-history-panel" class="panel panel-radius">
|
|
||||||
<div class="panel-header">
|
|
||||||
<strong>{{.i18n.Tr "repo.settings.recent_deliveries"}}</strong>
|
|
||||||
</div>
|
|
||||||
<ul class="panel-body setting-list">
|
|
||||||
<li>Coming soon!</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{template "ng/base/footer" .}}
|
{{template "base/footer" .}}
|
||||||
|
|
|
@ -1,15 +1,28 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<h4 class="text-center">{{.i18n.Tr "repo.settings.event_desc"}}</h4>
|
<h4>{{.i18n.Tr "repo.settings.event_desc"}}</h4>
|
||||||
<label></label>
|
<div class="grouped fields">
|
||||||
<input name="push_only" type="radio" {{if or .PageIsSettingsHooksNew .Webhook.PushOnly}}checked{{end}}> {{.i18n.Tr "repo.settings.event_push_only" | Str2html}}
|
<div class="field">
|
||||||
|
<div class="ui radio checkbox checked">
|
||||||
|
<input class="hidden" name="push_only" type="radio" {{if or .PageIsSettingsHooksNew .Webhook.PushOnly}}checked{{end}}>
|
||||||
|
<label>{{.i18n.Tr "repo.settings.event_push_only" | Str2html}}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<div class="ui checkbox">
|
||||||
|
<input class="hidden" name="active" type="checkbox" tabindex="0" {{if or .PageIsSettingsHooksNew .Webhook.IsActive}}checked{{end}}>
|
||||||
|
<label>{{.i18n.Tr "repo.settings.active"}}</label>
|
||||||
|
<span class="help">{{.i18n.Tr "repo.settings.active_helper"}}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label for="active">{{.i18n.Tr "repo.settings.active"}}</label>
|
{{if .PageIsSettingsHooksNew}}
|
||||||
<input class="ipt-chk" id="active" name="active" type="checkbox" {{if or .PageIsSettingsHooksNew .Webhook.IsActive}}checked{{end}} />
|
<button class="ui green button">{{.i18n.Tr "repo.settings.add_webhook"}}</button>
|
||||||
<span>{{.i18n.Tr "repo.settings.active_helper"}}</span>
|
{{else}}
|
||||||
</div>
|
<button class="ui green button">{{.i18n.Tr "repo.settings.update_webhook"}}</button>
|
||||||
<div class="field">
|
<a class="ui red delete-button button" data-url="{{.BaseLink}}/settings/hooks/delete" data-id="{{.Webhook.ID}}">{{.i18n.Tr "repo.settings.delete_webhook"}}</a>
|
||||||
<label></label>
|
{{end}}
|
||||||
<button class="btn btn-green btn-large btn-radius">{{if .PageIsSettingsHooksNew}}{{.i18n.Tr "repo.settings.add_webhook"}}{{else}}{{.i18n.Tr "repo.settings.update_webhook"}}{{end}}</button>
|
|
||||||
{{if .PageIsSettingsHooksEdit}}<a class="btn btn-red btn-large btn-link btn-radius" href="{{.RepoLink}}/settings/hooks?remove={{.Webhook.ID}}"><strong>{{.i18n.Tr "repo.settings.delete_webhook"}}</strong></a>{{end}}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{template "repo/settings/hook_delete_modal" .}}
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
<div id="slack" class="{{if or .PageIsSettingsHooksNew (and .PageIsSettingsHooksEdit (not (eq .HookType "Slack")))}}hidden{{end}}">
|
{{if eq .HookType "slack"}}
|
||||||
<form class="form form-align panel-body repo-setting-form" id="repo-setting-form-slack" action="{{if .RepoLink}}{{.RepoLink}}{{else if .OrgLink}}{{.OrgLink}}{{end}}/settings/hooks/slack/{{if .PageIsSettingsHooksNew}}new{{else}}{{.Webhook.ID}}{{end}}" method="post">
|
<p>{{.i18n.Tr "repo.settings.add_slack_hook_desc" "http://slack.com" | Str2html}}</p>
|
||||||
|
<form class="ui form" action="{{.BaseLink}}/settings/hooks/{{if .PageIsSettingsHooksNew}}slack/new{{else}}{{.Webhook.ID}}{{end}}" method="post">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<input type="hidden" name="hook_type" value="slack">
|
<div class="required field {{if .Err_PayloadURL}}error{{end}}">
|
||||||
<div class="text-center panel-desc">{{.i18n.Tr "repo.settings.add_slack_hook_desc" "http://slack.com" | Str2html}}</div>
|
<label for="payload_url">{{.i18n.Tr "repo.settings.payload_url"}}</label>
|
||||||
<div class="field">
|
<input id="payload_url" name="payload_url" type="url" value="{{.Webhook.URL}}" autofocus required>
|
||||||
<label class="req" for="payload-url">{{.i18n.Tr "repo.settings.payload_url"}}</label>
|
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_UserName}}ipt-error{{end}}" id="payload-url" name="payload_url" type="url" value="{{.Webhook.URL}}" required />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="required field {{if .Err_Channel}}error{{end}}">
|
||||||
<label class="req" for="channel">{{.i18n.Tr "repo.settings.slack_channel"}}</label>
|
<label for="channel">{{.i18n.Tr "repo.settings.slack_channel"}}</label>
|
||||||
<input class="ipt ipt-large ipt-radius {{if .Err_UserName}}ipt-error{{end}}" id="channel" name="channel" type="text" value="{{.SlackHook.Channel}}" placeholder="#general" required />
|
<input id="channel" name="channel" value="{{.SlackHook.Channel}}" placeholder="#general" required>
|
||||||
</div>
|
</div>
|
||||||
{{template "repo/settings/hook_settings" .}}
|
{{template "repo/settings/hook_settings" .}}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
{{end}}
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
{{if .PageIsSettingsHooksNew}}
|
|
||||||
<div id="hook-type" class="form-align">
|
|
||||||
<label class="req">{{.i18n.Tr "repo.settings.hook_type"}}</label>
|
|
||||||
<select name="hook_type" id="hook-type" class="form-control">
|
|
||||||
{{if .HookType}}<option value="{{.HookType}}">{{.HookType}}</option>{{end}}
|
|
||||||
{{range .HookTypes}}
|
|
||||||
{{if not (eq $.HookType .)}}<option value="{{.}}" >{{.}}</option>{{end}}
|
|
||||||
{{end}}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
Reference in a new issue