Show "delete branch" button on closed pull requests (#6570) (#6601)

* Show button to delete a pull request branch after a pull request has been closed (#6570)

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Update routers/repo/pull.go

Co-Authored-By: saitho <mario.lubenka@googlemail.com>
This commit is contained in:
Mario Lubenka 2019-04-20 22:50:34 +02:00 committed by Lauris BH
parent b1bb700665
commit bc86134759
4 changed files with 15 additions and 3 deletions

View file

@ -944,6 +944,7 @@ pulls.tab_conversation = Conversation
pulls.tab_commits = Commits pulls.tab_commits = Commits
pulls.tab_files = Files Changed pulls.tab_files = Files Changed
pulls.reopen_to_merge = Please reopen this pull request to perform a merge. pulls.reopen_to_merge = Please reopen this pull request to perform a merge.
pulls.cant_reopen_deleted_branch = This pull request cannot be reopened because the branch was deleted.
pulls.merged = Merged pulls.merged = Merged
pulls.has_merged = The pull request has been merged. pulls.has_merged = The pull request has been merged.
pulls.title_wip_desc = `<a href="#">Start the title with <strong>%s</strong></a> to prevent the pull request from being merged accidentally.` pulls.title_wip_desc = `<a href="#">Start the title with <strong>%s</strong></a> to prevent the pull request from being merged accidentally.`

View file

@ -674,6 +674,7 @@ func ViewIssue(ctx *context.Context) {
PrepareMergedViewPullInfo(ctx, issue) PrepareMergedViewPullInfo(ctx, issue)
} else { } else {
PrepareViewPullInfo(ctx, issue) PrepareViewPullInfo(ctx, issue)
ctx.Data["DisableStatusChange"] = ctx.Data["IsPullRequestBroken"] == true && issue.IsClosed
} }
if ctx.Written() { if ctx.Written() {
return return

View file

@ -999,8 +999,8 @@ func CleanUpPullRequest(ctx *context.Context) {
pr := issue.PullRequest pr := issue.PullRequest
// Allow cleanup only for merged PR // Don't cleanup unmerged and unclosed PRs
if !pr.HasMerged { if !pr.HasMerged && !issue.IsClosed {
ctx.NotFound("CleanUpPullRequest", nil) ctx.NotFound("CleanUpPullRequest", nil)
return return
} }

View file

@ -58,8 +58,18 @@
{{end}} {{end}}
{{else if .Issue.IsClosed}} {{else if .Issue.IsClosed}}
<div class="item text grey"> <div class="item text grey">
{{if .IsPullRequestBroken}}
{{$.i18n.Tr "repo.pulls.cant_reopen_deleted_branch"}}
{{else}}
{{$.i18n.Tr "repo.pulls.reopen_to_merge"}} {{$.i18n.Tr "repo.pulls.reopen_to_merge"}}
{{end}}
</div> </div>
{{if .IsPullBranchDeletable}}
<div class="ui divider"></div>
<div>
<a class="delete-button ui red button" href="" data-url="{{.DeleteBranchLink}}">{{$.i18n.Tr "repo.branch.delete" .HeadTarget}}</a>
</div>
{{end}}
{{else if .IsPullFilesConflicted}} {{else if .IsPullFilesConflicted}}
<div class="item text grey"> <div class="item text grey">
<span class="octicon octicon-x"></span> <span class="octicon octicon-x"></span>