Skip to content

Fix repo home file list #32788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions templates/repo/home.tmpl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@
{{end}} {{end}}
</div> </div>


{{/* by default, the row-right flex grows, but on non-root tree path, it should not because the row-left might contain a long path */}} <div class="repo-button-row-right">
<div class="repo-button-row-right {{if not $isTreePathRoot}}tw-flex-grow-0{{end}}">
<!-- Only show clone panel in repository home page --> <!-- Only show clone panel in repository home page -->
{{if $isTreePathRoot}} {{if $isTreePathRoot}}
{{template "repo/clone_panel" .}} {{template "repo/clone_panel" .}}
Expand All @@ -124,6 +123,9 @@
{{template "repo/code/upstream_diverging_info" .}} {{template "repo/code/upstream_diverging_info" .}}
{{end}} {{end}}
{{template "repo/view_list" .}} {{template "repo/view_list" .}}
{{if and .ReadmeExist (or .IsMarkup .IsPlainText)}}
{{template "repo/view_file" .}}
{{end}}
{{end}} {{end}}
</div> </div>


Expand Down
2 changes: 1 addition & 1 deletion templates/repo/latest_commit.tmpl
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
{{if not .LatestCommit}} {{if not .LatestCommit}}
<div class="ui active tiny slow centered inline">…</div>
{{else}} {{else}}
{{if .LatestCommitUser}} {{if .LatestCommitUser}}
{{ctx.AvatarUtils.Avatar .LatestCommitUser 24 "tw-mr-1"}} {{ctx.AvatarUtils.Avatar .LatestCommitUser 24 "tw-mr-1"}}
Expand Down
50 changes: 17 additions & 33 deletions templates/repo/view_list.tmpl
Original file line number Original file line Diff line number Diff line change
@@ -1,29 +1,20 @@
<table id="repo-files-table" class="ui single line fixed table tw-mt-0" {{if .HasFilesWithoutLatestCommit}}hx-indicator="tr.notready td.message span" hx-trigger="load" hx-swap="morph" hx-post="{{.LastCommitLoaderURL}}"{{end}}> {{/* use grid layout, still use the old ID because there are many other CSS styles depending on this ID */}}
<thead> <div id="repo-files-table" {{if .HasFilesWithoutLatestCommit}}hx-indicator="#repo-files-table .repo-file-cell.message" hx-trigger="load" hx-swap="morph" hx-post="{{.LastCommitLoaderURL}}"{{end}}>
<tr class="commit-list"> <div class="repo-file-line">
<th class="tw-overflow-hidden" colspan="2"> <div class="latest-commit">{{template "repo/latest_commit" .}}</div>
<div class="tw-flex"> <div>{{if and .LatestCommit .LatestCommit.Committer}}{{DateUtils.TimeSince .LatestCommit.Committer.When}}{{end}}</div>
<div class="latest-commit">
{{template "repo/latest_commit" .}}
</div> </div>
</div>
</th>
<th class="text grey right age">{{if .LatestCommit}}{{if .LatestCommit.Committer}}{{DateUtils.TimeSince .LatestCommit.Committer.When}}{{end}}{{end}}</th>
</tr>
</thead>
<tbody>
{{if .HasParentPath}} {{if .HasParentPath}}
<tr class="has-parent"> <div class="repo-file-line">
<td colspan="3">{{svg "octicon-reply"}}<a class="muted" href="{{.BranchLink}}{{if .ParentPath}}{{PathEscapeSegments .ParentPath}}{{end}}">..</a></td> {{svg "octicon-reply"}} <a class="muted" href="{{.BranchLink}}{{if .ParentPath}}{{PathEscapeSegments .ParentPath}}{{end}}">..</a>
</tr> </div>
{{end}} {{end}}
{{range $item := .Files}} {{range $item := .Files}}
<div class="repo-file-item">
{{$entry := $item.Entry}} {{$entry := $item.Entry}}
{{$commit := $item.Commit}} {{$commit := $item.Commit}}
{{$subModuleFile := $item.SubModuleFile}} {{$subModuleFile := $item.SubModuleFile}}
<tr data-entryname="{{$entry.Name}}" data-ready="{{if $commit}}true{{else}}false{{end}}" class="{{if not $commit}}not{{end}}ready entry"> <div class="repo-file-cell name {{if not $commit}}notready{{end}}">
<td class="name four wide">
<span class="truncate">
{{if $entry.IsSubModule}} {{if $entry.IsSubModule}}
{{svg "octicon-file-submodule"}} {{svg "octicon-file-submodule"}}
{{$refURL := $subModuleFile.RefURL AppUrl $.Repository.FullName $.SSHDomain}} {{/* FIXME: the usage of AppUrl seems incorrect, it would be fixed in the future, use AppSubUrl instead */}} {{$refURL := $subModuleFile.RefURL AppUrl $.Repository.FullName $.SSHDomain}} {{/* FIXME: the usage of AppUrl seems incorrect, it would be fixed in the future, use AppSubUrl instead */}}
Expand Down Expand Up @@ -51,23 +42,16 @@
<a class="muted" href="{{$.TreeLink}}/{{PathEscapeSegments $entry.Name}}" title="{{$entry.Name}}">{{$entry.Name}}</a> <a class="muted" href="{{$.TreeLink}}/{{PathEscapeSegments $entry.Name}}" title="{{$entry.Name}}">{{$entry.Name}}</a>
{{end}} {{end}}
{{end}} {{end}}
</span> </div>
</td> <div class="repo-file-cell message loading-icon-2px">
<td class="message nine wide">
<span class="truncate">
{{if $commit}} {{if $commit}}
{{$commitLink := printf "%s/commit/%s" $.RepoLink (PathEscape $commit.ID.String)}} {{$commitLink := printf "%s/commit/%s" $.RepoLink (PathEscape $commit.ID.String)}}
{{ctx.RenderUtils.RenderCommitMessageLinkSubject $commit.Message $commitLink ($.Repository.ComposeMetas ctx)}} {{ctx.RenderUtils.RenderCommitMessageLinkSubject $commit.Message $commitLink ($.Repository.ComposeMetas ctx)}}
{{else}} {{else}}
<div class="ui active tiny slow centered inline"></div> … {{/* will be loaded again by LastCommitLoaderURL */}}
{{end}}
</span>
</td>
<td class="text right age three wide">{{if $commit}}{{DateUtils.TimeSince $commit.Committer.When}}{{end}}</td>
</tr>
{{end}} {{end}}
</tbody> </div>
</table> <div class="repo-file-cell age">{{if $commit}}{{DateUtils.TimeSince $commit.Committer.When}}{{end}}</div>
{{if and .ReadmeExist (or .IsMarkup .IsPlainText)}} </div>
{{template "repo/view_file" .}}
{{end}} {{end}}
</div>
4 changes: 2 additions & 2 deletions templates/repo/wiki/view.tmpl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{$title := .title}} {{$title := .title}}
<div class="ui container"> <div class="ui container">
<div class="repo-button-row"> <div class="repo-button-row">
<div class="tw-flex tw-items-center"> <div class="flex-text-block tw-flex-1">
<div class="ui floating filter dropdown" data-no-results="{{ctx.Locale.Tr "no_results_found"}}"> <div class="ui floating filter dropdown" data-no-results="{{ctx.Locale.Tr "no_results_found"}}">
<div class="ui basic small button"> <div class="ui basic small button">
<span class="text"> <span class="text">
Expand Down Expand Up @@ -42,7 +42,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="flex-text-block tw-flex-wrap tw-justify-end"> <div class="repo-button-row">
{{if .EscapeStatus.Escaped}} {{if .EscapeStatus.Escaped}}
<a class="ui small button unescape-button tw-m-0 tw-hidden">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</a> <a class="ui small button unescape-button tw-m-0 tw-hidden">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</a>
<a class="ui small button escape-button tw-m-0">{{ctx.Locale.Tr "repo.escape_control_characters"}}</a> <a class="ui small button escape-button tw-m-0">{{ctx.Locale.Tr "repo.escape_control_characters"}}</a>
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/repo_test.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func testViewRepo(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") files := htmlDoc.doc.Find("#repo-files-table .repo-file-item")


type file struct { type file struct {
fileName string fileName string
Expand All @@ -61,7 +61,7 @@ func testViewRepo(t *testing.T) {
var items []file var items []file


files.Each(func(i int, s *goquery.Selection) { files.Each(func(i int, s *goquery.Selection) {
tds := s.Find("td") tds := s.Find(".repo-file-cell")
var f file var f file
tds.Each(func(i int, s *goquery.Selection) { tds.Each(func(i int, s *goquery.Selection) {
if i == 0 { if i == 0 {
Expand Down Expand Up @@ -161,7 +161,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 > SPAN.truncate") files := htmlDoc.doc.Find("#repo-files-table .repo-file-cell.name")
items := files.Map(func(i int, s *goquery.Selection) string { items := files.Map(func(i int, s *goquery.Selection) string {
cls, _ := s.Find("SVG").Attr("class") cls, _ := s.Find("SVG").Attr("class")
file := strings.Trim(s.Find("A").Text(), " \t\n") file := strings.Trim(s.Find("A").Text(), " \t\n")
Expand Down
2 changes: 2 additions & 0 deletions web_src/css/index.css
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@
@import "./repo/wiki.css"; @import "./repo/wiki.css";
@import "./repo/header.css"; @import "./repo/header.css";
@import "./repo/home.css"; @import "./repo/home.css";
@import "./repo/home-file-list.css";
@import "./repo/reactions.css"; @import "./repo/reactions.css";
@import "./repo/clone.css"; @import "./repo/clone.css";
@import "./repo/commit-sign.css";


@import "./editor/fileeditor.css"; @import "./editor/fileeditor.css";
@import "./editor/combomarkdowneditor.css"; @import "./editor/combomarkdowneditor.css";
Expand Down
Loading
Loading