Skip to content

Commit 8d55fbf

Browse files
committed
improve ui
1 parent e92d772 commit 8d55fbf

File tree

4 files changed

+31
-19
lines changed

4 files changed

+31
-19
lines changed

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,6 +1970,8 @@ pulls.status_checks_details = Details
19701970
pulls.status_checks_hide_all = Hide all checks
19711971
pulls.status_checks_show_all = Show all checks
19721972
pulls.status_checks_approve_all = Approve all workflows
1973+
pulls.status_checks_need_approvals = %d workflow awaiting approval
1974+
pulls.status_checks_need_approvals_helper = The workflow will only run after approval from the repository maintainer.
19731975
pulls.update_branch = Update branch by merge
19741976
pulls.update_branch_rebase = Update branch by rebase
19751977
pulls.update_branch_success = Branch update was successful

routers/web/repo/pull.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,11 @@ func prepareMergedViewPullInfo(ctx *context.Context, issue *issues_model.Issue)
313313
}
314314

315315
type pullCommitStatusCheckData struct {
316-
MissingRequiredChecks []string // list of missing required checks
317-
IsContextRequired func(string) bool // function to check whether a context is required
318-
RequireApproval bool // whether approval is required for workflow runs
319-
CanApprove bool // whether the user can approve workflow runs
320-
ApproveLink string // link to approve all checks
316+
MissingRequiredChecks []string // list of missing required checks
317+
IsContextRequired func(string) bool // function to check whether a context is required
318+
RequireApprovalRunCount int // number of workflow runs that require approval
319+
CanApprove bool // whether the user can approve workflow runs
320+
ApproveLink string // link to approve all checks
321321
}
322322

323323
// prepareViewPullInfo show meta information for a pull request preview page
@@ -486,11 +486,10 @@ func prepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *pull_
486486
}
487487
for _, run := range runs {
488488
if run.NeedApproval {
489-
statusCheckData.RequireApproval = true
490-
break
489+
statusCheckData.RequireApprovalRunCount++
491490
}
492491
}
493-
if statusCheckData.RequireApproval {
492+
if statusCheckData.RequireApprovalRunCount > 0 {
494493
statusCheckData.CanApprove = ctx.Repo.CanWrite(unit.TypeActions)
495494
}
496495

templates/repo/pulls/status.tmpl

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,31 @@
2222
{{ctx.Locale.Tr "repo.pulls.status_checking"}}
2323
{{end}}
2424

25+
{{if .ShowHideChecks}}
2526
<div class="ui right">
26-
{{if and $statusCheckData $statusCheckData.RequireApproval $statusCheckData.CanApprove}}
27-
<button class="ui basic small compact button link-action" data-url="{{$statusCheckData.ApproveLink}}">
27+
<button class="commit-status-hide-checks btn interact-fg"
28+
data-show-all="{{ctx.Locale.Tr "repo.pulls.status_checks_show_all"}}"
29+
data-hide-all="{{ctx.Locale.Tr "repo.pulls.status_checks_hide_all"}}">
30+
{{ctx.Locale.Tr "repo.pulls.status_checks_hide_all"}}</button>
31+
</div>
32+
{{end}}
33+
</div>
34+
35+
{{if and $statusCheckData (gt $statusCheckData.RequireApprovalRunCount 0)}}
36+
<div class="ui attached segment tw-flex tw-items-center tw-justify-between" id="approve-status-checks">
37+
<div>
38+
<strong>
39+
{{ctx.Locale.Tr "repo.pulls.status_checks_need_approvals" $statusCheckData.RequireApprovalRunCount}}
40+
</strong>
41+
<p>{{ctx.Locale.Tr "repo.pulls.status_checks_need_approvals_helper"}}</p>
42+
</div>
43+
{{if $statusCheckData.CanApprove}}
44+
<button class="ui basic button link-action" data-url="{{$statusCheckData.ApproveLink}}">
2845
{{ctx.Locale.Tr "repo.pulls.status_checks_approve_all"}}
2946
</button>
3047
{{end}}
31-
{{if .ShowHideChecks}}
32-
<button class="commit-status-hide-checks btn interact-fg"
33-
data-show-all="{{ctx.Locale.Tr "repo.pulls.status_checks_show_all"}}"
34-
data-hide-all="{{ctx.Locale.Tr "repo.pulls.status_checks_hide_all"}}">
35-
{{ctx.Locale.Tr "repo.pulls.status_checks_hide_all"}}</button>
36-
{{end}}
3748
</div>
38-
</div>
49+
{{end}}
3950

4051
<div class="commit-status-list">
4152
{{range .CommitStatuses}}

tests/integration/actions_approve_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ jobs:
112112
req = NewRequest(t, "GET", fmt.Sprintf("/%s/%s/pulls/%d", baseRepo.OwnerName, baseRepo.Name, apiPull.Index))
113113
resp = user4Session.MakeRequest(t, req, http.StatusOK)
114114
htmlDoc := NewHTMLParser(t, resp.Body)
115-
assert.Zero(t, htmlDoc.doc.Find(".commit-status-header button.link-action").Length())
115+
assert.Zero(t, htmlDoc.doc.Find("#approve-status-checks button.link-action").Length())
116116

117117
// user2 can see the approve button
118118
req = NewRequest(t, "GET", fmt.Sprintf("/%s/%s/pulls/%d", baseRepo.OwnerName, baseRepo.Name, apiPull.Index))
119119
resp = user2Session.MakeRequest(t, req, http.StatusOK)
120120
htmlDoc = NewHTMLParser(t, resp.Body)
121-
dataURL, exist := htmlDoc.doc.Find(".commit-status-header button.link-action").Attr("data-url")
121+
dataURL, exist := htmlDoc.doc.Find("#approve-status-checks button.link-action").Attr("data-url")
122122
assert.True(t, exist)
123123
assert.Equal(t,
124124
fmt.Sprintf("%s/actions/approve-all-checks?commit_id=%s",

0 commit comments

Comments
 (0)