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 3 commits
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
3 changes: 3 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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", 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">
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.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>