Skip to content

Commit 33b03e8

Browse files
Restore history button and hide add button when unable to add (#20718)
Fix two regressions from #20602: - Restore the 'History' button that was previously unable to render because it's show condition was never hit - Hide the 'Add File' button when there would be no items in the dropdown. Co-authored-by: wxiaoguang <[email protected]>
1 parent 871082b commit 33b03e8

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

templates/repo/home.tmpl

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -73,34 +73,31 @@
7373
</a>
7474
{{end}}
7575
<a href="{{.Repository.Link}}/find/{{.BranchNameSubURL}}" class="ui compact basic button tooltip" data-content="{{.locale.Tr "repo.find_file.go_to_file"}}">{{svg "octicon-file-moved" 15}}</a>
76-
<button class="ui basic small compact dropdown jump icon button mr-2">
77-
<span class="text">{{.locale.Tr "repo.editor.add_file"}}</span>
78-
<div class="menu">
79-
{{if .Repository.CanEnableEditor}}
80-
{{if .CanAddFile}}
81-
<a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
82-
{{.locale.Tr "repo.editor.new_file"}}
83-
</a>
84-
{{end}}
85-
{{if .CanUploadFile}}
86-
<a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
87-
{{.locale.Tr "repo.editor.upload_file"}}
88-
</a>
89-
{{end}}
90-
{{if .CanAddFile}}
91-
<a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
92-
{{.locale.Tr "repo.editor.patch"}}
93-
</a>
76+
{{if or .CanAddFile .CanUploadFile}}
77+
<button class="ui basic small compact dropdown jump icon button mr-2">
78+
<span class="text">{{.locale.Tr "repo.editor.add_file"}}</span>
79+
<div class="menu">
80+
{{if .Repository.CanEnableEditor}}
81+
{{if .CanAddFile}}
82+
<a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
83+
{{.locale.Tr "repo.editor.new_file"}}
84+
</a>
85+
{{end}}
86+
{{if .CanUploadFile}}
87+
<a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
88+
{{.locale.Tr "repo.editor.upload_file"}}
89+
</a>
90+
{{end}}
91+
{{if .CanAddFile}}
92+
<a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
93+
{{.locale.Tr "repo.editor.patch"}}
94+
</a>
95+
{{end}}
9496
{{end}}
95-
{{end}}
96-
{{if and (ne $n 0) (not .IsViewFile) (not .IsBlame) }}
97-
<a class="item"href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/{{.TreePath | PathEscapeSegments}}">
98-
{{.locale.Tr "repo.file_history"}}
99-
</a>
100-
{{end}}
101-
</div>
102-
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
103-
</button>
97+
</div>
98+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
99+
</button>
100+
{{end}}
104101
{{else}}
105102
<span class="ui breadcrumb repo-path"><a class="section" href="{{.RepoLink}}/src/{{.BranchNameSubURL}}" title="{{.Repository.Name}}">{{EllipsisString .Repository.Name 30}}</a>{{range $i, $v := .TreeNames}}<span class="divider">/</span>{{if eq $i $l}}<span class="active section" title="{{$v}}">{{EllipsisString $v 30}}</span>{{else}}{{ $p := index $.Paths $i}}<span class="section"><a href="{{$.BranchLink}}/{{PathEscapeSegments $p}}" title="{{$v}}">{{EllipsisString $v 30}}</a></span>{{end}}{{end}}</span>
106103
{{end}}
@@ -133,6 +130,11 @@
133130
{{end}}
134131
</div>
135132
{{end}}
133+
{{if and (ne $n 0) (not .IsViewFile) (not .IsBlame) }}
134+
<a class="ui button" href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/{{.TreePath | PathEscapeSegments}}">
135+
{{svg "octicon-history" 16 "mr-3"}}{{.locale.Tr "repo.file_history"}}
136+
</a>
137+
{{end}}
136138
</div>
137139
</div>
138140
{{if .IsViewFile}}

0 commit comments

Comments
 (0)