aboutsummaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-04-19 21:40:42 +0800
committerGitHub <noreply@github.com>2023-04-19 21:40:42 +0800
commite422342eebc18034ef586ec58f1e2fff0340091d (patch)
tree307264b46c1683915429083d54e9634ee4f2fc4d /templates
parent01214c8ada993bf5f54a4149979d140443d69410 (diff)
downloadgitea-e422342eebc18034ef586ec58f1e2fff0340091d.tar.gz
gitea-e422342eebc18034ef586ec58f1e2fff0340091d.zip
Allow adding new files to an empty repo (#24164)
![image](https://user-images.githubusercontent.com/2114189/232561612-2bfcfd0a-fc04-47ba-965f-5d0bcea46c54.png)
Diffstat (limited to 'templates')
-rw-r--r--templates/repo/editor/commit_form.tmpl2
-rw-r--r--templates/repo/empty.tmpl17
-rw-r--r--templates/repo/home.tmpl28
3 files changed, 30 insertions, 17 deletions
diff --git a/templates/repo/editor/commit_form.tmpl b/templates/repo/editor/commit_form.tmpl
index 7ac0ed3df1..db798d92e8 100644
--- a/templates/repo/editor/commit_form.tmpl
+++ b/templates/repo/editor/commit_form.tmpl
@@ -39,6 +39,7 @@
</label>
</div>
</div>
+ {{if not .Repository.IsEmpty}}
<div class="field">
{{$pullRequestEnabled := .Repository.UnitEnabled $.Context $.UnitTypePullRequests}}
{{$prUnit := .Repository.MustGetUnit $.Context $.UnitTypePullRequests}}
@@ -65,6 +66,7 @@
<span class="text-muted js-quick-pull-normalization-info"></span>
</div>
</div>
+ {{end}}
</div>
</div>
<button id="commit-button" type="submit" class="ui green button">
diff --git a/templates/repo/empty.tmpl b/templates/repo/empty.tmpl
index cb883e8df5..0acb08933a 100644
--- a/templates/repo/empty.tmpl
+++ b/templates/repo/empty.tmpl
@@ -21,8 +21,21 @@
<div class="ui attached guide table segment empty-repo-guide">
<div class="item">
<h3>{{.locale.Tr "repo.clone_this_repo"}} <small>{{.locale.Tr "repo.clone_helper" "http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository" | Str2html}}</small></h3>
- <div class="ui action small input">
- {{template "repo/clone_buttons" .}}
+
+ <div class="gt-df">
+ {{if and .CanWriteCode (not .Repository.IsArchived)}}
+ <a class="ui small button" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/">
+ {{.locale.Tr "repo.editor.new_file"}}
+ </a>
+ {{if .RepositoryUploadEnabled}}
+ <a class="ui small button" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/">
+ {{.locale.Tr "repo.editor.upload_file"}}
+ </a>
+ {{end}}
+ {{end}}
+ <div class="ui action small input gt-df gt-f1">
+ {{template "repo/clone_buttons" .}}
+ </div>
</div>
</div>
diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl
index 8de54611c3..4db12f2c95 100644
--- a/templates/repo/home.tmpl
+++ b/templates/repo/home.tmpl
@@ -71,29 +71,27 @@
{{end}}
<a href="{{.Repository.Link}}/find/{{.BranchNameSubURL}}" class="ui compact basic button">{{.locale.Tr "repo.find_file.go_to_file"}}</a>
{{end}}
- {{if or .CanAddFile .CanUploadFile}}
+
+ {{if and .CanWriteCode .IsViewBranch (not .Repository.IsArchived)}}
<button class="ui basic compact dropdown jump icon button gt-mr-2"{{if not .Repository.CanEnableEditor}} disabled{{end}}>
<span class="text">{{.locale.Tr "repo.editor.add_file"}}</span>
<div class="menu">
- {{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>
+ <a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
+ {{.locale.Tr "repo.editor.new_file"}}
+ </a>
+ {{if .RepositoryUploadEnabled}}
+ <a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
+ {{.locale.Tr "repo.editor.upload_file"}}
+ </a>
{{end}}
+ <a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
+ {{.locale.Tr "repo.editor.patch"}}
+ </a>
</div>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
</button>
{{end}}
+
{{if and (eq $n 0) (.Repository.IsTemplate)}}
<a role="button" class="ui primary compact button" href="{{AppSubUrl}}/repo/create?template_id={{.Repository.ID}}">
{{.locale.Tr "repo.use_template"}}