Skip to content

Commit c88f3d8

Browse files
committed
Fix file table overflows
- Fix overflow regression from go-gitea#12553. - Fix submodule columns stretching the table - Refactor template to share more HTML nodes - Introduce CSS helper classes
1 parent eb4db04 commit c88f3d8

File tree

5 files changed

+52
-34
lines changed

5 files changed

+52
-34
lines changed

integrations/repo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func TestViewRepoWithSymlinks(t *testing.T) {
148148
resp := session.MakeRequest(t, req, http.StatusOK)
149149

150150
htmlDoc := NewHTMLParser(t, resp.Body)
151-
files := htmlDoc.doc.Find("#repo-files-table > TBODY > TR > TD.name")
151+
files := htmlDoc.doc.Find("#repo-files-table > TBODY > TR > TD.name > SPAN.truncate")
152152
items := files.Map(func(i int, s *goquery.Selection) string {
153153
cls, _ := s.Find("SVG").Attr("class")
154154
file := strings.Trim(s.Find("A").Text(), " \t\n")

templates/repo/view_list.tmpl

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,37 +43,39 @@
4343
{{$entry := index $item 0}}
4444
{{$commit := index $item 1}}
4545
<tr>
46-
{{if $entry.IsSubModule}}
47-
<td>
48-
{{svg "octicon-file-submodule" 16}}
49-
{{$refURL := $commit.RefURL AppUrl $.Repository.FullName}}
50-
{{if $refURL}}
51-
<a href="{{$refURL}}">{{$entry.Name}}</a> @ <a href="{{$refURL}}/commit/{{$commit.RefID}}">{{ShortSha $commit.RefID}}</a>
46+
<td class="name four wide">
47+
<span class="truncate">
48+
{{if $entry.IsSubModule}}
49+
{{svg "octicon-file-submodule" 16}}
50+
{{$refURL := $commit.RefURL AppUrl $.Repository.FullName}}
51+
{{if $refURL}}
52+
<a class="flex-0" href="{{$refURL}}">{{$entry.Name}}</a><span class="at">@</span><a class="flex-1" href="{{$refURL}}/commit/{{$commit.RefID}}">{{ShortSha $commit.RefID}}</a>
53+
{{else}}
54+
{{$entry.Name}}<span class="at">@</span>{{ShortSha $commit.RefID}}
55+
{{end}}
5256
{{else}}
53-
{{$entry.Name}} @ {{ShortSha $commit.RefID}}
57+
{{if $entry.IsDir}}
58+
{{$subJumpablePathName := $entry.GetSubJumpablePathName}}
59+
{{$subJumpablePath := SubJumpablePath $subJumpablePathName}}
60+
{{svg "octicon-file-directory" 16}}
61+
<a class="flex-1" href="{{EscapePound $.TreeLink}}/{{EscapePound $subJumpablePathName}}" title="{{$subJumpablePathName}}">
62+
{{if eq (len $subJumpablePath) 2}}
63+
<span class="jumpable-path">{{index $subJumpablePath 0}}</span>{{index $subJumpablePath 1}}
64+
{{else}}
65+
{{index $subJumpablePath 0}}
66+
{{end}}
67+
</a>
68+
{{else}}
69+
{{svg (printf "octicon-%s" (EntryIcon $entry)) 16}}
70+
<a class="flex-1" href="{{EscapePound $.TreeLink}}/{{EscapePound $entry.Name}}" title="{{$entry.Name}}">{{$entry.Name}}</a>
71+
{{end}}
5472
{{end}}
55-
</td>
56-
{{else}}
57-
<td class="name four wide">
58-
{{if $entry.IsDir}}
59-
{{$subJumpablePathName := $entry.GetSubJumpablePathName}}
60-
{{$subJumpablePath := SubJumpablePath $subJumpablePathName}}
61-
{{svg "octicon-file-directory" 16}}
62-
<a href="{{EscapePound $.TreeLink}}/{{EscapePound $subJumpablePathName}}" title="{{$subJumpablePathName}}">
63-
{{if eq (len $subJumpablePath) 2}}
64-
<span class="jumpable-path">{{index $subJumpablePath 0}}</span>{{index $subJumpablePath 1}}
65-
{{else}}
66-
{{index $subJumpablePath 0}}
67-
{{end}}
68-
</a>
69-
{{else}}
70-
{{svg (printf "octicon-%s" (EntryIcon $entry)) 16}}
71-
<a href="{{EscapePound $.TreeLink}}/{{EscapePound $entry.Name}}" title="{{$entry.Name}}">{{$entry.Name}}</a>
72-
{{end}}
73-
</td>
74-
{{end}}
73+
</span>
74+
</td>
7575
<td class="message nine wide">
76-
<a href="{{$.RepoLink}}/commit/{{$commit.ID}}" title="{{$commit.Summary}}">{{$commit.Summary | RenderEmoji}}</a>
76+
<span class="truncate">
77+
<a class="flex-1" href="{{$.RepoLink}}/commit/{{$commit.ID}}" title="{{$commit.Summary}}">{{$commit.Summary | RenderEmoji}}</a>
78+
</span>
7779
</td>
7880
<td class="text right age three wide">{{TimeSince $commit.Committer.When $.Lang}}</td>
7981
</tr>

web_src/less/_repository.less

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,23 @@
361361
width: 120px;
362362
}
363363

364-
> a {
365-
width: calc(100% - 8px); /* prevent overflow into adjacant cell */
366-
display: inline-block;
367-
padding-top: 8px;
368-
padding-bottom: 8px;
364+
.truncate {
365+
display: inline-flex;
366+
align-items: center;
369367
overflow: hidden;
370368
text-overflow: ellipsis;
371369
white-space: nowrap;
370+
width: 100%;
371+
}
372+
373+
a {
374+
padding-top: 8px;
375+
padding-bottom: 8px;
376+
}
377+
378+
.at {
379+
margin-left: 3px;
380+
margin-right: 3px;
372381
}
373382

374383
> * {

web_src/less/helpers.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.flex-0 {
2+
flex: 0;
3+
}
4+
.flex-1 {
5+
flex: 1;
6+
}

web_src/less/index.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import "~font-awesome/css/font-awesome.css";
22

3+
@import "./helpers.less";
34
@import "./features/gitgraph.less";
45
@import "./features/animations.less";
56
@import "./markdown/mermaid.less";

0 commit comments

Comments
 (0)