Skip to content

Commit

Permalink
CB/bp: Add button for issue deletion (go-gitea#19032)
Browse files Browse the repository at this point in the history
Co-authored-by: Norwin <noerw@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
  • Loading branch information
3 people committed Mar 9, 2022
1 parent d44095f commit aabb9b1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,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
Expand Down
15 changes: 15 additions & 0 deletions routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
1 change: 1 addition & 0 deletions routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,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)
Expand Down
21 changes: 21 additions & 0 deletions templates/repo/issue/view_content/sidebar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit aabb9b1

Please sign in to comment.