aboutsummaryrefslogtreecommitdiffstats
path: root/templates/repo/settings/protected_branch.tmpl
blob: 86045f433f0065a4de449ca247a52a4638a713dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
{{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 radio checkbox">
							<input name="enable_push" type="radio" value="none" class="disable-whitelist" data-target="#whitelist_box" {{if not .Branch.CanPush}}checked{{end}}>
							<label>{{.i18n.Tr "repo.settings.protect_disable_push"}}</label>
							<p class="help">{{.i18n.Tr "repo.settings.protect_disable_push_desc"}}</p>
						</div>
					</div>
					<div class="field">
						<div class="ui radio checkbox">
							<input name="enable_push" type="radio" value="all" class="disable-whitelist" data-target="#whitelist_box" {{if and (.Branch.CanPush) (not .Branch.EnableWhitelist)}}checked{{end}}>
							<label>{{.i18n.Tr "repo.settings.protect_enable_push"}}</label>
							<p class="help">{{.i18n.Tr "repo.settings.protect_enable_push_desc"}}</p>
						</div>
					</div>
					<div class="field">
						<div class="ui radio checkbox">
							<input name="enable_push" type="radio" value="whitelist" class="enable-whitelist" data-target="#whitelist_box" {{if and (.Branch.CanPush) (.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}}">
												{{svg "octicon-jersey" 16}}
												{{.Name}}
											</div>
										{{end}}
									</div>
								</div>
							</div>
						{{end}}
						<br>
						<div class="whitelist field">
							<div class="ui checkbox">
								<input type="checkbox" name="whitelist_deploy_keys" {{if .Branch.WhitelistDeployKeys}}checked{{end}}>
								<label for="whitelist_deploy_keys">{{.i18n.Tr "repo.settings.protect_whitelist_deploy_keys"}}</label>
							</div>
						</div>
					</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}}">
										{{svg "octicon-jersey" 16}}
									{{.Name}}
									</div>
								{{end}}
								</div>
							</div>
						</div>
					{{end}}
					</div>

					<div class="field">
						<div class="ui checkbox">
							<input class="enable-statuscheck" name="enable_status_check" type="checkbox" data-target="#statuscheck_contexts_box" {{if .Branch.EnableStatusCheck}}checked{{end}}>
							<label>{{.i18n.Tr "repo.settings.protect_check_status_contexts"}}</label>
							<p class="help">{{.i18n.Tr "repo.settings.protect_check_status_contexts_desc"}}</p>
						</div>
					</div>

					<div id="statuscheck_contexts_box" class="fields {{if not .Branch.EnableStatusCheck}}disabled{{end}}">
						<div class="field">
							<table class="ui celled table six column">
								<thead>
									<tr><th>
										{{.i18n.Tr "repo.settings.protect_check_status_contexts_list"}}
									</th>
									</tr>
								</thead>
								<tbody>
								{{range $.branch_status_check_contexts}}
									<tr><td>
										<span class="ui checkbox">
											<input class="enable-whitelist" name="status_check_contexts" value="{{.}}" type="checkbox" {{if $.is_context_required}}{{if call $.is_context_required .}}checked{{end}}{{end}}>
										</span>
										{{.}}
										{{if $.is_context_required}}{{if call $.is_context_required .}}<div class="ui label right">Required</div>{{end}}{{end}}
									</td></tr>
								{{end}}
								</tbody>
							</table>
						</div>
					</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="field">
						<div class="ui checkbox">
							<input class="enable-whitelist" name="enable_approvals_whitelist" type="checkbox" data-target="#approvals_whitelist_box" {{if .Branch.EnableApprovalsWhitelist}}checked{{end}}>
							<label>{{.i18n.Tr "repo.settings.protect_approvals_whitelist_enabled"}}</label>
							<p class="help">{{.i18n.Tr "repo.settings.protect_approvals_whitelist_enabled_desc"}}</p>
						</div>
					</div>
					<div id="approvals_whitelist_box" class="fields {{if not .Branch.EnableApprovalsWhitelist}}disabled{{end}}">
						<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}}">
											{{svg "octicon-jersey" 16}}
										{{.Name}}
										</div>
									{{end}}
									</div>
								</div>
							</div>
						{{end}}
					</div>
					<div class="field">
						<div class="ui checkbox">
							<input name="block_on_rejected_reviews" type="checkbox" {{if .Branch.BlockOnRejectedReviews}}checked{{end}}>
							<label for="block_on_rejected_reviews">{{.i18n.Tr "repo.settings.block_rejected_reviews"}}</label>
							<p class="help">{{.i18n.Tr "repo.settings.block_rejected_reviews_desc"}}</p>
						</div>
					</div>
					<div class="field">
						<div class="ui checkbox">
							<input name="dismiss_stale_approvals" type="checkbox" {{if .Branch.DismissStaleApprovals}}checked{{end}}>
							<label for="dismiss_stale_approvals">{{.i18n.Tr "repo.settings.dismiss_stale_approvals"}}</label>
							<p class="help">{{.i18n.Tr "repo.settings.dismiss_stale_approvals_desc"}}</p>
						</div>
					</div>
					<div class="field">
						<div class="ui checkbox">
							<input name="require_signed_commits" type="checkbox" {{if .Branch.RequireSignedCommits}}checked{{end}}>
							<label for="require_signed_commits">{{.i18n.Tr "repo.settings.require_signed_commits"}}</label>
							<p class="help">{{.i18n.Tr "repo.settings.require_signed_commits_desc"}}</p>
						</div>
					</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" .}}