diff options
Diffstat (limited to 'routers/web/repo')
-rw-r--r-- | routers/web/repo/branch.go | 4 | ||||
-rw-r--r-- | routers/web/repo/issue.go | 12 | ||||
-rw-r--r-- | routers/web/repo/issue_label.go | 8 | ||||
-rw-r--r-- | routers/web/repo/milestone.go | 4 | ||||
-rw-r--r-- | routers/web/repo/projects.go | 32 | ||||
-rw-r--r-- | routers/web/repo/pull.go | 4 | ||||
-rw-r--r-- | routers/web/repo/pull_review.go | 4 | ||||
-rw-r--r-- | routers/web/repo/release.go | 8 | ||||
-rw-r--r-- | routers/web/repo/setting/collaboration.go | 8 | ||||
-rw-r--r-- | routers/web/repo/setting/deploy_key.go | 4 | ||||
-rw-r--r-- | routers/web/repo/setting/protected_branch.go | 20 | ||||
-rw-r--r-- | routers/web/repo/setting/webhook.go | 4 | ||||
-rw-r--r-- | routers/web/repo/wiki.go | 4 |
13 files changed, 29 insertions, 87 deletions
diff --git a/routers/web/repo/branch.go b/routers/web/repo/branch.go index 999104d787..d71d555bc2 100644 --- a/routers/web/repo/branch.go +++ b/routers/web/repo/branch.go @@ -162,9 +162,7 @@ func RestoreBranchPost(ctx *context.Context) { } func redirect(ctx *context.Context) { - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": ctx.Repo.RepoLink + "/branches?page=" + url.QueryEscape(ctx.FormString("page")), - }) + ctx.JSONRedirect(ctx.Repo.RepoLink + "/branches?page=" + url.QueryEscape(ctx.FormString("page"))) } // CreateBranch creates new branch in repository diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index b7d159d158..f5cec5a323 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -2221,9 +2221,7 @@ func UpdateIssueMilestone(ctx *context.Context) { } } - ctx.JSON(http.StatusOK, map[string]any{ - "ok": true, - }) + ctx.JSONOK() } // UpdateIssueAssignee change issue's or pull's assignee @@ -2267,9 +2265,7 @@ func UpdateIssueAssignee(ctx *context.Context) { } } } - ctx.JSON(http.StatusOK, map[string]any{ - "ok": true, - }) + ctx.JSONOK() } // UpdatePullReviewRequest add or remove review request @@ -2392,9 +2388,7 @@ func UpdatePullReviewRequest(ctx *context.Context) { } } - ctx.JSON(http.StatusOK, map[string]any{ - "ok": true, - }) + ctx.JSONOK() } // SearchIssues searches for issues across the repositories that the user has access to diff --git a/routers/web/repo/issue_label.go b/routers/web/repo/issue_label.go index af5db83bd5..5d326bab58 100644 --- a/routers/web/repo/issue_label.go +++ b/routers/web/repo/issue_label.go @@ -157,9 +157,7 @@ func DeleteLabel(ctx *context.Context) { ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success")) } - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": ctx.Repo.RepoLink + "/labels", - }) + ctx.JSONRedirect(ctx.Repo.RepoLink + "/labels") } // UpdateIssueLabel change issue's labels @@ -226,7 +224,5 @@ func UpdateIssueLabel(ctx *context.Context) { return } - ctx.JSON(http.StatusOK, map[string]any{ - "ok": true, - }) + ctx.JSONOK() } diff --git a/routers/web/repo/milestone.go b/routers/web/repo/milestone.go index 7b20cd9848..ad355ce5d7 100644 --- a/routers/web/repo/milestone.go +++ b/routers/web/repo/milestone.go @@ -255,9 +255,7 @@ func DeleteMilestone(ctx *context.Context) { ctx.Flash.Success(ctx.Tr("repo.milestones.deletion_success")) } - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": ctx.Repo.RepoLink + "/milestones", - }) + ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones") } // MilestoneIssuesAndPulls lists all the issues and pull requests of the milestone diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go index 1574c90c02..b8662e0605 100644 --- a/routers/web/repo/projects.go +++ b/routers/web/repo/projects.go @@ -203,9 +203,7 @@ func DeleteProject(ctx *context.Context) { ctx.Flash.Success(ctx.Tr("repo.projects.deletion_success")) } - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": ctx.Repo.RepoLink + "/projects", - }) + ctx.JSONRedirect(ctx.Repo.RepoLink + "/projects") } // RenderEditProject allows a project to be edited @@ -397,9 +395,7 @@ func UpdateIssueProject(ctx *context.Context) { } } - ctx.JSON(http.StatusOK, map[string]any{ - "ok": true, - }) + ctx.JSONOK() } // DeleteProjectBoard allows for the deletion of a project board @@ -452,9 +448,7 @@ func DeleteProjectBoard(ctx *context.Context) { return } - ctx.JSON(http.StatusOK, map[string]any{ - "ok": true, - }) + ctx.JSONOK() } // AddBoardToProjectPost allows a new board to be added to a project. @@ -487,9 +481,7 @@ func AddBoardToProjectPost(ctx *context.Context) { return } - ctx.JSON(http.StatusOK, map[string]any{ - "ok": true, - }) + ctx.JSONOK() } func checkProjectBoardChangePermissions(ctx *context.Context) (*project_model.Project, *project_model.Board) { @@ -561,9 +553,7 @@ func EditProjectBoard(ctx *context.Context) { return } - ctx.JSON(http.StatusOK, map[string]any{ - "ok": true, - }) + ctx.JSONOK() } // SetDefaultProjectBoard set default board for uncategorized issues/pulls @@ -578,9 +568,7 @@ func SetDefaultProjectBoard(ctx *context.Context) { return } - ctx.JSON(http.StatusOK, map[string]any{ - "ok": true, - }) + ctx.JSONOK() } // UnSetDefaultProjectBoard unset default board for uncategorized issues/pulls @@ -595,9 +583,7 @@ func UnSetDefaultProjectBoard(ctx *context.Context) { return } - ctx.JSON(http.StatusOK, map[string]any{ - "ok": true, - }) + ctx.JSONOK() } // MoveIssues moves or keeps issues in a column and sorts them inside that column @@ -699,7 +685,5 @@ func MoveIssues(ctx *context.Context) { return } - ctx.JSON(http.StatusOK, map[string]any{ - "ok": true, - }) + ctx.JSONOK() } diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 5290e25d46..237e53413f 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -1423,9 +1423,7 @@ func CleanUpPullRequest(ctx *context.Context) { } defer func() { - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": issue.Link(), - }) + ctx.JSONRedirect(issue.Link()) }() // Check if branch has no new commits diff --git a/routers/web/repo/pull_review.go b/routers/web/repo/pull_review.go index f7c962d1ae..c2271750c4 100644 --- a/routers/web/repo/pull_review.go +++ b/routers/web/repo/pull_review.go @@ -156,9 +156,7 @@ func UpdateResolveConversation(ctx *context.Context) { renderConversation(ctx, comment) return } - ctx.JSON(http.StatusOK, map[string]any{ - "ok": true, - }) + ctx.JSONOK() } func renderConversation(ctx *context.Context, comment *issues_model.Comment) { diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index 3d991384e5..957cf56972 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -628,13 +628,9 @@ func deleteReleaseOrTag(ctx *context.Context, isDelTag bool) { } if isDelTag { - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": ctx.Repo.RepoLink + "/tags", - }) + ctx.JSONRedirect(ctx.Repo.RepoLink + "/tags") return } - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": ctx.Repo.RepoLink + "/releases", - }) + ctx.JSONRedirect(ctx.Repo.RepoLink + "/releases") } diff --git a/routers/web/repo/setting/collaboration.go b/routers/web/repo/setting/collaboration.go index 8f2d306862..b708422cbd 100644 --- a/routers/web/repo/setting/collaboration.go +++ b/routers/web/repo/setting/collaboration.go @@ -133,9 +133,7 @@ func DeleteCollaboration(ctx *context.Context) { ctx.Flash.Success(ctx.Tr("repo.settings.remove_collaborator_success")) } - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": ctx.Repo.RepoLink + "/settings/collaboration", - }) + ctx.JSONRedirect(ctx.Repo.RepoLink + "/settings/collaboration") } // AddTeamPost response for adding a team to a repository @@ -204,7 +202,5 @@ func DeleteTeam(ctx *context.Context) { } ctx.Flash.Success(ctx.Tr("repo.settings.remove_team_success")) - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": ctx.Repo.RepoLink + "/settings/collaboration", - }) + ctx.JSONRedirect(ctx.Repo.RepoLink + "/settings/collaboration") } diff --git a/routers/web/repo/setting/deploy_key.go b/routers/web/repo/setting/deploy_key.go index d08c51f5e5..577706d454 100644 --- a/routers/web/repo/setting/deploy_key.go +++ b/routers/web/repo/setting/deploy_key.go @@ -105,7 +105,5 @@ func DeleteDeployKey(ctx *context.Context) { ctx.Flash.Success(ctx.Tr("repo.settings.deploy_key_deletion_success")) } - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": ctx.Repo.RepoLink + "/settings/keys", - }) + ctx.JSONRedirect(ctx.Repo.RepoLink + "/settings/keys") } diff --git a/routers/web/repo/setting/protected_branch.go b/routers/web/repo/setting/protected_branch.go index cf59e747d8..5bfdb8f515 100644 --- a/routers/web/repo/setting/protected_branch.go +++ b/routers/web/repo/setting/protected_branch.go @@ -318,41 +318,31 @@ func DeleteProtectedBranchRulePost(ctx *context.Context) { ruleID := ctx.ParamsInt64("id") if ruleID <= 0 { ctx.Flash.Error(ctx.Tr("repo.settings.remove_protected_branch_failed", fmt.Sprintf("%d", ruleID))) - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink), - }) + ctx.JSONRedirect(fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink)) return } rule, err := git_model.GetProtectedBranchRuleByID(ctx, ctx.Repo.Repository.ID, ruleID) if err != nil { ctx.Flash.Error(ctx.Tr("repo.settings.remove_protected_branch_failed", fmt.Sprintf("%d", ruleID))) - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink), - }) + ctx.JSONRedirect(fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink)) return } if rule == nil { ctx.Flash.Error(ctx.Tr("repo.settings.remove_protected_branch_failed", fmt.Sprintf("%d", ruleID))) - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink), - }) + ctx.JSONRedirect(fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink)) return } if err := git_model.DeleteProtectedBranch(ctx, ctx.Repo.Repository.ID, ruleID); err != nil { ctx.Flash.Error(ctx.Tr("repo.settings.remove_protected_branch_failed", rule.RuleName)) - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink), - }) + ctx.JSONRedirect(fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink)) return } ctx.Flash.Success(ctx.Tr("repo.settings.remove_protected_branch_success", rule.RuleName)) - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink), - }) + ctx.JSONRedirect(fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink)) } // RenameBranchPost responses for rename a branch diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go index d85d5c8b07..5c4e1d47d0 100644 --- a/routers/web/repo/setting/webhook.go +++ b/routers/web/repo/setting/webhook.go @@ -729,7 +729,5 @@ func DeleteWebhook(ctx *context.Context) { ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success")) } - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": ctx.Repo.RepoLink + "/settings/hooks", - }) + ctx.JSONRedirect(ctx.Repo.RepoLink + "/settings/hooks") } diff --git a/routers/web/repo/wiki.go b/routers/web/repo/wiki.go index 4773e25c70..e3c187c33b 100644 --- a/routers/web/repo/wiki.go +++ b/routers/web/repo/wiki.go @@ -790,7 +790,5 @@ func DeleteWikiPagePost(ctx *context.Context) { notification.NotifyDeleteWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(wikiName)) - ctx.JSON(http.StatusOK, map[string]any{ - "redirect": ctx.Repo.RepoLink + "/wiki/", - }) + ctx.JSONRedirect(ctx.Repo.RepoLink + "/wiki/") } |