Skip to content

Commit

Permalink
Fix link-action redirect network error (#27734)
Browse files Browse the repository at this point in the history
  • Loading branch information
lng2020 and 6543 authored Oct 23, 2023
1 parent f3956fc commit 61d94b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions routers/web/repo/milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,15 @@ func EditMilestonePost(ctx *context.Context) {

// ChangeMilestoneStatus response for change a milestone's status
func ChangeMilestoneStatus(ctx *context.Context) {
toClose := false
var toClose bool
switch ctx.Params(":action") {
case "open":
toClose = false
case "close":
toClose = true
default:
ctx.Redirect(ctx.Repo.RepoLink + "/milestones")
ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones")
return
}
id := ctx.ParamsInt64(":id")

Expand All @@ -250,7 +251,7 @@ func ChangeMilestoneStatus(ctx *context.Context) {
}
return
}
ctx.Redirect(ctx.Repo.RepoLink + "/milestones?state=" + url.QueryEscape(ctx.Params(":action")))
ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones?state=" + url.QueryEscape(ctx.Params(":action")))
}

// DeleteMilestone delete a milestone
Expand Down
7 changes: 4 additions & 3 deletions routers/web/repo/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,15 @@ func NewProjectPost(ctx *context.Context) {

// ChangeProjectStatus updates the status of a project between "open" and "close"
func ChangeProjectStatus(ctx *context.Context) {
toClose := false
var toClose bool
switch ctx.Params(":action") {
case "open":
toClose = false
case "close":
toClose = true
default:
ctx.Redirect(ctx.Repo.RepoLink + "/projects")
ctx.JSONRedirect(ctx.Repo.RepoLink + "/projects")
return
}
id := ctx.ParamsInt64(":id")

Expand All @@ -180,7 +181,7 @@ func ChangeProjectStatus(ctx *context.Context) {
}
return
}
ctx.Redirect(ctx.Repo.RepoLink + "/projects?state=" + url.QueryEscape(ctx.Params(":action")))
ctx.JSONRedirect(ctx.Repo.RepoLink + "/projects?state=" + url.QueryEscape(ctx.Params(":action")))
}

// DeleteProject delete a project
Expand Down

0 comments on commit 61d94b2

Please sign in to comment.