Skip to content

Commit eb00a80

Browse files
author
Earl Warren
committed
Merge pull request '[v10.0/forgejo] Rework new repo dialog' (go-gitea#6399) from bp-v10.0/forgejo-471e5b1-8159915-4cde569-8d32ca3-8d829a9 into v10.0/forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6399 Reviewed-by: 0ko <[email protected]>
2 parents c7c22aa + f1b98d1 commit eb00a80

File tree

13 files changed

+490
-305
lines changed

13 files changed

+490
-305
lines changed

options/locale/locale_en-US.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,10 @@ admin.failed_to_replace_flags = Failed to replace repository flags
10531053
admin.flags_replaced = Repository flags replaced
10541054

10551055
new_repo_helper = A repository contains all project files, including revision history. Already hosting one elsewhere? <a href="%s">Migrate repository</a>.
1056+
new_from_template = Use a template
1057+
new_from_template_description = You can select an existing repository template on this instance and apply its settings.
1058+
new_advanced = Advanced settings
1059+
new_advanced_expand = Click to expand
10561060
owner = Owner
10571061
owner_helper = Some organizations may not show up in the dropdown due to a maximum repository count limit.
10581062
repo_name = Repository name
@@ -1099,7 +1103,8 @@ object_format_helper = Object format of the repository. Cannot be changed later.
10991103
readme = README
11001104
readme_helper = Select a README file template
11011105
readme_helper_desc = This is the place where you can write a complete description for your project.
1102-
auto_init = Initialize repository (Adds .gitignore, License and README)
1106+
auto_init = Initialize repository
1107+
auto_init_description = Start the Git history with a README and optionally add License and .gitignore files.
11031108
create_repo = Create repository
11041109
default_branch = Default branch
11051110
default_branch_label = default

templates/repo/create.tmpl

Lines changed: 24 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -16,206 +16,34 @@
1616
<p>{{ctx.Locale.TrN .MaxCreationLimit "repo.form.reach_limit_of_creation_1" "repo.form.reach_limit_of_creation_n" .MaxCreationLimit}}</p>
1717
</div>
1818
{{end}}
19-
<div class="inline required field {{if .Err_Owner}}error{{end}}">
20-
<label>{{ctx.Locale.Tr "repo.owner"}}</label>
21-
<div class="ui selection owner dropdown">
22-
<input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required>
23-
<span class="text truncated-item-container" title="{{.ContextUser.Name}}">
24-
{{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}}
25-
<span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span>
26-
</span>
27-
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
28-
<div class="menu">
29-
<div class="item truncated-item-container" data-value="{{.SignedUser.ID}}" title="{{.SignedUser.Name}}">
30-
{{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}}
31-
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
32-
</div>
33-
{{range .Orgs}}
34-
<div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}">
35-
{{ctx.AvatarUtils.Avatar . 28 "mini"}}
36-
<span class="truncated-item-name">{{.ShortName 40}}</span>
37-
</div>
38-
{{end}}
39-
</div>
40-
</div>
41-
<span class="help">{{ctx.Locale.Tr "repo.owner_helper"}}</span>
42-
</div>
19+
<fieldset>
20+
{{template "repo/create_basic" .}}
21+
</fieldset>
4322

