Skip to content

Commit 4a189a5

Browse files
committed
improve tiddy commit status
1 parent 97e60b3 commit 4a189a5

File tree

8 files changed

+91
-54
lines changed

8 files changed

+91
-54
lines changed

routers/web/repo/pull.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ func PrepareMergedViewPullInfo(ctx *context.Context, issue *issues_model.Issue)
477477
if len(commitStatuses) != 0 {
478478
ctx.Data["LatestCommitStatuses"] = commitStatuses
479479
ctx.Data["LatestCommitStatus"] = git_model.CalcCommitStatus(commitStatuses)
480+
ctx.Data["ShowHideButton"] = true
480481
}
481482
}
482483

@@ -539,6 +540,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
539540
if len(commitStatuses) > 0 {
540541
ctx.Data["LatestCommitStatuses"] = commitStatuses
541542
ctx.Data["LatestCommitStatus"] = git_model.CalcCommitStatus(commitStatuses)
543+
ctx.Data["ShowHideButton"] = true
542544
}
543545

544546
compareInfo, err := baseGitRepo.GetCompareInfo(pull.BaseRepo.RepoPath(),
@@ -631,6 +633,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
631633
if len(commitStatuses) > 0 {
632634
ctx.Data["LatestCommitStatuses"] = commitStatuses
633635
ctx.Data["LatestCommitStatus"] = git_model.CalcCommitStatus(commitStatuses)
636+
ctx.Data["ShowHideButton"] = true
634637
}
635638

636639
if pb != nil && pb.EnableStatusCheck {

templates/repo/branch/list.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<div class="gt-df gt-ac">
2626
<a class="gt-ellipsis" href="{{.RepoLink}}/src/branch/{{PathEscapeSegments .DefaultBranchBranch.DBBranch.Name}}">{{.DefaultBranchBranch.DBBranch.Name}}</a>
2727
<button class="btn interact-fg gt-p-3" data-clipboard-text="{{.DefaultBranchBranch.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button>
28-
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID)}}
28+
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID) "root" $}}
2929
</div>
3030
<p class="info gt-df gt-ac gt-my-2">{{svg "octicon-git-commit" 16 "gt-mr-2"}}<a href="{{.RepoLink}}/commit/{{PathEscape .DefaultBranchBranch.DBBranch.CommitID}}">{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage .RepoLink .Repository.ComposeMetas}}</span> · {{.locale.Tr "org.repo_updated"}} {{TimeSince .DefaultBranchBranch.DBBranch.CommitTime.AsTime .locale}}{{if .DefaultBranchBranch.DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "Context" $.Context "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}</p>
3131
</td>
@@ -92,7 +92,7 @@
9292
<div class="gt-df gt-ac">
9393
<a class="gt-ellipsis" href="{{$.RepoLink}}/src/branch/{{PathEscapeSegments .DBBranch.Name}}">{{.DBBranch.Name}}</a>
9494
<button class="btn interact-fg gt-p-3" data-clipboard-text="{{.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button>
95-
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DBBranch.CommitID)}}
95+
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DBBranch.CommitID) "root" $}}
9696
</div>
9797
<p class="info gt-df gt-ac gt-my-2">{{svg "octicon-git-commit" 16 "gt-mr-2"}}<a href="{{$.RepoLink}}/commit/{{PathEscape .DBBranch.CommitID}}">{{ShortSha .DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DBBranch.CommitMessage $.RepoLink $.Repository.ComposeMetas}}</span> · {{$.locale.Tr "org.repo_updated"}} {{TimeSince .DBBranch.CommitTime.AsTime $.locale}}{{if .DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "Context" $.Context "user" .DBBranch.Pusher}} &nbsp;{{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p>
9898
{{end}}

templates/repo/commit_statuses.tmpl

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
</span>
1010
{{end}}
1111
<div class="tippy-target ui relaxed list divided">
12-
{{range .Statuses}}
13-
<div class="ui item singular-status gt-df">
14-
{{template "repo/commit_status" .}}
15-
<span class="ui gt-ml-3 gt-f1">{{.Context}} <span class="text grey">{{.Description}}</span></span>
16-
{{if .TargetURL}}
17-
<a class="gt-ml-3" href="{{.TargetURL}}" target="_blank" rel="noopener noreferrer">{{$.root.locale.Tr "repo.pulls.status_checks_details"}}</a>
18-
{{end}}
19-
</div>
20-
{{end}}
12+
{{template "repo/pulls/status" (dict
13+
"locale" .root.locale
14+
"CommitStatuses" .Statuses
15+
"CommitStatus" .Status
16+
"IsTippy" true
17+
"is_context_required" .root.is_context_required
18+
)}}
2119
</div>
2220
{{end}}

templates/repo/issue/view_content/pull.tmpl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
{{- else if .Issue.PullRequest.CanAutoMerge}}green
2121
{{- else}}red{{end}}">{{svg "octicon-git-merge" 40}}</a>
2222
<div class="content">
23-
{{template "repo/pulls/status" .}}
23+
{{template "repo/pulls/status" (dict
24+
"locale" .locale
25+
"CommitStatus" .LatestCommitStatus
26+
"CommitStatuses" .LatestCommitStatuses
27+
"is_context_required" .is_context_required
28+
)}}
2429
{{$showGeneralMergeForm := false}}
2530
<div class="ui attached merge-section segment {{if not $.LatestCommitStatus}}no-header{{end}} flex-items-block">
2631
{{if .Issue.PullRequest.HasMerged}}

templates/repo/pulls/status.tmpl

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,42 @@
1-
{{if $.LatestCommitStatus}}
2-
{{if not $.Issue.PullRequest.HasMerged}}
3-
<div class="ui top attached header">
4-
{{if eq .LatestCommitStatus.State "pending"}}
5-
{{$.locale.Tr "repo.pulls.status_checking"}}
6-
{{else if eq .LatestCommitStatus.State "success"}}
7-
{{$.locale.Tr "repo.pulls.status_checks_success"}}
8-
{{else if eq .LatestCommitStatus.State "warning"}}
9-
{{$.locale.Tr "repo.pulls.status_checks_warning"}}
10-
{{else if eq .LatestCommitStatus.State "failure"}}
11-
{{$.locale.Tr "repo.pulls.status_checks_failure"}}
12-
{{else if eq .LatestCommitStatus.State "error"}}
13-
{{$.locale.Tr "repo.pulls.status_checks_error"}}
14-
{{else}}
15-
{{$.locale.Tr "repo.pulls.status_checking"}}
16-
{{end}}
17-
<div class="ui right">
18-
<a class="hide-all-checks muted"
19-
data-show-all="{{$.locale.Tr "repo.pulls.status_checks_show_all"}}"
20-
data-hide-all="{{$.locale.Tr "repo.pulls.status_checks_hide_all"}}">
21-
{{$.locale.Tr "repo.pulls.status_checks_hide_all"}}</a>
22-
</div>
1+
{{/*
2+
Template Attributes:
3+
* locale: passed through for localization
4+
* CommitStatus: summary of all commit status state
5+
* CommitStatuses: all commit status elements
6+
* IsTippy: whether this template is the content of tippy
7+
* is_context_required: Used in pull request commit status check table
8+
*/}}
9+
10+
{{if .CommitStatus}}
11+
<div class="{{if .IsTippy}}tippy-commit-status{{else}}pr-commit-status{{end}}">
12+
<div class="ui attached header top">
13+
{{if eq .CommitStatus.State "pending"}}
14+
{{.locale.Tr "repo.pulls.status_checking"}}
15+
{{else if eq .CommitStatus.State "success"}}
16+
{{.locale.Tr "repo.pulls.status_checks_success"}}
17+
{{else if eq .CommitStatus.State "warning"}}
18+
{{.locale.Tr "repo.pulls.status_checks_warning"}}
19+
{{else if eq .CommitStatus.State "failure"}}
20+
{{.locale.Tr "repo.pulls.status_checks_failure"}}
21+
{{else if eq .CommitStatus.State "error"}}
22+
{{.locale.Tr "repo.pulls.status_checks_error"}}
23+
{{else}}
24+
{{.locale.Tr "repo.pulls.status_checking"}}
25+
{{end}}
26+
27+
{{if not .IsTippy}}
28+
<div class="ui right">
29+
<a class="hide-all-checks muted"
30+
data-show-all="{{.locale.Tr "repo.pulls.status_checks_show_all"}}"
31+
data-hide-all="{{.locale.Tr "repo.pulls.status_checks_hide_all"}}">
32+
{{.locale.Tr "repo.pulls.status_checks_hide_all"}}</a>
2333
</div>
24-
{{end}}
34+
{{end}}
35+
</div>
2536

26-
<div class="ui attached segment pr-status-list">
27-
{{range $.LatestCommitStatuses}}
28-
<div class="ui attached segment pr-status">
37+
<div class="ui attached segment commit-status-list">
38+
{{range .CommitStatuses}}
39+
<div class="ui attached segment commit-status-item">
2940
{{template "repo/commit_status" .}}
3041
<div class="status-context">
3142
<span>{{.Context}} <span class="text grey">{{.Description}}</span></span>
@@ -39,4 +50,5 @@
3950
</div>
4051
{{end}}
4152
</div>
53+
</div>
4254
{{end}}

web_src/css/modules/tippy.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
.tippy-content {
3939
position: relative;
40-
padding: 1rem;
40+
padding: 0;
4141
z-index: 1;
4242
}
4343

web_src/css/repo.css

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3284,68 +3284,86 @@ tbody.commit-list {
32843284
}
32853285
}
32863286

3287-
.ui.segment.pr-status-list {
3287+
.ui.segment.commit-status-list {
32883288
padding: 0;
32893289
max-height: 30vh;
32903290
overflow-x: hidden;
32913291
transition: max-height 0.4s;
3292+
border-bottom: 0 !important;
3293+
}
3294+
3295+
.pr-commit-status.hide {
3296+
border-bottom: 0 !important;
3297+
}
3298+
3299+
.pr-commit-status.hide .ui.attached.header {
3300+
border-bottom: 0 !important;
32923301
}
32933302

3294-
.ui.segment.pr-status-list.hide{
3303+
.pr-commit-status.hide .commit-status-list {
32953304
padding: 0;
32963305
max-height: 0;
32973306
overflow-x: hidden;
32983307
transition: max-height 0.4s;
3308+
border: 0;
32993309
}
33003310

3301-
.pr-status {
3311+
.commit-status-item {
33023312
padding: 0 !important; /* To clear fomantic's padding on .ui.segment elements */
33033313
display: flex;
33043314
align-items: center;
33053315
}
33063316

3307-
.pr-status:first-child {
3317+
.commit-status-item:first-child {
33083318
border-top: none !important;
33093319
}
33103320

3311-
.pr-status:last-child {
3321+
.commit-status-item:last-child {
33123322
border-bottom: none !important;
33133323
}
33143324

3315-
.pr-status .commit-status {
3325+
.commit-status-item .commit-status {
33163326
margin: 1em;
33173327
flex-shrink: 0;
33183328
}
33193329

3320-
.pr-status .status-context {
3330+
.commit-status-item .status-context {
33213331
display: flex;
33223332
justify-content: space-between;
33233333
width: 100%;
33243334
}
33253335

3326-
.pr-status .status-context > span {
3336+
.commit-status-item .status-context > span {
33273337
padding: 1em 0;
33283338
}
33293339

3330-
.pr-status .status-details {
3340+
.commit-status-item .status-details {
33313341
display: flex;
33323342
padding-right: 0.5em;
33333343
align-items: center;
33343344
justify-content: flex-end;
33353345
}
33363346

33373347
@media (max-width: 767.98px) {
3338-
.pr-status .status-details {
3348+
.commit-status-item .status-details {
33393349
flex-direction: column;
33403350
align-items: flex-end;
33413351
justify-content: center;
33423352
}
33433353
}
33443354

3345-
.pr-status .status-details > span {
3355+
.commit-status-item .status-details > span {
33463356
padding-right: 0.5em; /* To match the alignment with the "required" label */
33473357
}
33483358

3359+
.tippy-commit-status {
3360+
max-width: 100vw;
3361+
}
3362+
3363+
.tippy-commit-status .ui.attached.header {
3364+
border-top: 0 !important;
3365+
}
3366+
33493367
.search-fullname {
33503368
color: var(--color-text-light-2);
33513369
}

web_src/js/features/repo-issue-pr-status.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import $ from 'jquery';
22

33
export function initRepoPullRequestCommitStatus() {
4-
const $prStatusList = $('.pr-status-list');
4+
const $prStatus = $('.pr-status');
55

66
$('.hide-all-checks').on('click', async (e) => {
77
e.preventDefault();
88
const $this = $(e.currentTarget);
9-
if ($prStatusList.hasClass('hide')) {
10-
$prStatusList.removeClass('hide');
9+
10+
if ($prStatus.hasClass('hide')) {
11+
$prStatus.removeClass('hide');
1112
$this.text($this.attr('data-hide-all'));
1213
} else {
13-
$prStatusList.addClass('hide');
14+
$prStatus.addClass('hide');
1415
$this.text($this.attr('data-show-all'));
1516
}
1617
});

0 commit comments

Comments
 (0)