Skip to content

Add multi delete issues #22344

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

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -2562,6 +2562,11 @@ func UpdateIssueStatus(ctx *context.Context) {
isClosed = false
case "close":
isClosed = true
case "delete":
if err := issue_service.DeleteIssues(ctx.Doer, ctx.Repo.GitRepo, issues); err != nil {
ctx.ServerError("DeleteIssues", err)
}
return
default:
log.Warn("Unrecognized action: %s", action)
}
Expand Down
9 changes: 9 additions & 0 deletions services/issue/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ func UpdateAssignees(issue *issues_model.Issue, oneAssignee string, multipleAssi
return err
}

func DeleteIssues(doer *user_model.User, gitRepo *git.Repository, issues []*issues_model.Issue) error {
for _, issue := range issues {
if err := DeleteIssue(doer, gitRepo, issue); err != nil {
return err
}
}
return nil
}
Comment on lines +133 to +140
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we could think about passing a context in as well and executing this whole block inside a transaction so that it is automatically rolled back if the deletion of any issue fails.


// DeleteIssue deletes an issue
func DeleteIssue(doer *user_model.User, gitRepo *git.Repository, issue *issues_model.Issue) error {
// load issue before deleting it
Expand Down
1 change: 1 addition & 0 deletions templates/repo/issue/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
{{else}}
<div class="ui red active basic button issue-action" data-action="close" data-url="{{$.RepoLink}}/issues/status" style="margin-left: auto">{{.locale.Tr "repo.issues.action_close"}}</div>
{{end}}
<div class="ui negative active button issue-action" data-action="delete" data-url="{{$.RepoLink}}/issues/status" style="margin-left: auto">{{.locale.Tr "repo.issues.delete"}}</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm strongly against allowing such a destructive action to occur without presenting a warning dialogue.
At best, extract the existing issue deletion dialogue into a new template and reuse it, or copy it if that's not easily possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, why display a text when it's probably a better idea to use the octicon-trash SVG instead?
First of all to minimize the user potential to missclick there, and secondly to improve the UX.

<!-- Labels -->
<div class="ui {{if not .Labels}}disabled{{end}} dropdown jump item">
<span class="text">
Expand Down
2 changes: 1 addition & 1 deletion templates/user/dashboard/issues.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{{end}}
<div class="ui divider"></div>
<a class="{{if not $.RepoIDs}}ui basic primary button{{end}} repo name item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&q={{$.Keyword}}">
<span class="text truncate">All</span>
<span class="text truncate">{{.locale.Tr "all"}}</span>
Copy link
Member

@delvh delvh Jan 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems oddly familiar… 😉

<div class="ui {{if $.IsShowClosed}}red{{else}}green{{end}} label">{{CountFmt .TotalIssueCount}}</div>
</a>
{{range .Repos}}
Expand Down