44-
<div class="inline required field {{if .Err_RepoName}}error{{end}}">
45-
<label for="repo_name">{{ctx.Locale.Tr "repo.repo_name"}}</label>
46-
<input id="repo_name" name="repo_name" value="{{.repo_name}}" autofocus required maxlength="100">
47-
<span class="help">{{ctx.Locale.Tr "repo.repo_name_helper"}}</span>
48-
</div>
49-
<div class="inline field">
50-
<label>{{ctx.Locale.Tr "repo.visibility"}}</label>
51-
<div class="ui checkbox">
52-
<input name="private" type="checkbox"
53-
{{if .IsForcedPrivate}}
54-
checked disabled
55-
{{else}}
56-
{{if .private}}checked{{end}}
57-
{{end}}>
58-
<label>{{ctx.Locale.Tr "repo.visibility_helper"}}</label>
59-
</div>
60-
{{if .IsForcedPrivate}}
61-
<span class="help">{{ctx.Locale.Tr "repo.visibility_helper_forced"}}</span>
62-
{{end}}
63-
<span class="help">{{ctx.Locale.Tr "repo.visibility_description"}}</span>
64-
</div>
65-
<div class="inline field {{if .Err_Description}}error{{end}}">
66-
<label for="description">{{ctx.Locale.Tr "repo.repo_desc"}}</label>
67-
<textarea id="description" rows="2" name="description" placeholder="{{ctx.Locale.Tr "repo.repo_desc_helper"}}" maxlength="2048">{{.description}}</textarea>
68-
</div>
69-
<div class="inline field">
70-
<label>{{ctx.Locale.Tr "repo.template"}}</label>
71-
<div id="repo_template_search" class="ui search selection dropdown">
72-
<input type="hidden" id="repo_template" name="repo_template" value="{{if ne .repo_template 0}}{{.repo_template}}{{end}}">
73-
<div class="default text">{{.repo_template_name}}</div>
74-
<div class="menu">
75-
</div>
76-
</div>
77-
</div>
78-
79-
<div id="template_units" class="tw-hidden">
80-
<div class="inline field">
81-
<label>{{ctx.Locale.Tr "repo.template.items"}}</label>
82-
<div class="ui checkbox">
83-
<input name="git_content" type="checkbox" {{if .git_content}}checked{{end}}>
84-
<label>{{ctx.Locale.Tr "repo.template.git_content"}}</label>
85-
</div>
86-
<div class="ui checkbox" {{if not .SignedUser.CanEditGitHook}}data-tooltip-content="{{ctx.Locale.Tr "repo.template.git_hooks_tooltip"}}"{{end}}>
87-
<input name="git_hooks" type="checkbox" {{if .git_hooks}}checked{{end}}>
88-
<label>{{ctx.Locale.Tr "repo.template.git_hooks"}}</label>
89-
</div>
90-
</div>
91-
<div class="inline field">
92-
<label></label>
93-
<div class="ui checkbox">
94-
<input name="webhooks" type="checkbox" {{if .webhooks}}checked{{end}}>
95-
<label>{{ctx.Locale.Tr "repo.template.webhooks"}}</label>
96-
</div>
97-
<div class="ui checkbox">
98-
<input name="topics" type="checkbox" {{if .topics}}checked{{end}}>
99-
<label>{{ctx.Locale.Tr "repo.template.topics"}}</label>
100-
</div>
101-
</div>
102-
<div class="inline field">
103-
<label></label>
104-
<div class="ui checkbox">
105-
<input name="avatar" type="checkbox" {{if .avatar}}checked{{end}}>
106-
<label>{{ctx.Locale.Tr "repo.template.avatar"}}</label>
107-
</div>
108-
<div class="ui checkbox">
109-
<input name="labels" type="checkbox" {{if .labels}}checked{{end}}>
110-
<label>{{ctx.Locale.Tr "repo.template.issue_labels"}}</label>
111-
</div>
112-
</div>
113-
<div class="inline field">
114-
<label></label>
115-
<div class="ui checkbox">
116-
<input name="protected_branch" type="checkbox" {{if .protected_branch}}checked{{end}}>
117-
<label>{{ctx.Locale.Tr "repo.settings.protected_branch"}}</label>
118-
</div>
119-
</div>
120-
</div>
23+
<fieldset>
24+
<legend>
25+
{{ctx.Locale.Tr "repo.new_from_template"}}
26+
<span class="help">{{ctx.Locale.Tr "repo.new_from_template_description"}}</span>
27+
</legend>
28+
{{template "repo/create_from_template" .}}
29+
</fieldset>
12130

12231
<div id="non_template">
123-
<div class="inline field">
124-
<label>{{ctx.Locale.Tr "repo.issue_labels"}}</label>
125-
<div class="ui search selection dropdown">
126-
<input type="hidden" name="issue_labels" value="{{.issueLabels}}">
127-
<div class="default text">{{ctx.Locale.Tr "repo.issue_labels_helper"}}</div>
128-
<div class="menu">
129-
<div class="item" data-value="">{{ctx.Locale.Tr "repo.issue_labels_helper"}}</div>
130-
{{range .LabelTemplateFiles}}
131-
<div class="item" data-value="{{.DisplayName}}">{{.DisplayName}}<br><p>({{.Description}})</p></div>
132-
{{end}}
133-
</div>
134-
</div>
135-
</div>
32+
<fieldset>
33+
<legend>{{ctx.Locale.Tr "repo.auto_init"}}</legend>
34+
{{template "repo/create_init" .}}
35+
</fieldset>
13636

