aboutsummaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2022-10-19 10:08:33 +0200
committerGitHub <noreply@github.com>2022-10-19 16:08:33 +0800
commit7d1aed83f4d0cdf096ec8758ff8a85ddccf1328d (patch)
tree422fec76e5fac62ba573dc30e68a1d91728c579f /templates
parent37ca4cb7d61c0460d5d8e3dce35964ffc72a9f9d (diff)
downloadgitea-7d1aed83f4d0cdf096ec8758ff8a85ddccf1328d.tar.gz
gitea-7d1aed83f4d0cdf096ec8758ff8a85ddccf1328d.zip
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 <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'templates')
-rw-r--r--templates/repo/home.tmpl32
1 files changed, 15 insertions, 17 deletions
diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl
index c523ce3556..39e58d8e0f 100644
--- a/templates/repo/home.tmpl
+++ b/templates/repo/home.tmpl
@@ -77,25 +77,23 @@
<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>
{{end}}
{{if or .CanAddFile .CanUploadFile}}
- <button class="ui basic small compact dropdown jump icon button mr-2">
+ <button class="ui basic small compact dropdown jump icon button mr-2"{{if not .Repository.CanEnableEditor}} disabled{{end}}>
<span class="text">{{.locale.Tr "repo.editor.add_file"}}</span>
<div class="menu">
- {{if .Repository.CanEnableEditor}}
- {{if .CanAddFile}}
- <a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
- {{.locale.Tr "repo.editor.new_file"}}
- </a>
- {{end}}
- {{if .CanUploadFile}}
- <a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
- {{.locale.Tr "repo.editor.upload_file"}}
- </a>
- {{end}}
- {{if .CanAddFile}}
- <a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
- {{.locale.Tr "repo.editor.patch"}}
- </a>
- {{end}}
+ {{if .CanAddFile}}
+ <a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
+ {{.locale.Tr "repo.editor.new_file"}}
+ </a>
+ {{end}}
+ {{if .CanUploadFile}}
+ <a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
+ {{.locale.Tr "repo.editor.upload_file"}}
+ </a>
+ {{end}}
+ {{if .CanAddFile}}
+ <a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
+ {{.locale.Tr "repo.editor.patch"}}
+ </a>
{{end}}
</div>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}