Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use router params to differentiate admin hook pages
  • Loading branch information
jamesorlakin committed Mar 1, 2020
commit af76998291ca7d7c289abaf8f45bde9c94681664
4 changes: 1 addition & 3 deletions routers/admin/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
package admin

import (
"strings"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
Expand All @@ -24,7 +22,7 @@ func DefaultAndSystemWebhooks(ctx *context.Context) {
var err error

// Are we looking at default webhooks?
if strings.Contains(ctx.Link, "/admin/hooks") {
if ctx.Params(":configType") == "hooks" {
ctx.Data["Title"] = ctx.Tr("admin.hooks")
ctx.Data["Description"] = ctx.Tr("admin.hooks.desc")
ctx.Data["PageIsAdminHooks"] = true
Expand Down
2 changes: 1 addition & 1 deletion routers/repo/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func getOrgRepoCtx(ctx *context.Context) (*orgRepoCtx, error) {

if ctx.User.IsAdmin {
// Are we looking at default webhooks?
if strings.Contains(ctx.Link, "/admin/hooks") {
if ctx.Params(":configType") == "hooks" {
return &orgRepoCtx{
IsAdmin: true,
Link: path.Join(setting.AppSubURL, "/admin/hooks"),
Expand Down
2 changes: 1 addition & 1 deletion routers/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/delete", admin.DeleteRepo)
})

m.Group("/^:type(hooks|system-hooks)$", func() {
m.Group("/^:configType(hooks|system-hooks)$", func() {
m.Get("", admin.DefaultAndSystemWebhooks)
m.Post("/delete", admin.DeleteDefaultWebhook)
m.Get("/:type/new", repo.WebhooksNew)
Expand Down