Skip to content

Commit 023aaef

Browse files
fnetXforgejo-backport-action
authored andcommitted
New repo: Rework advanced and template sections
- make sections collapsible - only offer object format selection when there is an actual choice (cherry picked from commit 4cde569)
1 parent cb745a7 commit 023aaef

File tree

5 files changed

+114
-92
lines changed

5 files changed

+114
-92
lines changed

options/locale/locale_en-US.ini

Lines changed: 4 additions & 0 deletions
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

templates/repo/create.tmpl

Lines changed: 13 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -20,75 +20,22 @@
2020
{{template "repo/create_basic" .}}
2121
</fieldset>
2222

23-
<div class="inline field">
24-
<label>{{ctx.Locale.Tr "repo.template"}}</label>
25-
<div id="repo_template_search" class="ui search selection dropdown">
26-
<input type="hidden" id="repo_template" name="repo_template" value="{{if ne .repo_template 0}}{{.repo_template}}{{end}}">
27-
<div class="default text">{{.repo_template_name}}</div>
28-
<div class="menu">
29-
</div>
30-
</div>
31-
</div>
32-
33-
<div id="template_units" class="tw-hidden">
34-
<div class="inline field">
35-
<label>{{ctx.Locale.Tr "repo.template.items"}}</label>
36-
<div class="ui checkbox">
37-
<input name="git_content" type="checkbox" {{if .git_content}}checked{{end}}>
38-
<label>{{ctx.Locale.Tr "repo.template.git_content"}}</label>
39-
</div>
40-
<div class="ui checkbox" {{if not .SignedUser.CanEditGitHook}}data-tooltip-content="{{ctx.Locale.Tr "repo.template.git_hooks_tooltip"}}"{{end}}>
41-
<input name="git_hooks" type="checkbox" {{if .git_hooks}}checked{{end}}>
42-
<label>{{ctx.Locale.Tr "repo.template.git_hooks"}}</label>
43-
</div>
44-
</div>
45-
<div class="inline field">
46-
<label></label>
47-
<div class="ui checkbox">
48-
<input name="webhooks" type="checkbox" {{if .webhooks}}checked{{end}}>
49-
<label>{{ctx.Locale.Tr "repo.template.webhooks"}}</label>
50-
</div>
51-
<div class="ui checkbox">
52-
<input name="topics" type="checkbox" {{if .topics}}checked{{end}}>
53-
<label>{{ctx.Locale.Tr "repo.template.topics"}}</label>
54-
</div>
55-
</div>
56-
<div class="inline field">
57-
<label></label>
58-
<div class="ui checkbox">
59-
<input name="avatar" type="checkbox" {{if .avatar}}checked{{end}}>
60-
<label>{{ctx.Locale.Tr "repo.template.avatar"}}</label>
61-
</div>
62-
<div class="ui checkbox">
63-
<input name="labels" type="checkbox" {{if .labels}}checked{{end}}>
64-
<label>{{ctx.Locale.Tr "repo.template.issue_labels"}}</label>
65-
</div>
66-
</div>
67-
<div class="inline field">
68-
<label></label>
69-
<div class="ui checkbox">
70-
<input name="protected_branch" type="checkbox" {{if .protected_branch}}checked{{end}}>
71-
<label>{{ctx.Locale.Tr "repo.settings.protected_branch"}}</label>
72-
</div>
73-
</div>
74-
</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>
7530

7631
<div id="non_template">
77-
<div class="inline field">
78-
<label>{{ctx.Locale.Tr "repo.issue_labels"}}</label>
79-
<div class="ui search selection dropdown">
80-
<input type="hidden" name="issue_labels" value="{{.issueLabels}}">
81-
<div class="default text">{{ctx.Locale.Tr "repo.issue_labels_helper"}}</div>
82-
<div class="menu">
83-
<div class="item" data-value="">{{ctx.Locale.Tr "repo.issue_labels_helper"}}</div>
84-
{{range .LabelTemplateFiles}}
85-
<div class="item" data-value="{{.DisplayName}}">{{.DisplayName}}<br><p>({{.Description}})</p></div>
86-
{{end}}
87-
</div>
88-
</div>
89-
</div>
32+
<fieldset>
33+
<legend>{{ctx.Locale.Tr "repo.new_advanced"}}</legend>
34+
<details><summary>{{ctx.Locale.Tr "repo.new_advanced_expand"}}</summary>
35+
{{template "repo/create_advanced" .}}
36+
</details>
37+
</fieldset>
9038

91-
<div class="divider"></div>
9239

9340
<div class="inline field">
9441
<label>.gitignore</label>
@@ -137,31 +84,6 @@
13784
<label>{{ctx.Locale.Tr "repo.auto_init"}}</label>
13885
</div>
13986
</div>
140-
<div class="inline field">
141-
<label for="default_branch">{{ctx.Locale.Tr "repo.default_branch"}}</label>
142-
<input id="default_branch" name="default_branch" value="{{.default_branch}}" placeholder="{{.default_branch}}">
143-
<span class="help">{{ctx.Locale.Tr "repo.default_branch_helper"}}</span>
144-
</div>
145-
<div class="inline field">
146-
<label>{{ctx.Locale.Tr "repo.object_format"}}</label>
147-
<div class="ui selection owner dropdown">
148-
<input type="hidden" id="object_format_name" name="object_format_name" value="{{.DefaultObjectFormat.Name}}" required>
149-
<div class="default text">{{.DefaultObjectFormat.Name}}</div>
150-
<div class="menu">
151-
{{range .SupportedObjectFormats}}
152-
<div class="item" data-value="{{.Name}}">{{.Name}}</div>
153-
{{end}}
154-
</div>
155-
</div>
156-
<span class="help">{{ctx.Locale.Tr "repo.object_format_helper"}}</span>
157-
</div>
158-
<div class="inline field">
159-
<label>{{ctx.Locale.Tr "repo.template"}}</label>
160-
<div class="ui checkbox">
161-
<input name="template" type="checkbox">
162-
<label>{{ctx.Locale.Tr "repo.template_helper"}}</label>
163-
</div>
164-
</div>
16587
</div>
16688
<br>
16789
<div class="inline field">
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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
<label id="repo_owner_label" {{if .Err_Owner}}class="field error"{{end}}>{{ctx.Locale.Tr "repo.owner"}}
1+
<label id="repo_owner_label" {{if .Err_Owner}}class="field error"{{end}}>
2+
{{ctx.Locale.Tr "repo.owner"}}
23
<div class="ui selection required dropdown" aria-labelledby="repo_owner_label">
4+
{{/* uid id is used by the repo-template code */}}
35
<input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required>
46
<span class="text truncated-item-container" title="{{.ContextUser.Name}}">
57
{{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}}
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)