Skip to content

Commit 8913916

Browse files
jladbrookzeripathlunny
authored
Update button is shown when a Pull Request is marked WIP - Issue #21740 (#22683)
Fix #21740. Updated the Pull Request template so that the 'Update branch by merge' button is visible for WIP PR's. Making the behaviour match a non WIP-PR. Previous WIP page with changes pending on the branch: ![image](https://user-images.githubusercontent.com/1656302/215738307-e68a2f92-5ff8-4f48-a541-35ca81d1f1a4.png) Updated UI adding the update button: ![image](https://user-images.githubusercontent.com/1656302/215737872-e0e9d712-b7aa-4b90-b7ed-6a92a14fc182.png) ## Notes * have not removed the **$canAutoMerge** variable from the pull.tmpl on this [line](https://github.com/go-gitea/gitea/blob/36dc11869d0401b796a7a3f74627fec842a4a89a/templates/repo/issue/view_content/pull.tmpl#L131) - doesn't appear to be used elsewhere but wasn't sure * In order to avoid duplicating code corresponding UI code was added to a new tmpl file, ```update_branch_by_merge.tmpl``` and is called in two places from ```pull.tmpl```. --------- Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Andrew Thornton <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
1 parent 82728a7 commit 8913916

File tree

2 files changed

+41
-38
lines changed

2 files changed

+41
-38
lines changed

templates/repo/issue/view_content/pull.tmpl

+2-38
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
{{end}}
191191
</div>
192192
</div>
193+
{{template "repo/issue/view_content/update_branch_by_merge" (dict "locale" .locale "Issue" .Issue "UpdateAllowed" .UpdateAllowed "UpdateByRebaseAllowed" .UpdateByRebaseAllowed "Link" .Link)}}
193194
{{else if .Issue.PullRequest.IsChecking}}
194195
<div class="item">
195196
<i class="icon icon-octicon">{{svg "octicon-sync"}}</i>
@@ -282,44 +283,7 @@
282283
</div>
283284
{{end}}
284285
{{end}}
285-
{{if and (gt .Issue.PullRequest.CommitsBehind 0) (not .Issue.IsClosed) (not .Issue.PullRequest.IsChecking) (not .IsPullFilesConflicted) (not .IsPullRequestBroken) (not $canAutoMerge)}}
286-
<div class="ui divider"></div>
287-
<div class="item item-section">
288-
<div class="item-section-left">
289-
<i class="icon icon-octicon">{{svg "octicon-alert"}}</i>
290-
{{$.locale.Tr "repo.pulls.outdated_with_base_branch"}}
291-
</div>
292-
<div class="item-section-right">
293-
{{if and .UpdateAllowed .UpdateByRebaseAllowed}}
294-
<div class="dib">
295-
<div class="ui buttons update-button">
296-
<button class="ui button" data-do="{{.Link}}/update" data-redirect="{{.Link}}">
297-
<span class="button-text">
298-
{{$.locale.Tr "repo.pulls.update_branch"}}
299-
</span>
300-
</button>
301-
302-
<div class="ui dropdown icon button no-text">
303-
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
304-
<div class="menu">
305-
<div class="item active selected" data-do="{{.Link}}/update">{{$.locale.Tr "repo.pulls.update_branch"}}</div>
306-
<div class="item" data-do="{{.Link}}/update?style=rebase">{{$.locale.Tr "repo.pulls.update_branch_rebase"}}</div>
307-
</div>
308-
</div>
309-
</div>
310-
</div>
311-
{{end}}
312-
{{if and .UpdateAllowed (not .UpdateByRebaseAllowed)}}
313-
<form action="{{.Link}}/update" method="post" class="ui update-branch-form">
314-
{{.CsrfTokenHtml}}
315-
<button class="ui compact button" data-do="update">
316-
<span class="ui text">{{$.locale.Tr "repo.pulls.update_branch"}}</span>
317-
</button>
318-
</form>
319-
{{end}}
320-
</div>
321-
</div>
322-
{{end}}
286+
{{template "repo/issue/view_content/update_branch_by_merge" (dict "locale" .locale "Issue" .Issue "UpdateAllowed" .UpdateAllowed "UpdateByRebaseAllowed" .UpdateByRebaseAllowed "Link" .Link)}}
323287
{{if .Issue.PullRequest.IsEmpty}}
324288
<div class="ui divider"></div>
325289

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{{$canAutoMerge := false}}
2+
{{if and (gt .Issue.PullRequest.CommitsBehind 0) (not .Issue.IsClosed) (not .Issue.PullRequest.IsChecking) (not .IsPullFilesConflicted) (not .IsPullRequestBroken) (not $canAutoMerge)}}
3+
<div class="ui divider"></div>
4+
<div class="item item-section">
5+
<div class="item-section-left">
6+
<i class="icon icon-octicon">{{svg "octicon-alert"}}</i>
7+
{{$.locale.Tr "repo.pulls.outdated_with_base_branch"}}
8+
</div>
9+
<div class="item-section-right">
10+
{{if and .UpdateAllowed .UpdateByRebaseAllowed}}
11+
<div class="dib">
12+
<div class="ui buttons update-button">
13+
<button class="ui button" data-do="{{.Link}}/update" data-redirect="{{.Link}}">
14+
<span class="button-text">
15+
{{$.locale.Tr "repo.pulls.update_branch"}}
16+
</span>
17+
</button>
18+
19+
<div class="ui dropdown icon button no-text">
20+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
21+
<div class="menu">
22+
<div class="item active selected" data-do="{{.Link}}/update">{{$.locale.Tr "repo.pulls.update_branch"}}</div>
23+
<div class="item" data-do="{{.Link}}/update?style=rebase">{{$.locale.Tr "repo.pulls.update_branch_rebase"}}</div>
24+
</div>
25+
</div>
26+
</div>
27+
</div>
28+
{{end}}
29+
{{if and .UpdateAllowed (not .UpdateByRebaseAllowed)}}
30+
<form action="{{.Link}}/update" method="post" class="ui update-branch-form">
31+
{{.CsrfTokenHtml}}
32+
<button class="ui compact button" data-do="update">
33+
<span class="ui text">{{$.locale.Tr "repo.pulls.update_branch"}}</span>
34+
</button>
35+
</form>
36+
{{end}}
37+
</div>
38+
</div>
39+
{{end}}

0 commit comments

Comments
 (0)