From ea46142bcea6084e50a11baf048f8eb8862285c7 Mon Sep 17 00:00:00 2001 From: "Otto Richter (fnetX)" Date: Wed, 9 Mar 2022 01:38:11 +0100 Subject: Add button for issue deletion (#19032) Co-authored-by: Norwin Co-authored-by: 6543 <6543@obermui.de> --- routers/web/repo/issue.go | 15 +++++++++++++++ routers/web/web.go | 1 + 2 files changed, 16 insertions(+) (limited to 'routers/web') diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index d0c3d3325a..a81b1f1962 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -852,6 +852,21 @@ func NewIssueChooseTemplate(ctx *context.Context) { ctx.HTML(http.StatusOK, tplIssueChoose) } +// DeleteIssue deletes an issue +func DeleteIssue(ctx *context.Context) { + issue := GetActionIssue(ctx) + if ctx.Written() { + return + } + + if err := issue_service.DeleteIssue(ctx.User, ctx.Repo.GitRepo, issue); err != nil { + ctx.ServerError("DeleteIssueByID", err) + return + } + + ctx.Redirect(fmt.Sprintf("%s/issues", ctx.Repo.Repository.HTMLURL()), http.StatusSeeOther) +} + // ValidateRepoMetas check and returns repository's meta information func ValidateRepoMetas(ctx *context.Context, form forms.CreateIssueForm, isPull bool) ([]int64, []int64, int64, int64) { var ( diff --git a/routers/web/web.go b/routers/web/web.go index d8c197fb96..9faa61e560 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -757,6 +757,7 @@ func RegisterRoutes(m *web.Route) { m.Post("/reactions/{action}", bindIgnErr(forms.ReactionForm{}), repo.ChangeIssueReaction) m.Post("/lock", reqRepoIssueWriter, bindIgnErr(forms.IssueLockForm{}), repo.LockIssue) m.Post("/unlock", reqRepoIssueWriter, repo.UnlockIssue) + m.Post("/delete", reqRepoAdmin, repo.DeleteIssue) }, context.RepoMustNotBeArchived()) m.Group("/{index}", func() { m.Get("/attachments", repo.GetIssueAttachments) -- cgit v1.2.3