summaryrefslogtreecommitdiffstats
path: root/templates/repo/settings/tags.tmpl
blob: e7a7aaa84584b15bc29c2ff305cea7f02d2976e6 (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
{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings edit")}}
	<div class="repo-setting-content">
		{{if .Repository.IsArchived}}
			<div class="ui warning message tw-text-center">
				{{ctx.Locale.Tr "repo.settings.archive.tagsettings_unavailable"}}
			</div>
		{{else}}
			<h4 class="ui top attached header">
				{{ctx.Locale.Tr "repo.settings.tags.protection"}}
			</h4>

			<div class="ui attached segment">
				<div class="ui grid">
					<div class="sixteen wide column">
						<div class="ui segment">
							<form class="ui form" action="{{.Link}}" method="post">
								{{.CsrfTokenHtml}}
								<div class="field">
									<label>{{ctx.Locale.Tr "repo.settings.tags.protection.pattern"}}</label>
									<div id="search-tag-box" class="ui search">
										<div class="ui input">
											<input class="prompt" name="name_pattern" autocomplete="off" value="{{.name_pattern}}" placeholder="v*" autofocus required>
										</div>
										<div class="help">{{ctx.Locale.Tr "repo.settings.tags.protection.pattern.description" "https://forgejo.org/docs/latest/user/protection/#protected-tags"}}</div>
									</div>
								</div>
								<div class="whitelist field">
									<label>{{ctx.Locale.Tr "repo.settings.tags.protection.allowed.users"}}</label>
									<div class="ui multiple search selection dropdown">
										<input type="hidden" name="allowlist_users" value="{{.allowlist_users}}">
										<div class="default text">{{ctx.Locale.Tr "search.user_kind"}}</div>
										<div class="menu">
											{{range .Users}}
												<div class="item" data-value="{{.ID}}">
													{{ctx.AvatarUtils.Avatar . 28 "mini"}}{{template "repo/search_name" .}}
												</div>
											{{end}}
										</div>
									</div>
								</div>
								{{if .Owner.IsOrganization}}
									<div class="whitelist field">
										<label>{{ctx.Locale.Tr "repo.settings.tags.protection.allowed.teams"}}</label>
										<div class="ui multiple search selection dropdown">
											<input type="hidden" name="allowlist_teams" value="{{.allowlist_teams}}">
											<div class="default text">{{ctx.Locale.Tr "search.team_kind"}}</div>
											<div class="menu">
												{{range .Teams}}
													<div class="item" data-value="{{.ID}}">
														{{svg "octicon-people"}}
														{{.Name}}
													</div>
												{{end}}
											</div>
										</div>
									</div>
								{{end}}
								<div class="field">
									{{if .PageIsEditProtectedTag}}
									<button class="ui primary button">
										{{ctx.Locale.Tr "save"}}
									</button>
									<a class="ui primary button" href="{{$.RepoLink}}/settings/tags">
										{{ctx.Locale.Tr "cancel"}}
									</a>
									{{else}}
									<button class="ui primary button">
										{{ctx.Locale.Tr "repo.settings.tags.protection.create"}}
									</button>
									{{end}}
								</div>
							</form>
						</div>
					</div>

					<div class="sixteen wide column">
						<table class="ui single line table">
							<thead>
								<th>{{ctx.Locale.Tr "repo.settings.tags.protection.pattern"}}</th>
								<th>{{ctx.Locale.Tr "repo.settings.tags.protection.allowed"}}</th>
								<th></th>
							</thead>
							<tbody>
								{{range .ProtectedTags}}
									<tr>
										<td><pre>{{.NamePattern}}</pre></td>
										<td>
											{{if or .AllowlistUserIDs (and $.Owner.IsOrganization .AllowlistTeamIDs)}}
												{{$userIDs := .AllowlistUserIDs}}
												{{range $.Users}}
													{{if SliceUtils.Contains $userIDs .ID}}
														<a class="ui basic label" href="{{.HomeLink}}">{{ctx.AvatarUtils.Avatar . 26}} {{.GetDisplayName}}</a>
													{{end}}
												{{end}}
												{{if $.Owner.IsOrganization}}
													{{$teamIDs := .AllowlistTeamIDs}}
													{{range $.Teams}}
														{{if SliceUtils.Contains $teamIDs .ID}}
															<a class="ui basic label" href="{{$.Owner.OrganisationLink}}/teams/{{PathEscape .LowerName}}">{{.Name}}</a>
														{{end}}
													{{end}}
												{{end}}
											{{else}}
												{{ctx.Locale.Tr "repo.settings.tags.protection.allowed.noone"}}
											{{end}}
										</td>
										<td class="right aligned">
											<a class="ui tiny primary button" href="{{$.RepoLink}}/settings/tags/{{.ID}}">{{ctx.Locale.Tr "edit"}}</a>
											<form class="tw-inline-block" action="{{$.RepoLink}}/settings/tags/delete" method="post">
												{{$.CsrfTokenHtml}}
												<input type="hidden" name="id" value="{{.ID}}">
												<button class="ui tiny red button">{{ctx.Locale.Tr "remove"}}</button>
											</form>
										</td>
									</tr>
								{{else}}
									<tr class="center aligned"><td colspan="3">{{ctx.Locale.Tr "repo.settings.tags.protection.none"}}</td></tr>
								{{end}}
							</tbody>
						</table>
					</div>
				</div>
			</div>
		{{end}}
	</div>
{{template "repo/settings/layout_footer" .}}