summaryrefslogtreecommitdiffstats
path: root/routers/repo/setting.go
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-08-09 15:40:10 -0700
committerUnknwon <joe2010xtmf@163.com>2014-08-09 15:40:10 -0700
commit9a1d5d2489d25778e26ab413cb9ee78d3fe2823a (patch)
tree4e31de40d92b96ba9fa8f45e5da442291303832e /routers/repo/setting.go
parent9820b8e1342017edfe4f6ced9cc3a7d811449c7b (diff)
downloadgitea-9a1d5d2489d25778e26ab413cb9ee78d3fe2823a.tar.gz
gitea-9a1d5d2489d25778e26ab413cb9ee78d3fe2823a.zip
Finish new web hook pages
Diffstat (limited to 'routers/repo/setting.go')
-rw-r--r--routers/repo/setting.go57
1 files changed, 31 insertions, 26 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index 5867d161e4..10a6f72db7 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -24,9 +24,7 @@ const (
SETTINGS_OPTIONS base.TplName = "repo/settings/options"
COLLABORATION base.TplName = "repo/settings/collaboration"
HOOKS base.TplName = "repo/settings/hooks"
-
- HOOK_ADD base.TplName = "repo/hook_add"
- HOOK_EDIT base.TplName = "repo/hook_edit"
+ HOOK_NEW base.TplName = "repo/settings/hook_new"
)
func Settings(ctx *middleware.Context) {
@@ -241,18 +239,22 @@ func Webhooks(ctx *middleware.Context) {
ctx.HTML(200, HOOKS)
}
-func WebHooksAdd(ctx *middleware.Context) {
- ctx.Data["IsRepoToolbarWebHooks"] = true
- ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Add Webhook"
- ctx.HTML(200, HOOK_ADD)
+func WebHooksNew(ctx *middleware.Context) {
+ ctx.Data["Title"] = ctx.Tr("repo.settings")
+ ctx.Data["PageIsSettingsHooks"] = true
+ ctx.Data["PageIsSettingsHooksNew"] = true
+ ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}}
+ ctx.HTML(200, HOOK_NEW)
}
-func WebHooksAddPost(ctx *middleware.Context, form auth.NewWebhookForm) {
- ctx.Data["IsRepoToolbarWebHooks"] = true
- ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Add Webhook"
+func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) {
+ ctx.Data["Title"] = ctx.Tr("repo.settings")
+ ctx.Data["PageIsSettingsHooks"] = true
+ ctx.Data["PageIsSettingsHooksNew"] = true
+ ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}}
if ctx.HasError() {
- ctx.HTML(200, HOOK_ADD)
+ ctx.HTML(200, HOOK_NEW)
return
}
@@ -263,7 +265,7 @@ func WebHooksAddPost(ctx *middleware.Context, form auth.NewWebhookForm) {
w := &models.Webhook{
RepoId: ctx.Repo.Repository.Id,
- Url: form.Url,
+ Url: form.PayloadUrl,
ContentType: ct,
Secret: form.Secret,
HookEvent: &models.HookEvent{
@@ -272,20 +274,21 @@ func WebHooksAddPost(ctx *middleware.Context, form auth.NewWebhookForm) {
IsActive: form.Active,
}
if err := w.UpdateEvent(); err != nil {
- ctx.Handle(500, "setting.WebHooksAddPost(UpdateEvent)", err)
+ ctx.Handle(500, "UpdateEvent", err)
return
} else if err := models.CreateWebhook(w); err != nil {
- ctx.Handle(500, "setting.WebHooksAddPost(CreateWebhook)", err)
+ ctx.Handle(500, "CreateWebhook", err)
return
}
- ctx.Flash.Success("New webhook has been added.")
+ ctx.Flash.Success(ctx.Tr("repo.settings.add_hook_success"))
ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks")
}
func WebHooksEdit(ctx *middleware.Context) {
- ctx.Data["IsRepoToolbarWebHooks"] = true
- ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Webhook"
+ ctx.Data["Title"] = ctx.Tr("repo.settings")
+ ctx.Data["PageIsSettingsHooks"] = true
+ ctx.Data["PageIsSettingsHooksEdit"] = true
hookId := com.StrTo(ctx.Params(":id")).MustInt64()
if hookId == 0 {
@@ -296,21 +299,21 @@ func WebHooksEdit(ctx *middleware.Context) {
w, err := models.GetWebhookById(hookId)
if err != nil {
if err == models.ErrWebhookNotExist {
- ctx.Handle(404, "setting.WebHooksEdit(GetWebhookById)", nil)
+ ctx.Handle(404, "GetWebhookById", nil)
} else {
- ctx.Handle(500, "setting.WebHooksEdit(GetWebhookById)", err)
+ ctx.Handle(500, "GetWebhookById", err)
}
return
}
-
w.GetEvent()
ctx.Data["Webhook"] = w
- ctx.HTML(200, HOOK_EDIT)
+ ctx.HTML(200, HOOK_NEW)
}
func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) {
- ctx.Data["IsRepoToolbarWebHooks"] = true
- ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - Webhook"
+ ctx.Data["Title"] = ctx.Tr("repo.settings")
+ ctx.Data["PageIsSettingsHooks"] = true
+ ctx.Data["PageIsSettingsHooksEdit"] = true
hookId := com.StrTo(ctx.Params(":id")).MustInt64()
if hookId == 0 {
@@ -327,9 +330,11 @@ func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) {
}
return
}
+ w.GetEvent()
+ ctx.Data["Webhook"] = w
if ctx.HasError() {
- ctx.HTML(200, HOOK_EDIT)
+ ctx.HTML(200, HOOK_NEW)
return
}
@@ -338,7 +343,7 @@ func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) {
ct = models.FORM
}
- w.Url = form.Url
+ w.Url = form.PayloadUrl
w.ContentType = ct
w.Secret = form.Secret
w.HookEvent = &models.HookEvent{
@@ -353,6 +358,6 @@ func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) {
return
}
- ctx.Flash.Success("Webhook has been updated.")
+ ctx.Flash.Success(ctx.Tr("repo.settings.update_hook_success"))
ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", ctx.Repo.RepoLink, hookId))
}