Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add button for issue deletion #19032

Merged
merged 5 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add button for issue deletion
  • Loading branch information
fnetX committed Mar 8, 2022
commit 8d74bcf28710b53ad5819b740692d1f1803a6d0a
20 changes: 20 additions & 0 deletions routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,26 @@ func NewIssueChooseTemplate(ctx *context.Context) {
ctx.HTML(http.StatusOK, tplIssueChoose)
}

// DeleteIssue deletes an issue
func DeleteIssue(ctx *context.Context) {
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if models.IsErrIssueNotExist(err) {
ctx.NotFound("IssueOrPullRequestNotExist", err)
} else {
ctx.ServerError("GetIssueByID", err)
}
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)
6543 marked this conversation as resolved.
Show resolved Hide resolved
}

// 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 @@ -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", reqRepoIssueWriter, repo.DeleteIssue)
6543 marked this conversation as resolved.
Show resolved Hide resolved
fnetX marked this conversation as resolved.
Show resolved Hide resolved
}, 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">
fnetX marked this conversation as resolved.
Show resolved Hide resolved
{{svg "octicon-trash"}}
{{.i18n.Tr "repo.issues.delete"}}
fnetX marked this conversation as resolved.
Show resolved Hide resolved
</button>
<div class="ui basic modal" id="delete">
<div class="ui icon header">
{{.i18n.Tr "repo.issues.delete"}}
</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>