aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Richter (fnetX)2022-03-09 01:38:11 +0100
committerGitHub2022-03-09 01:38:11 +0100
commitea46142bcea6084e50a11baf048f8eb8862285c7 (patch)
tree0b269d8e46c824e3a76ab1432cd528493de2b4c6
parentddf7f1319f70e124acfd1e8e86dff4ff87290f51 (diff)
Add button for issue deletion (#19032)
Co-authored-by: Norwin <noerw@users.noreply.github.com> Co-authored-by: 6543 <6543@obermui.de>
-rw-r--r--options/locale/locale_en-US.ini3
-rw-r--r--routers/web/repo/issue.go15
-rw-r--r--routers/web/web.go1
-rw-r--r--templates/repo/issue/view_content/sidebar.tmpl21
4 files changed, 40 insertions, 0 deletions
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index 90309c9df..90564c63b 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -1374,6 +1374,9 @@ issues.lock.reason = Reason for locking
issues.lock.title = Lock conversation on this issue.
issues.unlock.title = Unlock conversation on this issue.
issues.comment_on_locked = You cannot comment on a locked issue.
+issues.delete = Delete
+issues.delete.title = Delete this issue?
+issues.delete.text = Do you really want to delete this issue? (This will permanently remove all content. Consider closing it instead, if you intend to keep it archived)
issues.tracker = Time Tracker
issues.start_tracking_short = Start Timer
issues.start_tracking = Start Time Tracking
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index d0c3d3325..a81b1f196 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 d8c197fb9..9faa61e56 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)
diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl
index 6198b6a62..65c1cf75e 100644
--- a/templates/repo/issue/view_content/sidebar.tmpl
+++ b/templates/repo/issue/view_content/sidebar.tmpl
@@ -645,6 +645,27 @@
</form>
</div>
</div>
+ <button class="fluid ui show-modal button negative mt-3" data-modal="#delete">
+ {{svg "octicon-trash"}}
+ {{.i18n.Tr "repo.issues.delete"}}
+ </button>
+ <div class="ui basic modal" id="delete">
+ <div class="ui icon header">
+ {{.i18n.Tr "repo.issues.delete.title"}}
+ </div>
+ <div class="content center">
+ <p>
+ {{.i18n.Tr "repo.issues.delete.text"}}
+ </p>
+ </div>
+ <form action="{{.Issue.Link}}/delete" method="post">
+ {{.CsrfTokenHtml}}
+ <div class="center actions">
+ <div class="ui basic cancel inverted button">{{.i18n.Tr "settings.cancel"}}</div>
+ <button class="ui basic red inverted button">{{.i18n.Tr "modal.yes"}}</button>
+ </div>
+ </form>
+ </div>
{{end}}
</div>
</div>