Skip to content

Commit

Permalink
Merge pull request 'feat(UI): add links to icons in repository file l…
Browse files Browse the repository at this point in the history
…ist' (#4648) from mahlzahn/forgejo:add_icon_links_file_list into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4648
Reviewed-by: Gusted <[email protected]>
  • Loading branch information
Earl Warren committed Aug 1, 2024
2 parents 3d3ddd7 + b7f2739 commit 9df2fbb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
19 changes: 9 additions & 10 deletions templates/repo/view_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<tbody>
{{if .HasParentPath}}
<tr class="has-parent">
<td colspan="3">{{svg "octicon-reply"}}<a class="muted" href="{{.BranchLink}}{{if .ParentPath}}{{PathEscapeSegments .ParentPath}}{{end}}">..</a></td>
<td colspan="3"><a class="muted" href="{{.BranchLink}}{{if .ParentPath}}{{PathEscapeSegments .ParentPath}}{{end}}">{{svg "octicon-reply" 16 "tw-mr-2"}}..</a></td>
</tr>
{{end}}
{{range $item := .Files}}
Expand All @@ -25,30 +25,29 @@
<td class="name four wide">
<span class="truncate">
{{if $entry.IsSubModule}}
{{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 */}}
{{$icon := (svg "octicon-file-submodule" 16 "tw-mr-2")}}
{{if $refURL}}
<a class="muted" href="{{$refURL}}">{{$entry.Name}}</a><span class="at">@</span><a href="{{$refURL}}/commit/{{PathEscape $subModuleFile.RefID}}">{{ShortSha $subModuleFile.RefID}}</a>
<a class="muted" href="{{$refURL}}">{{$icon}}{{$entry.Name}}</a><span class="at">@</span><a href="{{$refURL}}/commit/{{PathEscape $subModuleFile.RefID}}">{{ShortSha $subModuleFile.RefID}}</a>
{{else}}
{{$entry.Name}}<span class="at">@</span>{{ShortSha $subModuleFile.RefID}}
{{$icon}}{{$entry.Name}}<span class="at">@</span>{{ShortSha $subModuleFile.RefID}}
{{end}}
{{else}}
{{if $entry.IsDir}}
{{$subJumpablePathName := $entry.GetSubJumpablePathName}}
{{svg "octicon-file-directory-fill"}}
<a class="muted" href="{{$.TreeLink}}/{{PathEscapeSegments $subJumpablePathName}}" title="{{$subJumpablePathName}}">
{{$subJumpablePathFields := StringUtils.Split $subJumpablePathName "/"}}
{{$subJumpablePathFieldLast := (Eval (len $subJumpablePathFields) "-" 1)}}
{{if eq $subJumpablePathFieldLast 0}}
{{svg "octicon-file-directory-fill" 16 "tw-mr-2" -}}
{{if eq $subJumpablePathFieldLast 0 -}}
{{$subJumpablePathName}}
{{else}}
{{$subJumpablePathPrefixes := slice $subJumpablePathFields 0 $subJumpablePathFieldLast}}
{{else -}}
{{$subJumpablePathPrefixes := slice $subJumpablePathFields 0 $subJumpablePathFieldLast -}}
<span class="text light-2">{{StringUtils.Join $subJumpablePathPrefixes "/"}}</span>/{{index $subJumpablePathFields $subJumpablePathFieldLast}}
{{end}}
</a>
{{else}}
{{svg (printf "octicon-%s" (EntryIcon $entry))}}
<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}}">{{svg (printf "octicon-%s" (EntryIcon $entry)) 16 "tw-mr-2"}}{{$entry.Name}}</a>
{{end}}
{{end}}
</span>
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ func TestViewRepoWithSymlinks(t *testing.T) {
return fmt.Sprintf("%s: %s", file, cls)
})
assert.Len(t, items, 5)
assert.Equal(t, "a: svg octicon-file-directory-fill", items[0])
assert.Equal(t, "link_b: svg octicon-file-directory-symlink", items[1])
assert.Equal(t, "link_d: svg octicon-file-symlink-file", items[2])
assert.Equal(t, "link_hi: svg octicon-file-symlink-file", items[3])
assert.Equal(t, "link_link: svg octicon-file-symlink-file", items[4])
assert.Equal(t, "a: tw-mr-2 svg octicon-file-directory-fill", items[0])
assert.Equal(t, "link_b: tw-mr-2 svg octicon-file-directory-symlink", items[1])
assert.Equal(t, "link_d: tw-mr-2 svg octicon-file-symlink-file", items[2])
assert.Equal(t, "link_hi: tw-mr-2 svg octicon-file-symlink-file", items[3])
assert.Equal(t, "link_link: tw-mr-2 svg octicon-file-symlink-file", items[4])
}

// TestViewAsRepoAdmin tests PR #2167
Expand Down

0 comments on commit 9df2fbb

Please sign in to comment.