Skip to content

Commit 7d1aed8

Browse files
silverwindlafrikslunny
authored
Disable the 'Add File' button when not able to edit repo (#21503)
Previously, the button would render a dropdown with zero items when `.CanEnableEditor` was false (for example on a mirror repo). Now it disables the button instead which is better UX. <img width="310" alt="image" src="https://user-images.githubusercontent.com/115237/196546655-7262070d-dd8f-4fbe-ad5c-ecb443a9caef.png"> <img width="292" alt="image" src="https://user-images.githubusercontent.com/115237/196546694-51ef5792-16d4-463d-aae8-7ef22dba6bb4.png"> Co-authored-by: Lauris BH <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
1 parent 37ca4cb commit 7d1aed8

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

templates/repo/home.tmpl

+15-17
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,23 @@
7777
<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>
7878
{{end}}
7979
{{if or .CanAddFile .CanUploadFile}}
80-
<button class="ui basic small compact dropdown jump icon button mr-2">
80+
<button class="ui basic small compact dropdown jump icon button mr-2"{{if not .Repository.CanEnableEditor}} disabled{{end}}>
8181
<span class="text">{{.locale.Tr "repo.editor.add_file"}}</span>
8282
<div class="menu">
83-
{{if .Repository.CanEnableEditor}}
84-
{{if .CanAddFile}}
85-
<a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
86-
{{.locale.Tr "repo.editor.new_file"}}
87-
</a>
88-
{{end}}
89-
{{if .CanUploadFile}}
90-
<a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
91-
{{.locale.Tr "repo.editor.upload_file"}}
92-
</a>
93-
{{end}}
94-
{{if .CanAddFile}}
95-
<a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
96-
{{.locale.Tr "repo.editor.patch"}}
97-
</a>
98-
{{end}}
83+
{{if .CanAddFile}}
84+
<a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
85+
{{.locale.Tr "repo.editor.new_file"}}
86+
</a>
87+
{{end}}
88+
{{if .CanUploadFile}}
89+
<a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
90+
{{.locale.Tr "repo.editor.upload_file"}}
91+
</a>
92+
{{end}}
93+
{{if .CanAddFile}}
94+
<a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
95+
{{.locale.Tr "repo.editor.patch"}}
96+
</a>
9997
{{end}}
10098
</div>
10199
{{svg "octicon-triangle-down" 14 "dropdown icon"}}

0 commit comments

Comments
 (0)