Skip to content

Commit 70685a9

Browse files
authored
Fix git graph page (#34948)
fix #34946
1 parent 41678e1 commit 70685a9

File tree

10 files changed

+88
-208
lines changed

10 files changed

+88
-208
lines changed

routers/web/repo/commit.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,13 @@ func Graph(ctx *context.Context) {
166166
ctx.Data["Username"] = ctx.Repo.Owner.Name
167167
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
168168

169+
divOnly := ctx.FormBool("div-only")
170+
queryParams := ctx.Req.URL.Query()
171+
queryParams.Del("div-only")
169172
paginator := context.NewPagination(int(graphCommitsCount), setting.UI.GraphMaxCommitNum, page, 5)
170-
paginator.AddParamFromRequest(ctx.Req)
173+
paginator.AddParamFromQuery(queryParams)
171174
ctx.Data["Page"] = paginator
172-
if ctx.FormBool("div-only") {
175+
if divOnly {
173176
ctx.HTML(http.StatusOK, tplGraphDiv)
174177
return
175178
}

services/context/pagination.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ func (p *Pagination) WithCurRows(n int) *Pagination {
3333
return p
3434
}
3535

36-
func (p *Pagination) AddParamFromRequest(req *http.Request) {
37-
for key, values := range req.URL.Query() {
36+
func (p *Pagination) AddParamFromQuery(q url.Values) {
37+
for key, values := range q {
3838
if key == "page" || len(values) == 0 || (len(values) == 1 && values[0] == "") {
3939
continue
4040
}
@@ -45,6 +45,10 @@ func (p *Pagination) AddParamFromRequest(req *http.Request) {
4545
}
4646
}
4747

48+
func (p *Pagination) AddParamFromRequest(req *http.Request) {
49+
p.AddParamFromQuery(req.URL.Query())
50+
}
51+
4852
// GetParams returns the configured URL params
4953
func (p *Pagination) GetParams() template.URL {
5054
return template.URL(strings.Join(p.urlParams, "&"))

templates/repo/commits_list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
{{end}}
5757
{{if $.CommitsTagsMap}}
5858
{{range (index $.CommitsTagsMap .ID.String)}}
59-
{{- template "repo/tag/name" dict "RepoLink" $.Repository.Link "TagName" .TagName "IsRelease" (not .IsTag) -}}
59+
{{- template "repo/tag/name" dict "AdditionalClasses" "tw-py-0" "RepoLink" $.Repository.Link "TagName" .TagName "IsRelease" (not .IsTag) -}}
6060
{{end}}
6161
{{end}}
6262
</td>

templates/repo/graph.tmpl

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div role="main" aria-label="{{.Title}}" class="page-content repository commits">
33
{{template "repo/header" .}}
44
<div class="ui container">
5-
<div id="git-graph-container" class="ui segment{{if eq .Mode "monochrome"}} monochrome{{end}}">
5+
<div id="git-graph-container" class="ui segment {{if eq .Mode "monochrome"}}monochrome{{end}}">
66
<h2 class="ui header dividing">
77
{{ctx.Locale.Tr "repo.commit_graph"}}
88
<div class="ui icon buttons tiny color-buttons">
@@ -11,35 +11,30 @@
1111
<div class="default text">{{ctx.Locale.Tr "repo.commit_graph.select"}}</div>
1212
<div class="menu">
1313
<div class="item" data-value="...flow-hide-pr-refs">
14-
<span class="truncate">
15-
{{svg "octicon-eye-closed" 16 "tw-mr-1"}}<span title="{{ctx.Locale.Tr "repo.commit_graph.hide_pr_refs"}}">{{ctx.Locale.Tr "repo.commit_graph.hide_pr_refs"}}</span>
16-
</span>
14+
{{svg "octicon-eye-closed"}}
15+
<span class="gt-ellipsis" title="{{ctx.Locale.Tr "repo.commit_graph.hide_pr_refs"}}">{{ctx.Locale.Tr "repo.commit_graph.hide_pr_refs"}}</span>
1716
</div>
1817
{{range .AllRefs}}
1918
{{$refGroup := .RefGroup}}
2019
{{if eq $refGroup "pull"}}
2120
<div class="item" data-value="{{.Name}}">
22-
<span class="truncate">
23-
{{svg "octicon-git-pull-request" 16 "tw-mr-1"}}<span title="{{.ShortName}}">#{{.ShortName}}</span>
24-
</span>
21+
{{svg "octicon-git-pull-request"}}
22+
<span class="gt-ellipsis" title="{{.ShortName}}">#{{.ShortName}}</span>
2523
</div>
2624
{{else if eq $refGroup "tags"}}
2725
<div class="item" data-value="{{.Name}}">
28-
<span class="truncate">
29-
{{svg "octicon-tag" 16 "tw-mr-1"}}<span title="{{.ShortName}}">{{.ShortName}}</span>
30-
</span>
26+
{{svg "octicon-tag"}}
27+
<span class="gt-ellipsis" title="{{.ShortName}}">{{.ShortName}}</span>
3128
</div>
3229
{{else if eq $refGroup "remotes"}}
3330
<div class="item" data-value="{{.Name}}">
34-
<span class="truncate">
35-
{{svg "octicon-cross-reference" 16 "tw-mr-1"}}<span title="{{.ShortName}}">{{.ShortName}}</span>
36-
</span>
31+
{{svg "octicon-cross-reference"}}
32+
<span class="gt-ellipsis" title="{{.ShortName}}">{{.ShortName}}</span>
3733
</div>
3834
{{else if eq $refGroup "heads"}}
3935
<div class="item" data-value="{{.Name}}">
40-
<span class="truncate">
41-
{{svg "octicon-git-branch" 16 "tw-mr-1"}}<span title="{{.ShortName}}">{{.ShortName}}</span>
42-
</span>
36+
{{svg "octicon-git-branch"}}
37+
<span class="gt-ellipsis" title="{{.ShortName}}">{{.ShortName}}</span>
4338
</div>
4439
{{end}}
4540
{{end}}
@@ -49,14 +44,12 @@
4944
<button id="flow-color-colored" class="ui icon button{{if ne .Mode "monochrome"}} active{{end}}" title="{{ctx.Locale.Tr "repo.commit_graph.color"}}">{{svg "material-palette" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.commit_graph.color"}}</button>
5045
</div>
5146
</h2>
52-
<div class="ui dividing"></div>
53-
<div class="is-loading tw-py-32 tw-hidden" id="loading-indicator"></div>
54-
{{template "repo/graph/svgcontainer" .}}
55-
{{template "repo/graph/commits" .}}
47+
<div id="git-graph-body">
48+
{{template "repo/graph/svgcontainer" .}}
49+
{{template "repo/graph/commits" .}}
50+
{{template "base/paginate" .}}
51+
</div>
5652
</div>
5753
</div>
5854
</div>
59-
<div id="pagination">
60-
{{template "base/paginate" .}}
61-
</div>
6255
{{template "base/footer" .}}

templates/repo/graph/commits.tmpl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
{{if $commit.OnlyRelation}}
66
<span></span>
77
{{else}}
8-
{{template "repo/commit_sign_badge" dict "Commit" $commit.Commit "CommitBaseLink" (print $.RepoLink "/commit") "CommitSignVerification" $commit.Verification}}
8+
{{/* every field must be in a span to get correctly styled */}}
9+
<span>
10+
{{template "repo/commit_sign_badge" dict "Commit" $commit.Commit "CommitBaseLink" (print $.RepoLink "/commit") "CommitSignVerification" $commit.Verification}}
11+
</span>
912

1013
<span class="message tw-inline-block gt-ellipsis">
11-
<span>{{ctx.RenderUtils.RenderCommitMessage $commit.Subject $.Repository}}</span>
14+
{{ctx.RenderUtils.RenderCommitMessage $commit.Subject $.Repository}}
1215
</span>
1316

1417
<span class="commit-refs flex-text-inline">
@@ -22,7 +25,7 @@
2225
</a>
2326
{{end}}
2427
{{else if eq $refGroup "tags"}}
25-
{{- template "repo/tag/name" dict "RepoLink" $.Repository.Link "TagName" .ShortName -}}
28+
{{- template "repo/tag/name" dict "AdditionalClasses" "tag-label" "RepoLink" $.Repository.Link "TagName" .ShortName -}}
2629
{{else if eq $refGroup "remotes"}}
2730
<a class="ui basic tiny button" href="{{$.RepoLink}}/src/commit/{{$commit.Rev|PathEscape}}">
2831
{{svg "octicon-cross-reference"}} {{.ShortName}}

templates/repo/graph/div.tmpl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
<div>
2-
{{template "repo/graph/svgcontainer" .}}
3-
{{template "repo/graph/commits" .}}
4-
<div id="pagination">
5-
{{template "base/paginate" .}}
6-
</div>
7-
</div>
1+
{{template "repo/graph/svgcontainer" .}}
2+
{{template "repo/graph/commits" .}}
3+
{{template "base/paginate" .}}

templates/repo/tag/name.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<a class="ui basic label tw-p-1 {{if .IsRelease}}primary{{end}}" href="{{.RepoLink}}/src/tag/{{.TagName|PathEscape}}">
1+
<a class="ui basic label {{if .IsRelease}}primary{{end}} {{.AdditionalClasses}}" href="{{.RepoLink}}/src/tag/{{.TagName|PathEscape}}">
22
{{svg "octicon-tag"}} {{.TagName}}
33
</a>

web_src/css/features/gitgraph.css

Lines changed: 13 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010
align-items: center;
1111
}
1212

13-
#git-graph-container .color-buttons {
14-
margin-right: 0;
15-
}
16-
17-
#git-graph-container .ui.header.dividing {
18-
padding-bottom: 10px;
19-
}
20-
2113
#git-graph-container #flow-select-refs-dropdown {
2214
border-top-right-radius: 0;
2315
border-bottom-right-radius: 0;
@@ -31,42 +23,27 @@
3123
align-items: center;
3224
}
3325

34-
#git-graph-container #flow-select-refs-dropdown .ui.label .truncate {
35-
display: inline-block;
36-
max-width: 140px;
37-
overflow: hidden;
38-
text-overflow: ellipsis;
39-
vertical-align: top;
40-
white-space: nowrap;
41-
}
42-
43-
#git-graph-container #flow-select-refs-dropdown .default.text {
44-
padding-top: 4px;
45-
padding-bottom: 4px;
46-
}
47-
48-
#git-graph-container #flow-select-refs-dropdown input.search {
49-
position: relative;
50-
top: 1px;
51-
}
52-
5326
#git-graph-container li {
5427
list-style-type: none;
5528
height: 24px;
5629
line-height: 24px;
5730
white-space: nowrap;
5831
display: flex;
5932
align-items: center;
60-
gap: 0.25em;
33+
gap: 0.5em;
6134
}
6235

63-
#git-graph-container li .ui.label.commit-id-short {
64-
padding-top: 2px;
65-
padding-bottom: 2px;
36+
#git-graph-container li > span {
37+
flex-shrink: 0;
6638
}
6739

