From b7f2739dfe7e1032b5399cf2021bc3677fb628dc Mon Sep 17 00:00:00 2001 From: Robert Wolff Date: Thu, 1 Aug 2024 13:32:01 +0200 Subject: [PATCH] feat(UI): add links to icons in repository file list --- templates/repo/view_list.tmpl | 19 +++++++++---------- tests/integration/repo_test.go | 10 +++++----- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index 7ec9acc84..b750e9129 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -14,7 +14,7 @@ {{if .HasParentPath}} - {{svg "octicon-reply"}}.. + {{svg "octicon-reply" 16 "tw-mr-2"}}.. {{end}} {{range $item := .Files}} @@ -25,30 +25,29 @@ {{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}} - {{$entry.Name}}@{{ShortSha $subModuleFile.RefID}} + {{$icon}}{{$entry.Name}}@{{ShortSha $subModuleFile.RefID}} {{else}} - {{$entry.Name}}@{{ShortSha $subModuleFile.RefID}} + {{$icon}}{{$entry.Name}}@{{ShortSha $subModuleFile.RefID}} {{end}} {{else}} {{if $entry.IsDir}} {{$subJumpablePathName := $entry.GetSubJumpablePathName}} - {{svg "octicon-file-directory-fill"}} {{$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 -}} {{StringUtils.Join $subJumpablePathPrefixes "/"}}/{{index $subJumpablePathFields $subJumpablePathFieldLast}} {{end}} {{else}} - {{svg (printf "octicon-%s" (EntryIcon $entry))}} - {{$entry.Name}} + {{svg (printf "octicon-%s" (EntryIcon $entry)) 16 "tw-mr-2"}}{{$entry.Name}} {{end}} {{end}} diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index c1d2f327b..1651bc4f1 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -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