mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-30 20:27:30 +00:00
9681c83734
* Add branch protection for approvals Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add required approvals Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing comments and fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add type = approval and group by reviewer_id to review * Prevent users from adding negative review limits * Add migration for approval whitelists Signed-off-by: Jonas Franz <info@jonasfranz.software>
159 lines
6.4 KiB
Cheetah
159 lines
6.4 KiB
Cheetah
{{template "base/head" .}}
|
|
<div class="repository settings branches">
|
|
{{template "repo/header" .}}
|
|
{{template "repo/settings/navbar" .}}
|
|
<div class="ui container">
|
|
{{template "base/alert" .}}
|
|
<h4 class="ui top attached header">
|
|
{{.i18n.Tr "repo.settings.branch_protection" .Branch.BranchName | Str2html}}
|
|
</h4>
|
|
<div class="ui attached segment branch-protection">
|
|
<form class="ui form" action="{{.Link}}" method="post">
|
|
{{.CsrfTokenHtml}}
|
|
<div class="inline field">
|
|
<div class="ui checkbox">
|
|
<input class="enable-protection" name="protected" type="checkbox" data-target="#protection_box" {{if .Branch.IsProtected}}checked{{end}}>
|
|
<label>{{.i18n.Tr "repo.settings.protect_this_branch"}}</label>
|
|
<p class="help">{{.i18n.Tr "repo.settings.protect_this_branch_desc"}}</p>
|
|
</div>
|
|
</div>
|
|
<div id="protection_box" class="fields {{if not .Branch.IsProtected}}disabled{{end}}">
|
|
<div class="field">
|
|
<div class="ui checkbox">
|
|
<input class="enable-whitelist" name="enable_whitelist" type="checkbox" data-target="#whitelist_box" {{if .Branch.EnableWhitelist}}checked{{end}}>
|
|
<label>{{.i18n.Tr "repo.settings.protect_whitelist_committers"}}</label>
|
|
<p class="help">{{.i18n.Tr "repo.settings.protect_whitelist_committers_desc"}}</p>
|
|
</div>
|
|
</div>
|
|
<div id="whitelist_box" class="fields {{if not .Branch.EnableWhitelist}}disabled{{end}}">
|
|
<div class="whitelist field">
|
|
<label>{{.i18n.Tr "repo.settings.protect_whitelist_users"}}</label>
|
|
<div class="ui multiple search selection dropdown">
|
|
<input type="hidden" name="whitelist_users" value="{{.whitelist_users}}">
|
|
<div class="default text">{{.i18n.Tr "repo.settings.protect_whitelist_search_users"}}</div>
|
|
<div class="menu">
|
|
{{range .Users}}
|
|
<div class="item" data-value="{{.ID}}">
|
|
<img class="ui mini image" src="{{.RelAvatarLink}}">
|
|
{{.Name}}
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{if .Owner.IsOrganization}}
|
|
<br>
|
|
<div class="whitelist field">
|
|
<label>{{.i18n.Tr "repo.settings.protect_whitelist_teams"}}</label>
|
|
<div class="ui multiple search selection dropdown">
|
|
<input type="hidden" name="whitelist_teams" value="{{.whitelist_teams}}">
|
|
<div class="default text">{{.i18n.Tr "repo.settings.protect_whitelist_search_teams"}}</div>
|
|
<div class="menu">
|
|
{{range .Teams}}
|
|
<div class="item" data-value="{{.ID}}">
|
|
<i class="octicon octicon-jersey"></i>
|
|
{{.Name}}
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
|
|
<div class="field">
|
|
<div class="ui checkbox">
|
|
<input class="enable-whitelist" name="enable_merge_whitelist" type="checkbox" data-target="#merge_whitelist_box" {{if .Branch.EnableMergeWhitelist}}checked{{end}}>
|
|
<label>{{.i18n.Tr "repo.settings.protect_merge_whitelist_committers"}}</label>
|
|
<p class="help">{{.i18n.Tr "repo.settings.protect_merge_whitelist_committers_desc"}}</p>
|
|
</div>
|
|
</div>
|
|
<div id="merge_whitelist_box" class="fields {{if not .Branch.EnableMergeWhitelist}}disabled{{end}}">
|
|
<div class="whitelist field">
|
|
<label>{{.i18n.Tr "repo.settings.protect_merge_whitelist_users"}}</label>
|
|
<div class="ui multiple search selection dropdown">
|
|
<input type="hidden" name="merge_whitelist_users" value="{{.merge_whitelist_users}}">
|
|
<div class="default text">{{.i18n.Tr "repo.settings.protect_whitelist_search_users"}}</div>
|
|
<div class="menu">
|
|
{{range .Users}}
|
|
<div class="item" data-value="{{.ID}}">
|
|
<img class="ui mini image" src="{{.RelAvatarLink}}">
|
|
{{.Name}}
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{if .Owner.IsOrganization}}
|
|
<br>
|
|
<div class="whitelist field">
|
|
<label>{{.i18n.Tr "repo.settings.protect_merge_whitelist_teams"}}</label>
|
|
<div class="ui multiple search selection dropdown">
|
|
<input type="hidden" name="merge_whitelist_teams" value="{{.merge_whitelist_teams}}">
|
|
<div class="default text">{{.i18n.Tr "repo.settings.protect_whitelist_search_teams"}}</div>
|
|
<div class="menu">
|
|
{{range .Teams}}
|
|
<div class="item" data-value="{{.ID}}">
|
|
<i class="octicon octicon-jersey"></i>
|
|
{{.Name}}
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label for="required-approvals">{{.i18n.Tr "repo.settings.protect_required_approvals"}}</label>
|
|
<input name="required_approvals" id="required-approvals" type="number" value="{{.Branch.RequiredApprovals}}">
|
|
<p class="help">{{.i18n.Tr "repo.settings.protect_required_approvals_desc"}}</p>
|
|
</div>
|
|
<div class="fields">
|
|
<div class="whitelist field">
|
|
<label>{{.i18n.Tr "repo.settings.protect_approvals_whitelist_users"}}</label>
|
|
<div class="ui multiple search selection dropdown">
|
|
<input type="hidden" name="approvals_whitelist_users" value="{{.approvals_whitelist_users}}">
|
|
<div class="default text">{{.i18n.Tr "repo.settings.protect_whitelist_search_users"}}</div>
|
|
<div class="menu">
|
|
{{range .Users}}
|
|
<div class="item" data-value="{{.ID}}">
|
|
<img class="ui mini image" src="{{.RelAvatarLink}}">
|
|
{{.Name}}
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{if .Owner.IsOrganization}}
|
|
<br>
|
|
<div class="whitelist field">
|
|
<label>{{.i18n.Tr "repo.settings.protect_approvals_whitelist_teams"}}</label>
|
|
<div class="ui multiple search selection dropdown">
|
|
<input type="hidden" name="approvals_whitelist_teams" value="{{.approvals_whitelist_teams}}">
|
|
<div class="default text">{{.i18n.Tr "repo.settings.protect_whitelist_search_teams"}}</div>
|
|
<div class="menu">
|
|
{{range .Teams}}
|
|
<div class="item" data-value="{{.ID}}">
|
|
<i class="octicon octicon-jersey"></i>
|
|
{{.Name}}
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
<div class="field">
|
|
<button class="ui green button">{{$.i18n.Tr "repo.settings.update_settings"}}</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{template "base/footer" .}}
|