68-
#git-graph-container li .node-relation {
69-
font-family: var(--fonts-monospace);
40+
#git-graph-container li > span.message {
41+
flex-shrink: 1;
42+
}
43+
44+
#git-graph-container li .ui.label.commit-id-short {
45+
padding: 2px 4px;
46+
height: 20px;
7047
}
7148

7249
#git-graph-container li .author {
@@ -78,17 +55,6 @@
7855
font-size: 80%;
7956
}
8057

81-
#git-graph-container li a:not(.ui):hover {
82-
text-decoration: underline;
83-
}
84-
85-
#git-graph-container li a em {
86-
color: var(--color-red);
87-
border-bottom: 1px dotted var(--color-secondary);
88-
text-decoration: none;
89-
font-style: normal;
90-
}
91-
9258
#git-graph-container #rel-container {
9359
max-width: 30%;
9460
overflow-x: auto;
@@ -105,34 +71,23 @@
10571
width: 100%;
10672
}
10773

108-
#git-graph-container #rev-list li.highlight.hover {
109-
background-color: var(--color-secondary-alpha-30);
110-
}
111-
112-
#git-graph-container #rev-list .commit-refs .button {
74+
#git-graph-container li .commit-refs .ui.button,
75+
#git-graph-container li .commit-refs .ui.label.tag-label {
11376
padding: 2px 4px;
11477
margin-right: 0.25em;
11578
display: inline-block;
11679
max-width: 200px;
11780
overflow: hidden;
11881
text-overflow: ellipsis;
82+
line-height: var(--line-height-default);
11983
min-height: 0;
12084
}
12185

122-
#git-graph-container #graph-raw-list {
123-
margin: 0;
124-
}
125-
12686
#git-graph-container.monochrome #rel-container .flow-group {
12787
stroke: var(--color-secondary-dark-5);
12888
fill: var(--color-secondary-dark-5);
12989
}
13090

131-
#git-graph-container.monochrome #rel-container .flow-group.highlight {
132-
stroke: var(--color-secondary-dark-12);
133-
fill: var(--color-secondary-dark-12);
134-
}
135-
13691
#git-graph-container:not(.monochrome) #rel-container .flow-group.flow-color-16-1 {
13792
stroke: #499a37;
13893
fill: #499a37;

web_src/css/modules/label.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.ui.label {
55
display: inline-flex;
66
align-items: center;
7+
vertical-align: middle;
78
gap: var(--gap-inline);
89
min-width: 0;
910
max-width: 100%;
@@ -88,10 +89,6 @@ a.ui.label:hover {
8889
color: var(--color-label-text);
8990
}
9091

91-
.ui.label.visible:not(.dropdown) {
92-
display: inline-block !important;
93-
}
94-
9592
.ui.basic.label {
9693
background: var(--color-button);
9794
border: 1px solid var(--color-light-border);

0 commit comments

Comments
 (0)