Refactor table width to have more info shown in file list (#6867)

* Refactor table width to have more info shown in file list

* Remove unnecesary semicolon

* Fix tests for changed html structure
This commit is contained in:
Lauris BH 2019-05-06 21:43:40 +03:00 committed by GitHub
parent 01ebd52a1f
commit d9d538c8a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 454 additions and 143 deletions

View File

@ -86,7 +86,7 @@ func TestViewRepoWithSymlinks(t *testing.T) {
resp := session.MakeRequest(t, req, http.StatusOK) resp := session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body) htmlDoc := NewHTMLParser(t, resp.Body)
files := htmlDoc.doc.Find("#repo-files-table > TBODY > TR > TD.name") files := htmlDoc.doc.Find("#repo-files-table > TBODY > TR > TD.name > SPAN")
items := files.Map(func(i int, s *goquery.Selection) string { items := files.Map(func(i int, s *goquery.Selection) string {
cls, _ := s.Find("SPAN").Attr("class") cls, _ := s.Find("SPAN").Attr("class")
file := strings.Trim(s.Find("A").Text(), " \t\n") file := strings.Trim(s.Find("A").Text(), " \t\n")

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
<table id="repo-files-table" class="ui fixed single line table"> <table id="repo-files-table" class="ui single line table">
<thead> <thead>
<tr class="commit-list"> <tr class="commit-list">
<th class="four wide"> <th colspan="2">
{{if .LatestCommitUser}} {{if .LatestCommitUser}}
<img class="ui avatar image img-12" src="{{.LatestCommitUser.RelAvatarLink}}" /> <img class="ui avatar image img-12" src="{{.LatestCommitUser.RelAvatarLink}}" />
{{if .LatestCommitUser.FullName}} {{if .LatestCommitUser.FullName}}
@ -34,9 +34,7 @@
{{end}} {{end}}
{{template "repo/commit_status" .LatestCommitStatus}}</span> {{template "repo/commit_status" .LatestCommitStatus}}</span>
</th> </th>
<th class="nine wide"> <th class="text grey right age">{{if .LatestCommit.Author}}{{TimeSince .LatestCommit.Author.When $.Lang}}{{end}}</th>
</th>
<th class="three wide text grey right age">{{if .LatestCommit.Author}}{{TimeSince .LatestCommit.Author.When $.Lang}}{{end}}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -51,35 +49,41 @@
<tr> <tr>
{{if $entry.IsSubModule}} {{if $entry.IsSubModule}}
<td> <td>
<span class="octicon octicon-file-submodule"></span> <span class="truncate">
{{$refURL := $commit.RefURL AppUrl $.BranchLink}} <span class="octicon octicon-file-submodule"></span>
{{if $refURL}} {{$refURL := $commit.RefURL AppUrl $.BranchLink}}
<a href="{{$refURL}}">{{$entry.Name}}</a> @ <a href="{{$refURL}}/commit/{{$commit.RefID}}">{{ShortSha $commit.RefID}}</a> {{if $refURL}}
{{else}} <a href="{{$refURL}}">{{$entry.Name}}</a> @ <a href="{{$refURL}}/commit/{{$commit.RefID}}">{{ShortSha $commit.RefID}}</a>
{{$entry.Name}} @ {{ShortSha $commit.RefID}} {{else}}
{{end}} {{$entry.Name}} @ {{ShortSha $commit.RefID}}
{{end}}
</span>
</td> </td>
{{else}} {{else}}
<td class="name"> <td class="name">
{{if $entry.IsDir}} <span class="truncate">
{{$subJumpablePathName := $entry.GetSubJumpablePathName}} {{if $entry.IsDir}}
{{$subJumpablePath := SubJumpablePath $subJumpablePathName}} {{$subJumpablePathName := $entry.GetSubJumpablePathName}}
<span class="octicon octicon-file-directory"></span> {{$subJumpablePath := SubJumpablePath $subJumpablePathName}}
<a href="{{EscapePound $.TreeLink}}/{{EscapePound $subJumpablePathName}}" title="{{$subJumpablePathName}}"> <span class="octicon octicon-file-directory"></span>
{{if eq (len $subJumpablePath) 2}} <a href="{{EscapePound $.TreeLink}}/{{EscapePound $subJumpablePathName}}" title="{{$subJumpablePathName}}">
<span class="jumpable-path">{{index $subJumpablePath 0}}</span>{{index $subJumpablePath 1}} {{if eq (len $subJumpablePath) 2}}
{{else}} <span class="jumpable-path">{{index $subJumpablePath 0}}</span>{{index $subJumpablePath 1}}
{{index $subJumpablePath 0}} {{else}}
{{end}} {{index $subJumpablePath 0}}
</a> {{end}}
{{else}} </a>
<span class="octicon octicon-{{EntryIcon $entry}}"></span> {{else}}
<a href="{{EscapePound $.TreeLink}}/{{EscapePound $entry.Name}}" title="{{$entry.Name}}">{{$entry.Name}}</a> <span class="octicon octicon-{{EntryIcon $entry}}"></span>
{{end}} <a href="{{EscapePound $.TreeLink}}/{{EscapePound $entry.Name}}" title="{{$entry.Name}}">{{$entry.Name}}</a>
{{end}}
</span>
</td> </td>
{{end}} {{end}}
<td class="message collapsing has-emoji"> <td class="message has-emoji">
<a href="{{$.RepoLink}}/commit/{{$commit.ID}}">{{$commit.Summary}}</a> <span class="truncate">
<a href="{{$.RepoLink}}/commit/{{$commit.ID}}">{{$commit.Summary}}</a>
</span>
</td> </td>
<td class="text grey right age">{{TimeSince $commit.Committer.When $.Lang}}</td> <td class="text grey right age">{{TimeSince $commit.Committer.When $.Lang}}</td>
</tr> </tr>