Skip to content

Commit 1046bf4

Browse files
committed
fix
1 parent 893866b commit 1046bf4

File tree

6 files changed

+16
-4
lines changed

6 files changed

+16
-4
lines changed

modules/fileicon/entry.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ func EntryInfoFromGitTreeEntry(gitEntry *git.TreeEntry) *EntryInfo {
2525
func EntryInfoFolder() *EntryInfo {
2626
return &EntryInfo{EntryMode: git.EntryModeTree}
2727
}
28+
29+
func EntryInfoFolderOpen() *EntryInfo {
30+
return &EntryInfo{EntryMode: git.EntryModeTree, IsOpen: true}
31+
}

modules/fileicon/material_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"code.gitea.io/gitea/models/unittest"
1010
"code.gitea.io/gitea/modules/fileicon"
11+
"code.gitea.io/gitea/modules/git"
1112

1213
"github.com/stretchr/testify/assert"
1314
)
@@ -19,8 +20,8 @@ func TestMain(m *testing.M) {
1920
func TestFindIconName(t *testing.T) {
2021
unittest.PrepareTestEnv(t)
2122
p := fileicon.DefaultMaterialIconProvider()
22-
assert.Equal(t, "php", p.FindIconName("foo.php", false, false))
23-
assert.Equal(t, "php", p.FindIconName("foo.PHP", false, false))
24-
assert.Equal(t, "javascript", p.FindIconName("foo.js", false, false))
25-
assert.Equal(t, "visualstudio", p.FindIconName("foo.vba", false, false))
23+
assert.Equal(t, "php", p.FindIconName(&fileicon.EntryInfo{FullName: "foo.php", EntryMode: git.EntryModeBlob}))
24+
assert.Equal(t, "php", p.FindIconName(&fileicon.EntryInfo{FullName: "foo.PHP", EntryMode: git.EntryModeBlob}))
25+
assert.Equal(t, "javascript", p.FindIconName(&fileicon.EntryInfo{FullName: "foo.js", EntryMode: git.EntryModeBlob}))
26+
assert.Equal(t, "visualstudio", p.FindIconName(&fileicon.EntryInfo{FullName: "foo.vba", EntryMode: git.EntryModeBlob}))
2627
}

routers/web/repo/commit.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ func Diff(ctx *context.Context) {
372372

373373
renderedIconPool := fileicon.NewRenderedIconPool()
374374
ctx.PageData["DiffFileTree"] = transformDiffTreeForWeb(renderedIconPool, diffTree, nil)
375+
ctx.PageData["FolderIcon"] = fileicon.RenderEntryIconHTML(renderedIconPool, fileicon.EntryInfoFolder())
376+
ctx.PageData["FolderOpenIcon"] = fileicon.RenderEntryIconHTML(renderedIconPool, fileicon.EntryInfoFolderOpen())
375377
ctx.Data["FileIconPoolHTML"] = renderedIconPool.RenderToHTML()
376378
}
377379

routers/web/repo/compare.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,8 @@ func PrepareCompareDiff(
642642

643643
renderedIconPool := fileicon.NewRenderedIconPool()
644644
ctx.PageData["DiffFileTree"] = transformDiffTreeForWeb(renderedIconPool, diffTree, nil)
645+
ctx.PageData["FolderIcon"] = fileicon.RenderEntryIconHTML(renderedIconPool, fileicon.EntryInfoFolder())
646+
ctx.PageData["FolderOpenIcon"] = fileicon.RenderEntryIconHTML(renderedIconPool, fileicon.EntryInfoFolderOpen())
645647
ctx.Data["FileIconPoolHTML"] = renderedIconPool.RenderToHTML()
646648
}
647649

routers/web/repo/pull.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,8 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
827827

828828
renderedIconPool := fileicon.NewRenderedIconPool()
829829
ctx.PageData["DiffFileTree"] = transformDiffTreeForWeb(renderedIconPool, diffTree, filesViewedState)
830+
ctx.PageData["FolderIcon"] = fileicon.RenderEntryIconHTML(renderedIconPool, fileicon.EntryInfoFolder())
831+
ctx.PageData["FolderOpenIcon"] = fileicon.RenderEntryIconHTML(renderedIconPool, fileicon.EntryInfoFolderOpen())
830832
ctx.Data["FileIconPoolHTML"] = renderedIconPool.RenderToHTML()
831833
}
832834

templates/repo/diff/box.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
{{end}}
6161
<div id="diff-container">
6262
{{if $showFileTree}}
63+
{{$.FileIconPoolHTML}}
6364
<div id="diff-file-tree" class="tw-hidden not-mobile"></div>
6465
<script>
6566
if (diffTreeVisible) document.getElementById('diff-file-tree').classList.remove('tw-hidden');

0 commit comments

Comments
 (0)