mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-26 23:35:51 +03:00
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>
This commit is contained in:
parent
37ca4cb7d6
commit
7d1aed83f4
1 changed files with 15 additions and 17 deletions
|
@ -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>
|
<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}}
|
{{end}}
|
||||||
{{if or .CanAddFile .CanUploadFile}}
|
{{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>
|
<span class="text">{{.locale.Tr "repo.editor.add_file"}}</span>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
{{if .Repository.CanEnableEditor}}
|
{{if .CanAddFile}}
|
||||||
{{if .CanAddFile}}
|
<a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
|
||||||
<a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
|
{{.locale.Tr "repo.editor.new_file"}}
|
||||||
{{.locale.Tr "repo.editor.new_file"}}
|
</a>
|
||||||
</a>
|
{{end}}
|
||||||
{{end}}
|
{{if .CanUploadFile}}
|
||||||
{{if .CanUploadFile}}
|
<a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
|
||||||
<a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
|
{{.locale.Tr "repo.editor.upload_file"}}
|
||||||
{{.locale.Tr "repo.editor.upload_file"}}
|
</a>
|
||||||
</a>
|
{{end}}
|
||||||
{{end}}
|
{{if .CanAddFile}}
|
||||||
{{if .CanAddFile}}
|
<a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
|
||||||
<a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
|
{{.locale.Tr "repo.editor.patch"}}
|
||||||
{{.locale.Tr "repo.editor.patch"}}
|
</a>
|
||||||
</a>
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
||||||
|
|
Loading…
Reference in a new issue