Skip to content

Commit 72e956b

Browse files
HesterGwxiaoguangsilverwindGiteaBot
authored
Improve protected branch setting page (#24379)
Main changes: 1. Change html structure of protected branch page, use [`grouped fields`](https://fomantic-ui.com/collections/form.html#grouped-fields) instead of `fields` for better margin, and wrap `grouped fields` around related `field`s, remove unnecessary `<div id="protection_box" class="fields">` outer div 2. Changed some order of field to make them more categorized, used `ui dividing header` for categorization and fine tune css. Before: <img width="1907" alt="Screen Shot 2023-04-27 at 14 56 19" src="https://user-images.githubusercontent.com/17645053/234783731-bce8a7ce-dfc9-4d47-a3a8-b962ebea9467.png"> <img width="1849" alt="Screen Shot 2023-04-27 at 14 56 30" src="https://user-images.githubusercontent.com/17645053/234783740-c47d314e-5e2d-4854-98fd-c88f85ef3584.png"> <img width="1872" alt="Screen Shot 2023-04-27 at 14 56 36" src="https://user-images.githubusercontent.com/17645053/234783745-18e35a75-07e8-451d-b001-f9bcf16fcab5.png"> After: https://user-images.githubusercontent.com/17645053/235114568-da010aad-7654-4410-ab8c-5d0fce7edadb.mov 3. Changed "Enable Merge Whitelist" to radio checkbox, and added "Enable Merge" radio checkbox, which are exclusive Before: <img width="926" alt="Screen Shot 2023-04-28 at 13 08 29" src="https://user-images.githubusercontent.com/17645053/235059233-75790f7a-e5ea-4e1c-82c6-509fef8b84b3.png"> After: <img width="942" alt="Screen Shot 2023-04-28 at 13 09 28" src="https://user-images.githubusercontent.com/17645053/235059367-852d1f61-8407-4126-8c79-315b9c1ffada.png"> 4. Add a link to set default branch on branch list page (with reference to github) https://user-images.githubusercontent.com/17645053/234787404-61c1c7b6-aabf-429f-a109-5b690e4e0b5a.mov 5. Removed dead codes. --------- Co-authored-by: wxiaoguang <[email protected]> Co-authored-by: silverwind <[email protected]> Co-authored-by: Giteabot <[email protected]>
1 parent fc62992 commit 72e956b

File tree

9 files changed

+181
-212
lines changed

9 files changed

+181
-212
lines changed

options/locale/locale_en-US.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,7 @@ settings.sync_mirror = Synchronize Now
19011901
settings.mirror_sync_in_progress = Mirror synchronization is in progress. Check back in a minute.
19021902
settings.site = Website
19031903
settings.update_settings = Update Settings
1904+
settings.branches.switch_default_branch = Switch Default Branch
19041905
settings.branches.update_default_branch = Update Default Branch
19051906
settings.branches.add_new_rule = Add New Rule
19061907
settings.advanced_settings = Advanced Settings
@@ -2096,6 +2097,8 @@ settings.event_pull_request_review = Pull Request Reviewed
20962097
settings.event_pull_request_review_desc = Pull request approved, rejected, or review comment.
20972098
settings.event_pull_request_sync = Pull Request Synchronized
20982099
settings.event_pull_request_sync_desc = Pull request synchronized.
2100+
settings.event_pull_request_approvals = Pull Request Approvals
2101+
settings.event_pull_request_merge = Pull Request Merge
20992102
settings.event_package = Package
21002103
settings.event_package_desc = Package created or deleted in a repository.
21012104
settings.branch_filter = Branch filter
@@ -2151,13 +2154,15 @@ settings.protected_branch.delete_rule = Delete Rule
21512154
settings.protected_branch_can_push = Allow push?
21522155
settings.protected_branch_can_push_yes = You can push
21532156
settings.protected_branch_can_push_no = You cannot push
2154-
settings.branch_protection = Branch Protection for Branch '<b>%s</b>'
2157+
settings.branch_protection = Branch Protection Rules for Branch '<b>%s</b>'
21552158
settings.protect_this_branch = Enable Branch Protection
21562159
settings.protect_this_branch_desc = Prevents deletion and restricts Git pushing and merging to the branch.
21572160
settings.protect_disable_push = Disable Push
21582161
settings.protect_disable_push_desc = No pushing will be allowed to this branch.
21592162
settings.protect_enable_push = Enable Push
21602163
settings.protect_enable_push_desc = Anyone with write access will be allowed to push to this branch (but not force push).
2164+
settings.protect_enable_merge = Enable Merge
2165+
settings.protect_enable_merge_desc = Anyone with write access will be allowed to merge the pull requests into this branch.
21612166
settings.protect_whitelist_committers = Whitelist Restricted Push
21622167
settings.protect_whitelist_committers_desc = Only whitelisted users or teams will be allowed to push to this branch (but not force push).
21632168
settings.protect_whitelist_deploy_keys = Whitelist deploy keys with write access to push.
@@ -2183,6 +2188,7 @@ settings.dismiss_stale_approvals_desc = When new commits that change the content
21832188
settings.require_signed_commits = Require Signed Commits
21842189
settings.require_signed_commits_desc = Reject pushes to this branch if they are unsigned or unverifiable.
21852190
settings.protect_branch_name_pattern = Protected Branch Name Pattern
2191+
settings.protect_patterns = Patterns
21862192
settings.protect_protected_file_patterns = "Protected file patterns (separated using semicolon ';'):"
21872193
settings.protect_protected_file_patterns_desc = "Protected files are not allowed to be changed directly even if user has rights to add, edit, or delete files in this branch. Multiple patterns can be separated using semicolon (';'). See <a href='https://pkg.go.dev/github.com/gobwas/glob#Compile'>github.com/gobwas/glob</a> documentation for pattern syntax. Examples: <code>.drone.yml</code>, <code>/docs/**/*.txt</code>."
21882194
settings.protect_unprotected_file_patterns = "Unprotected file patterns (separated using semicolon ';'):"

routers/web/repo/setting_protected_branch.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,6 @@ func SettingsProtectedBranch(c *context.Context) {
130130
}
131131

132132
c.Data["branch_status_check_contexts"] = contexts
133-
c.Data["is_context_required"] = func(context string) bool {
134-
for _, c := range rule.StatusCheckContexts {
135-
if c == context {
136-
return true
137-
}
138-
}
139-
return false
140-
}
141-
142133
if c.Repo.Owner.IsOrganization() {
143134
teams, err := organization.OrgFromUser(c.Repo.Owner).TeamsWithAccessToRepo(c.Repo.Repository.ID, perm.AccessModeRead)
144135
if err != nil {

templates/repo/branch/list.tmpl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
{{template "base/alert" .}}
66
{{template "repo/sub_menu" .}}
77
{{if .DefaultBranchBranch}}
8-
<h4 class="ui top attached header gt-mt-4">
8+
<h4 class="ui top attached header">
99
{{.locale.Tr "repo.default_branch"}}
10+
{{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}}
11+
<a role="button" class="right" href="{{.RepoLink}}/settings/branches" data-tooltip-content="{{.locale.Tr "repo.settings.branches.switch_default_branch"}}">
12+
{{svg "octicon-arrow-switch"}}
13+
</a>
14+
{{end}}
1015
</h4>
1116

1217
<div class="ui attached table segment">

templates/repo/settings/branches.tmpl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,13 @@
1212
<p>
1313
{{.locale.Tr "repo.settings.default_branch_desc"}}
1414
</p>
15-
<form class="ui form" action="{{.Link}}" method="post">
15+
<form class="gt-df" action="{{.Link}}" method="post">
1616
{{.CsrfTokenHtml}}
1717
<input type="hidden" name="action" value="default_branch">
1818
{{if not .Repository.IsEmpty}}
19-
<div class="required inline field">
20-
<div class="ui dropdown selection" tabindex="0">
21-
<select name="branch">
22-
<option value="{{.Repository.DefaultBranch}}">{{.Repository.DefaultBranch}}</option>
23-
{{range .Branches}}
24-
<option value="{{.}}">{{.}}</option>
25-
{{end}}
26-
</select>{{svg "octicon-triangle-down" 14 "dropdown icon"}}
19+
<div class="ui dropdown selection gt-f1 gt-mr-3 gt-max-width-24rem">
20+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
21+
<input type="hidden" name="branch" value="{{.Repository.DefaultBranch}}">
2722
<div class="default text">{{.Repository.DefaultBranch}}</div>
2823
<div class="menu">
2924
{{range .Branches}}
@@ -32,7 +27,6 @@
3227
</div>
3328
</div>
3429
<button class="ui green button">{{$.locale.Tr "repo.settings.branches.update_default_branch"}}</button>
35-
</div>
3630
{{end}}
3731
</form>
3832
</div>

0 commit comments

Comments
 (0)