137-
<div class="divider"></div>
138-
139-
<div class="inline field">
140-
<label>.gitignore</label>
141-
<div class="ui multiple search selection dropdown">
142-
<input type="hidden" name="gitignores" value="{{.gitignores}}">
143-
<div class="default text">{{ctx.Locale.Tr "repo.repo_gitignore_helper"}}</div>
144-
<div class="menu">
145-
{{range .Gitignores}}
146-
<div class="item" data-value="{{.}}">{{.}}</div>
147-
{{end}}
148-
</div>
149-
</div>
150-
<span class="help">{{ctx.Locale.Tr "repo.repo_gitignore_helper_desc"}}</span>
151-
</div>
152-
<div class="inline field">
153-
<label>{{ctx.Locale.Tr "repo.license"}}</label>
154-
<div class="ui search selection dropdown">
155-
<input type="hidden" name="license" value="{{.license}}">
156-
<div class="default text">{{ctx.Locale.Tr "repo.license_helper"}}</div>
157-
<div class="menu">
158-
<div class="item" data-value="">{{ctx.Locale.Tr "repo.license_helper"}}</div>
159-
{{range .Licenses}}
160-
<div class="item" data-value="{{.}}">{{.}}</div>
161-
{{end}}
162-
</div>
163-
</div>
164-
<span class="help">{{ctx.Locale.Tr "repo.license_helper_desc" "https://choosealicense.com/"}}</span>
165-
</div>
166-
167-
<div class="inline field">
168-
<label>{{ctx.Locale.Tr "repo.readme"}}</label>
169-
<div class="ui selection dropdown">
170-
<input type="hidden" name="readme" value="{{.readme}}">
171-
<div class="default text">{{ctx.Locale.Tr "repo.readme_helper"}}</div>
172-
<div class="menu">
173-
{{range .Readmes}}
174-
<div class="item" data-value="{{.}}">{{.}}</div>
175-
{{end}}
176-
</div>
177-
</div>
178-
<span class="help">{{ctx.Locale.Tr "repo.readme_helper_desc"}}</span>
179-
</div>
180-
<div class="inline field">
181-
<div class="ui checkbox" id="auto-init">
182-
<input name="auto_init" type="checkbox" {{if .auto_init}}checked{{end}}>
183-
<label>{{ctx.Locale.Tr "repo.auto_init"}}</label>
184-
</div>
185-
</div>
186-
<div class="inline field">
187-
<label for="default_branch">{{ctx.Locale.Tr "repo.default_branch"}}</label>
188-
<input id="default_branch" name="default_branch" value="{{.default_branch}}" placeholder="{{.default_branch}}">
189-
<span class="help">{{ctx.Locale.Tr "repo.default_branch_helper"}}</span>
190-
</div>
191-
<div class="inline field">
192-
<label>{{ctx.Locale.Tr "repo.object_format"}}</label>
193-
<div class="ui selection owner dropdown">
194-
<input type="hidden" id="object_format_name" name="object_format_name" value="{{.DefaultObjectFormat.Name}}" required>
195-
<div class="default text">{{.DefaultObjectFormat.Name}}</div>
196-
<div class="menu">
197-
{{range .SupportedObjectFormats}}
198-
<div class="item" data-value="{{.Name}}">{{.Name}}</div>
199-
{{end}}
200-
</div>
201-
</div>
202-
<span class="help">{{ctx.Locale.Tr "repo.object_format_helper"}}</span>
203-
</div>
204-
<div class="inline field">
205-
<label>{{ctx.Locale.Tr "repo.template"}}</label>
206-
<div class="ui checkbox">
207-
<input name="template" type="checkbox">
208-
<label>{{ctx.Locale.Tr "repo.template_helper"}}</label>
209-
</div>
210-
</div>
211-
</div>
212-
<br>
213-
<div class="inline field">
214-
<label></label>
215-
<button class="ui primary button{{if not .CanCreateRepo}} disabled{{end}}">
216-
{{ctx.Locale.Tr "repo.create_repo"}}
217-
</button>
218-
</div>
37+
<fieldset>
38+
<legend>{{ctx.Locale.Tr "repo.new_advanced"}}</legend>
39+
<details><summary>{{ctx.Locale.Tr "repo.new_advanced_expand"}}</summary>
40+
{{template "repo/create_advanced" .}}
41+
</details>
42+
</fieldset>
43+
</div>
44+
<button class="ui primary button{{if not .CanCreateRepo}} disabled{{end}}">
45+
{{ctx.Locale.Tr "repo.create_repo"}}
46+
</button>
21947
</div>
22048
</form>
22149
</div>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<label>
2+
{{ctx.Locale.Tr "repo.issue_labels"}}
3+
<div class="ui search selection dropdown">
4+
<input type="hidden" name="issue_labels" value="{{.issueLabels}}">
5+
<div class="default text">{{ctx.Locale.Tr "repo.issue_labels_helper"}}</div>
6+
<div class="menu">
7+
<div class="item" data-value="">{{ctx.Locale.Tr "repo.issue_labels_helper"}}</div>
8+
{{range .LabelTemplateFiles}}
9+
<div class="item" data-value="{{.DisplayName}}">{{.DisplayName}}<br><p>({{.Description}})</p></div>
10+
{{end}}
11+
</div>
12+
</div>
13+
</label>
14+
15+
{{$supportedFormatsLength := len .SupportedObjectFormats}}
16+
{{/* Only offer object format selection if there is an actual choice */}}
17+
{{if ge $supportedFormatsLength 2}}
18+
<label>
19+
{{ctx.Locale.Tr "repo.object_format"}}
20+
<div class="ui selection dropdown">
21+
<input type="hidden" id="object_format_name" name="object_format_name" value="{{.DefaultObjectFormat.Name}}" required>
22+
<div class="default text">{{.DefaultObjectFormat.Name}}</div>
23+
<div class="menu">
24+
{{range .SupportedObjectFormats}}
25+
<div class="item" data-value="{{.Name}}">{{.Name}}</div>
26+
{{end}}
27+
</div>
28+
</div>
29+
<span class="help">{{ctx.Locale.Tr "repo.object_format_helper"}}</span>
30+
</label>
31+
{{else}}
32+
<input type="hidden" name="object_format_name" value="{{.DefaultObjectFormat.Name}}" required>
33+
{{end}}
34+
35+
<label>
36+
{{ctx.Locale.Tr "repo.default_branch"}}
37+
<input name="default_branch" value="{{.default_branch}}" placeholder="{{.default_branch}}">
38+
<span class="help">{{ctx.Locale.Tr "repo.default_branch_helper"}}</span>
39+
</label>
40+
41+
<label>
42+
<input name="template" type="checkbox">
43+
{{ctx.Locale.Tr "repo.template_helper"}}
44+
<span class="help">{{ctx.Locale.Tr "repo.template_description"}}</span>
45+
</label>

