aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/setting.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-08-26 21:45:51 +0800
committerUnknwon <u@gogs.io>2015-08-26 21:45:51 +0800
commit28814564212b7c64136cc3eda3774af56983557e (patch)
treec0ea1c8ecb6504241a1d2b4111075ee2b0905470 /routers/repo/setting.go
parent1cb03135b745675e614b0b89ab3fde412276fec1 (diff)
downloadgitea-28814564212b7c64136cc3eda3774af56983557e.tar.gz
gitea-28814564212b7c64136cc3eda3774af56983557e.zip
new webhooks list UI
Diffstat (limited to 'routers/repo/setting.go')
-rw-r--r--routers/repo/setting.go56
1 files changed, 29 insertions, 27 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index dfcf598188..8031135ec6 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -173,7 +173,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
}
}
-func SettingsCollaboration(ctx *middleware.Context) {
+func Collaboration(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings")
ctx.Data["PageIsSettingsCollaboration"] = true
@@ -249,26 +249,16 @@ func SettingsCollaboration(ctx *middleware.Context) {
func Webhooks(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings")
ctx.Data["PageIsSettingsHooks"] = true
-
- // Delete web hook.
- remove := com.StrTo(ctx.Query("remove")).MustInt64()
- if remove > 0 {
- if err := models.DeleteWebhook(remove); err != nil {
- ctx.Handle(500, "DeleteWebhook", err)
- return
- }
- ctx.Flash.Success(ctx.Tr("repo.settings.remove_hook_success"))
- ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks")
- return
- }
+ ctx.Data["BaseLink"] = ctx.Repo.RepoLink
+ ctx.Data["Description"] = ctx.Tr("repo.settings.hooks_desc", "http://gogs.io/docs/features/webhook.html")
ws, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.ID)
if err != nil {
ctx.Handle(500, "GetWebhooksByRepoId", err)
return
}
-
ctx.Data["Webhooks"] = ws
+
ctx.HTML(200, HOOKS)
}
@@ -318,8 +308,8 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) {
}
w := &models.Webhook{
- RepoId: orCtx.RepoId,
- Url: form.PayloadUrl,
+ RepoID: orCtx.RepoId,
+ URL: form.PayloadUrl,
ContentType: ct,
Secret: form.Secret,
HookEvent: &models.HookEvent{
@@ -328,7 +318,7 @@ func WebHooksNewPost(ctx *middleware.Context, form auth.NewWebhookForm) {
IsActive: form.Active,
HookTaskType: models.GOGS,
Meta: "",
- OrgId: orCtx.OrgId,
+ OrgID: orCtx.OrgId,
}
if err := w.UpdateEvent(); err != nil {
@@ -429,7 +419,7 @@ func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) {
ct = models.FORM
}
- w.Url = form.PayloadUrl
+ w.URL = form.PayloadUrl
w.ContentType = ct
w.Secret = form.Secret
w.HookEvent = &models.HookEvent{
@@ -474,8 +464,8 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) {
}
w := &models.Webhook{
- RepoId: orCtx.RepoId,
- Url: form.PayloadUrl,
+ RepoID: orCtx.RepoId,
+ URL: form.PayloadUrl,
ContentType: models.JSON,
Secret: "",
HookEvent: &models.HookEvent{
@@ -484,7 +474,7 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) {
IsActive: form.Active,
HookTaskType: models.SLACK,
Meta: string(meta),
- OrgId: orCtx.OrgId,
+ OrgID: orCtx.OrgId,
}
if err := w.UpdateEvent(); err != nil {
ctx.Handle(500, "UpdateEvent", err)
@@ -539,7 +529,7 @@ func SlackHooksEditPost(ctx *middleware.Context, form auth.NewSlackHookForm) {
return
}
- w.Url = form.PayloadUrl
+ w.URL = form.PayloadUrl
w.Meta = string(meta)
w.HookEvent = &models.HookEvent{
PushOnly: form.PushOnly,
@@ -557,6 +547,18 @@ func SlackHooksEditPost(ctx *middleware.Context, form auth.NewSlackHookForm) {
ctx.Redirect(fmt.Sprintf("%s/settings/hooks/%d", orCtx.Link, hookId))
}
+func DeleteWebhook(ctx *middleware.Context) {
+ if err := models.DeleteWebhook(ctx.QueryInt64("id")); err != nil {
+ ctx.Flash.Error("DeleteWebhook: " + err.Error())
+ } else {
+ ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
+ }
+
+ ctx.JSON(200, map[string]interface{}{
+ "redirect": ctx.Repo.RepoLink + "/settings/hooks",
+ })
+}
+
type OrgRepoCtx struct {
OrgId int64
RepoId int64
@@ -608,7 +610,7 @@ func TriggerHook(ctx *middleware.Context) {
models.HookQueue.AddRepoID(repo.ID)
}
-func SettingsGitHooks(ctx *middleware.Context) {
+func GitHooks(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings")
ctx.Data["PageIsSettingsGitHooks"] = true
@@ -622,7 +624,7 @@ func SettingsGitHooks(ctx *middleware.Context) {
ctx.HTML(200, GITHOOKS)
}
-func SettingsGitHooksEdit(ctx *middleware.Context) {
+func GitHooksEdit(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings")
ctx.Data["PageIsSettingsGitHooks"] = true
@@ -640,7 +642,7 @@ func SettingsGitHooksEdit(ctx *middleware.Context) {
ctx.HTML(200, GITHOOK_EDIT)
}
-func SettingsGitHooksEditPost(ctx *middleware.Context) {
+func GitHooksEditPost(ctx *middleware.Context) {
name := ctx.Params(":name")
hook, err := ctx.Repo.GitRepo.GetHook(name)
if err != nil {
@@ -659,7 +661,7 @@ func SettingsGitHooksEditPost(ctx *middleware.Context) {
ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks/git")
}
-func SettingsDeployKeys(ctx *middleware.Context) {
+func DeployKeys(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings")
ctx.Data["PageIsSettingsKeys"] = true
@@ -673,7 +675,7 @@ func SettingsDeployKeys(ctx *middleware.Context) {
ctx.HTML(200, DEPLOY_KEYS)
}
-func SettingsDeployKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
+func DeployKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
ctx.Data["Title"] = ctx.Tr("repo.settings")
ctx.Data["PageIsSettingsKeys"] = true