templates/repo/create_basic.tmpl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<label id="repo_owner_label" {{if .Err_Owner}}class="field error"{{end}}>
2+
{{ctx.Locale.Tr "repo.owner"}}
3+
<div class="ui selection required dropdown" aria-labelledby="repo_owner_label">
4+
{{/* uid id is used by the repo-template code */}}
5+
<input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required>
6+
<span class="text truncated-item-container" title="{{.ContextUser.Name}}">
7+
{{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}}
8+
<span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span>
9+
</span>
10+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
11+
<div class="menu">
12+
<div class="item truncated-item-container" data-value="{{.SignedUser.ID}}" title="{{.SignedUser.Name}}">
13+
{{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}}
14+
<span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span>
15+
</div>
16+
{{range .Orgs}}
17+
<div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}">
18+
{{ctx.AvatarUtils.Avatar . 28 "mini"}}
19+
<span class="truncated-item-name">{{.ShortName 40}}</span>
20+
</div>
21+
{{end}}
22+
</div>
23+
</div>
24+
<span class="help">{{ctx.Locale.Tr "repo.owner_helper"}}</span>
25+
</label>
26+
<label {{if .Err_RepoName}}class="field error"{{end}}>
27+
{{ctx.Locale.Tr "repo.repo_name"}}
28+
<input name="repo_name" value="{{.repo_name}}" required maxlength="100">
29+
<span class="help">{{ctx.Locale.Tr "repo.repo_name_helper"}}</span>
30+
</label>
31+
<label>
32+
<input name="private" type="checkbox"
33+
{{if .IsForcedPrivate}}
34+
checked disabled
35+
{{else}}
36+
{{if .private}}checked{{end}}
37+
{{end}}>
38+
{{ctx.Locale.Tr "repo.visibility_helper"}}
39+
{{if .IsForcedPrivate}}
40+
<span class="help">{{ctx.Locale.Tr "repo.visibility_helper_forced"}}</span>
41+
{{end}}
42+
<span class="help">{{ctx.Locale.Tr "repo.visibility_description"}}</span>
43+
</label>
44+
<label {{if .Err_Description}}class="field error"{{end}}>
45+
{{ctx.Locale.Tr "repo.repo_desc"}}
46+
<textarea rows="2" name="description" placeholder="{{ctx.Locale.Tr "repo.repo_desc_helper"}}" maxlength="2048">{{.description}}</textarea>
47+
</label>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<label class="tw-mb-0">
2+
{{ctx.Locale.Tr "repo.template"}}
3+
</label>
4+
{{/* If the dropdown is inside the label, the focus works correctly and it is more accessible.
5+
However, the Javascript takes the focus and opens the dropdown again immediately after closing.
6+
When the user interacts (via mouse or keyboard), the dropdown closes again.
7+
Due to the fieldset legend, this solutions is probably acceptable until the dropdown can be fixed properly. */}}
8+
<div id="repo_template_search" class="ui search selection dropdown tw-w-full">
9+
<input type="hidden" id="repo_template" name="repo_template" value="{{if ne .repo_template 0}}{{.repo_template}}{{end}}">
10+
<div class="default text">{{.repo_template_name}}</div>
11+
<div class="menu">
12+
</div>
13+
</div>
14+
15+
<fieldset id="template_units" class="tw-hidden simple-grid grid-2">
16+
<legend>{{ctx.Locale.Tr "repo.template.items"}}</legend>
17+
18+
<label>
19+
<input name="git_content" type="checkbox" {{if .git_content}}checked{{end}}>
20+
{{ctx.Locale.Tr "repo.template.git_content"}}
21+
</label>
22+
<label>
23+
<input name="webhooks" type="checkbox" {{if .webhooks}}checked{{end}}>
24+
{{ctx.Locale.Tr "repo.template.webhooks"}}
25+
</label>
26+
<label>
27+
<input name="topics" type="checkbox" {{if .topics}}checked{{end}}>
28+
{{ctx.Locale.Tr "repo.template.topics"}}
29+
</label>
30+
<label>
31+
<input name="avatar" type="checkbox" {{if .avatar}}checked{{end}}>
32+
{{ctx.Locale.Tr "repo.template.avatar"}}
33+
</label>
34+
<label>
35+
<input name="labels" type="checkbox" {{if .labels}}checked{{end}}>
36+
{{ctx.Locale.Tr "repo.template.issue_labels"}}
37+
</label>
38+
<label>
39+
<input name="protected_branch" type="checkbox" {{if .protected_branch}}checked{{end}}>
40+
{{ctx.Locale.Tr "repo.settings.protected_branch"}}
41+
</label>
42+
<label>
43+
<input name="git_hooks" type="checkbox" {{if .git_hooks}}checked{{end}}>
44+
{{ctx.Locale.Tr "repo.template.git_hooks"}}
45+
{{if not .SignedUser.CanEditGitHook}}
46+
<span class="help">{{ctx.Locale.Tr "repo.template.git_hooks_tooltip"}}</span>
47+
{{end}}
48+
</label>
49+
</fieldset>

0 commit comments

Comments
 (0)